Understanding zoomToEnvelope

1740
1
05-17-2011 02:34 AM
DominicLuechinger
New Contributor
Hi

I currently developing a iOS app for a botanical garden. Thx to ESRI and there well done iOS framework. It's well documented and easy to use.

During my programming I came across a strange behavior. If the AGSEnvelope has a quite small difference from xmin to xmax, but a lot bigger difference between ymin and ymax, the map will be aligned only on x direction, if I'm using zoomToEnvelope. The ymin and ymax value will not be at the edge of the mapview. Do I'm understand something wrong with the zoomToEnvelope.
This happens only, if I'm using the custom tiled layers (http://blogs.esri.com/Dev/blogs/mobilecentral/archive/2010/12/13/Developing-a-custom-tiled-layer.asp...) and a scale of approx. 1:300 - 1:600.
My understanding of zoomToEnvelope is, that the mapView will enclose the envelope. But currently, it will only adjust to one value (xmin and xmax).
Without the custom tiled layers it works as expected. Could it be, that the calculation of the  zoomToEnvelope only works until a certain zoomLevel (scale). I've added my own scale levels: 1:1500, 1:1000, 1:600, 1:300 for a small area.
Btw: The spacial references are all the same. wkid = 102100

I could add a special zoom function, that will calculate an envelope from a existing envelope relative to the current mapView screen size. Not sure, if this is not already implemented.

I can provide more code, if needed.
AGSSpatialReference *wgs102100 = [AGSSpatialReference spatialReferenceWithWKID:102100];
AGSEnvelope*   envPoly = [AGSEnvelope envelopeWithXmin:843900
                                       ymin:6033700
                                       xmax:843950
                                       ymax:6033790
                           spatialReference:wgs102100];

Thanks for your advice.
0 Kudos
1 Reply
MuratDzhusupov
New Contributor II
I have now same result with Open Street Map
AGSOpenStreetMapLayer *osLyr = [AGSOpenStreetMapLayer openStreetMapLayer];
 [self.mapView addMapLayer:osLyr withName:@"OpenStreetMap Layer"];
 
AGSSpatialReference *sr = [AGSSpatialReference spatialReferenceWithWKID:102100];

 AGSEnvelope *env = [AGSEnvelope envelopeWithXmin:
  9183090.953483 ymin:7363658.125409// correct = 7301109.281239 
            xmax:9301013.541211 
            ymax:7364392.063907// correct = 7454408.645285 
         spatialReference:sr];
 [self.mapView zoomToEnvelope:env animated:YES];


If I insert incorrect ymin and ymax values (ymin is too near from ymax) then map is drawn correctly (without flattening).
0 Kudos