AnsweredAssumed Answered

How To Limit Zooming/Panning ?

Question asked by ahmed.elashker-esrinea-esridist on Jun 12, 2014
Latest reply on Jun 15, 2014 by ahmed.elashker-esrinea-esridist
I'm using an AGSMapView with a AGSTiledMapServiceLayer for basemap layer as follows;

- (void)viewDidLoad
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    NSURL *basemapURL = [[NSURL alloc] initWithString:@""];
    AGSTiledMapServiceLayer *basemapLayer = [AGSTiledMapServiceLayer tiledMapServiceLayerWithURL:basemapURL];
    [mapView addMapLayer:basemapLayer withName:@"Basemap Tiled Layer"];
    mapView.layerDelegate = self;
    mapView.touchDelegate = self;

The app opens up as in the first attached photo, and it can be zoomed out and panned like in the 2nd photo.

I read somewhere that setting the mapView's maxEnvelope property is the only way to limit zooming/panning, however I couldn't get my finger around the envelope value I should be setting and I tried [mapView toMapEnvelope:CGRect]. I also tried working with the base layer's minScale and maxScale values but that didn't work either.

I had a successful try with tracking the map scale via AGSMapViewDidEndZoomingNotification to restore it to fit the screen when zoomed out too much, however that didn't prevent me from seeing the outsider grid around the map for a while, and I didn't know which value to monitor if I decided to listen for AGSMapViewDidEndPanningNotification as well.