AnsweredAssumed Answered

Map zooms in on equator or not at all

Question asked by purpledunes on Apr 25, 2014
Latest reply on Apr 28, 2014 by purpledunes
I'm showing a small map in an iPad app and I'm able to display the user location on it as a blinking blue dot on a map of the world. I would like to zoom in on a specific location, e.g. the city of Utrecht in The Netherlands, at a zoom level of a few hundred meters.

Unfortunately when I call zoomToEnvelope:envelope it drops me in the middle of the ocean, presumably 0 latitude by 0 longitude. If on the other hand I call zoomWithFactor the app doesn't zoom in anywhere. I must be doing something wrong. I actually had it working before, so perhaps I broke something (I'll try diff-ing my way to fixing it).

The spatial reference of AGSMapView *map is as excepted when mapViewDidLoad is called. I'm not getting any error messages. I'm calling zoomToEnvelope on the main thread. What else should be careful about?

//  ViewController.m #import <ArcGIS/ArcGIS.h> @interface ViewController () <AGSMapViewLayerDelegate>  {     IBOutlet AGSMapView *map; } @end  @implementation ViewController  - (void)viewDidLoad {     [super viewDidLoad];     NSString *mapLocation = @"https://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer";         AGSTiledMapServiceLayer *basemapServiceLayer = [AGSTiledMapServiceLayer tiledMapServiceLayerWithURL:[NSURL URLWithString:mapLocation]];     [map addMapLayer:basemapServiceLayer withName:@"Tiled Layer"];     map.layerDelegate = self;     }  -(void)mapViewDidLoad:(AGSMapView *)mapView {     [map.locationDisplay startDataSource];       if(map.loaded) {         double x = 5.0;         double y = 52.5;         zoomDegrees = 0.005         AGSEnvelope *envelope = [AGSEnvelope envelopeWithXmin:x - zoomDegrees ymin:y - zoomDegrees xmax:x + zoomDegrees ymax:y + zoomDegrees spatialReference:map.spatialReference];       // Zooms in on the equator:   [map zoomToEnvelope:envelope animated:YES];       // Does nothing at all:         // [map zoomWithFactor:4 atAnchorPoint:CGPointMake(50, 80) animated:YES];     } } @end

Outcomes