visibleAreaEnvelope not set after zoom

715
2
Jump to solution
04-28-2014 02:31 PM
KatherineLawler
New Contributor
I'm trying to retrieve the visibleAreaEnvelope set after performing a zoom operation such as zoomToEnvelope or zoomToResolution etc.  The following code performs the zoom as expected, however when I query the visibleAreaEnvelope it is always the envelope that was in existence before the zoom (in my case the max envelope).   Does the zoom have to finish before the new envelope is available?  If so, I can't find any way to determine when the map has been fully updated. 

e.g.  //In this example centre has been set to the GPS location in WKID:102100 map units

        double zoomRes = [agsMapView minResolution];
        while (zoomRes < 2)
            zoomRes *= 2;
        AGSSpatialReference *srs = [AGSSpatialReference spatialReferenceWithWKID:102100];
        [agsMapView zoomToResolution:zoomRes withCenterPoint:[AGSPoint pointWithX:centre.x y:centre.y spatialReference:srs] animated:NO];
        AGSEnvelope *envelope1 = [webMapView.agsMapView visibleAreaEnvelope];
0 Kudos
1 Solution

Accepted Solutions
NimeshJarecha
Esri Regular Contributor
Yes, you'll have to wait for zoom to finish to fetch new visibleAreaEnvelope. You should listen to the AGSMapViewDidEndZoomingNotification (AGSMapView doc).

Hope this helps!

Regards,
Nimesh

View solution in original post

0 Kudos
2 Replies
NimeshJarecha
Esri Regular Contributor
Yes, you'll have to wait for zoom to finish to fetch new visibleAreaEnvelope. You should listen to the AGSMapViewDidEndZoomingNotification (AGSMapView doc).

Hope this helps!

Regards,
Nimesh
0 Kudos
KatherineLawler
New Contributor
Thanks Nimesh,

I was hoping to avoid that but it does work.  Since in my case I need to know right away I have to wait for it in a background thread which is a bit messy but does work.  It would be nice if there were similar routines as there are for MapKit where you can query what the resulting limits will be given a new envelope before actually setting it.

Kathy
0 Kudos