Page 2 of 2 FirstFirst 12
Results 11 to 17 of 17

Thread: iOS: How to use Boundings

  1. #11
    Dev platform evangelist dandronic's Avatar
    Join Date
    31.03.2014
    Posts
    177
    We've attached a demo file over at https://www.dropbox.com/s/1un9l9ywex...ewController.m that can be integrated in the demo project and should illustrate how to arrive at your scenario - please take a look and see if this satisfies your needs.

    P.S. We could not reproduce the behaviour you've experienced

  2. #12
    Etablierter skobbler
    Join Date
    04.07.2014
    Posts
    10
    Sorry but this is not what I want. Furthermore in this script you commented out the other annotation. So in which way it should illustrate my scenario? There should be multiple annoations and I want that the region center is the middle of e.g. three annoations!

  3. #13
    Dev platform evangelist dandronic's Avatar
    Join Date
    31.03.2014
    Posts
    177
    The problem regarding "self.mapView fitBounds:box withPadding:CGSizeMake(50.0, 50.0)]; does a strange behaviour. The map zooms like it's in zoomlevel 20, despite zoomlevel = 12. " will be fixed in the next version (September's update)
    Meanwhile, in order for it to work it can be called after viewWillAppear.

  4. #14
    Dev platform evangelist dandronic's Avatar
    Join Date
    31.03.2014
    Posts
    177
    Quick update: this bug was fixed and will be deployed with the 2.2 SDK update (ETA week 37 or week 38, 2014)

  5. #15
    Etablierter skobbler
    Join Date
    07.03.2016
    Posts
    42
    Hi,

    I have a working version of what you want to do, it is just fitting a route instead of annotations. Here is my code, hope it helps you:

    Code:
    @implementation BRVMapPreview
    
    - (void)awakeFromNib {
        
        [super awakeFromNib];
    }
    
    - (void)setupSkMapView {
        
        self.skMapView = [[SKMapView alloc] initWithFrame:self.bounds];
        self.skMapView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
        self.skMapView.mapScaleView.hidden = YES;
        self.skMapView.delegate = self;
        self.skMapView.settings.rotationEnabled = YES;
        self.skMapView.settings.showCurrentPosition = NO;
        self.skMapView.settings.followUserPosition = NO;
        self.skMapView.settings.showCompass = NO;
        self.skMapView.settings.displayMode = SKMapDisplayMode2D;
        self.skMapView.settings.headingMode = SKHeadingModeNone;
        SKMapZoomLimits zoomLimits;
        zoomLimits.mapZoomLimitMin = 7;
        zoomLimits.mapZoomLimitMax = 21;
        self.skMapView.settings.zoomLimits = zoomLimits;
        [self addSubview:self.skMapView];
    }
    
    #pragma mark - Helpers
    - (void)drawRouteFromArray:(NSArray *)locations {
    
        self.isFit = NO;
        [self setupSkMapView];
        CLLocation *firstLocation = [locations firstObject];
        CLLocation *lastLocation = [locations lastObject];
    
        self.boundaries = [SKBoundingBox boundingBoxWithTopLeftCoordinate:firstLocation.coordinate bottomRightCoordinate:lastLocation.coordinate];
        
        for (CLLocation *location in locations) {
            self.boundaries = [self.boundaries boundingBoxIncludingLocation:location.coordinate];
        }
        self.polyline.coordinates = locations;
        [self.skMapView addPolyline:self.polyline];
        
    }
    
    - (void)addPOIs:(NSArray *)pois {
        
        for (BRVPOIComponent *poi in pois) {
            
            SKAnnotation *annotation = [SKAnnotation new];
            annotation.identifier = (int)poi.poiId + 11;
            
            [self.skMapView addAnnotation:annotation withAnimationSettings:[SKAnimationSettings defaultAnimationSettings]];
        }
    }
    
    
    #pragma mark - Getter
    - (SKPolyline *)polyline {
        
        if (!_polyline) {
            _polyline = [SKPolyline polyline];
            _polyline.identifier = 11;
            _polyline.borderDotsSize = 0.1;
            _polyline.borderDotsSpacingSize = 0.1;
            _polyline.fillColor = [UIColor brv_buttonTextBlueWithAlpha:0.5];
            _polyline.lineWidth = 16;
        }
        return _polyline;
    }
    
    #pragma mark - SKMapViewDelegate
    - (void)mapView:(SKMapView *)mapView didChangeToRegion:(SKCoordinateRegion)region {
        
        if (self.isFit) {
      
            return;
        }
        else {
           [self.skMapView fitBounds:self.boundaries withPadding:CGSizeMake(20.0, 20.0)];
            self.isFit = YES;
        }
    }

  6. #16
    Oberskobbler
    Join Date
    22.07.2014
    Posts
    399
    Thank you high5fly for sharing this!

  7. #17
    Etablierter skobbler
    Join Date
    07.03.2016
    Posts
    42
    Hi Adele,

    I have to share the updated version after updating to 3.0.

    KR,
    Miro

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •