bkrzys

zoomToEnvelope not working

Discussion created by bkrzys on Jan 20, 2011
Latest reply on Jan 21, 2011 by bkrzys
Example code below displays two layers and attempts to zoom to an envelope defined by a geographic lat-long box, but the zoom doesn't work.  Suspect I am missing something simple with how the envelope is defined?

Thanks ahead of time for any help.

Brian.

  
  //
  // ----- OpenStreetMap base layer
  //
  AGSOpenStreetMapLayer *baseLayer = [[AGSOpenStreetMapLayer alloc] init];
  [self.mapView addMapLayer:baseLayer withName:@"OpenStreetMap"];
  [baseLayer release];
  //
  // ----- US highways from ESRI
  //
  NSURL* url = [NSURL URLWithString: @"http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StateCityHighway_USA/MapServer"];  
  AGSDynamicMapServiceLayer* highwayLayer = [AGSDynamicMapServiceLayer dynamicMapServiceLayerWithURL: url];
  [self.mapView addMapLayer:highwayLayer withName:@"US Highways"];
  //
  // ----- zoom to approximately Colorado
  //
  AGSSpatialReference *sr = [AGSSpatialReference spatialReferenceWithWKID:4326];
 AGSEnvelope *env = [AGSEnvelope envelopeWithXmin:-110.0 
                                              ymin:35.0 
                                              xmax:-100.0 
                                              ymax:40.0 
                                  spatialReference:sr];
  [self.mapView zoomToEnvelope:env animated:YES];

Outcomes