wherewhy

iOS API 2.1 envelope to visibleArea deprication

Discussion created by wherewhy on Nov 22, 2011
Latest reply on Nov 28, 2011 by wherewhy
The iOS API 2.1 says:

"The envelope property on AGSMapView has been deprecated and replaced by visibleArea to take into account map rotation."

When I change to :

AGSEnvelope *env = self.mapView.visibleArea;

I get this error:

Incompatible pointer types initializing 'AGSEnvelope *' with an expression of type 'AGSPolygon *'


Nimesh : Your answer was

The visibleArea returns AGSPolygon and you are trying to save it as AGSEnvelope. Hence the error. If you want envelope then change code line as following,

AGSEnvelope *env = self.mapView.visibleArea.envelope;


I tried this, and now I get an EXC Bad Access error on the zoom to envelope call.

I do this:
    AGSEnvelope *env = self.mapView.visibleArea.envelope;
then this:


// remove all layers from the mapView
   
    [self.mapView reset];
   

    // add the layers back in with the correct order
    if (_currentTMS.loaded == YES){
        [self.mapView addMapLayer:_currentTMS withName:@"tiledLayer"];
    }
    [self.mapView addMapLayer:baseLayer withName:@"baseLayer"];
    [self.mapView addMapLayer:_currentFMS withName:@"featureLayer"];
    [self.mapView addMapLayer:_currentGL withName:@"Parcel Outline Graphics Layer"];
    [self.mapView zoomToEnvelope:env animated:NO];

the error is onthe zoomToEnvelope.


This all worked fine when it was just AGSEnvelope *env = self.mapView.envelope;

Any suggestions?

Outcomes