Select to view content in your preferred language

Limit map zoom level on sdk v2.3.2

2501
2
Jump to solution
11-22-2012 08:17 PM
marxonline
Emerging Contributor
Hello,
May I know if its possible to limit zoom on the map beyond certain levels ? I could not find a way referring to the api documentation.

My problem is the basemap layer provides detail upto 11 levels (i cant control this one) & the sublayer I add on provides only upto 7 levels of detail. because of this I want to limit the zoom on sublayer by 7 levels. Please provide me instructions on how to achieve this or a workaround. I'm using sdk v2.3.2

I tried some of the undocumented api calls mentioned in some of the old forum threads but they dont seem to work with current sdk.

Thanks & Regards,
Marx
0 Kudos
1 Solution

Accepted Solutions
RickJones
Deactivated User
What I've done is catch the zoom event

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(respondToZoom:) name:@"MapDidEndZooming" object:nil];

and reset the scale if it's too low


- (void)respondToZoom:(NSNotification*)notification {
   self.scale = self.mapView.mapScale;

    if (self.scale < 500) {
        // zoom out
        AGSEnvelope *e = self.mapView.visibleArea.envelope;
        AGSPoint *pt = e.center;
       
        [self.mapView zoomToScale:500 withCenterPoint:pt animated:YES];
    }
}

View solution in original post

0 Kudos
2 Replies
RickJones
Deactivated User
What I've done is catch the zoom event

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(respondToZoom:) name:@"MapDidEndZooming" object:nil];

and reset the scale if it's too low


- (void)respondToZoom:(NSNotification*)notification {
   self.scale = self.mapView.mapScale;

    if (self.scale < 500) {
        // zoom out
        AGSEnvelope *e = self.mapView.visibleArea.envelope;
        AGSPoint *pt = e.center;
       
        [self.mapView zoomToScale:500 withCenterPoint:pt animated:YES];
    }
}
0 Kudos
marxonline
Emerging Contributor
What I've done is catch the zoom event

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(respondToZoom:) name:@"MapDidEndZooming" object:nil];

and reset the scale if it's too low


- (void)respondToZoom:(NSNotification*)notification {
   self.scale = self.mapView.mapScale;

    if (self.scale < 500) {
        // zoom out
        AGSEnvelope *e = self.mapView.visibleArea.envelope;
        AGSPoint *pt = e.center;
       
        [self.mapView zoomToScale:500 withCenterPoint:pt animated:YES];
    }
}


Thanks alot Rick. this seems to be working. I hope they will include an api in future to get rid of the stretchy effect as well 🙂

regards,
Marx
0 Kudos