How to map  zoom in level?

5530
7
06-26-2010 04:39 PM
ZhaoMingJin
New Contributor II
question: the TiledMap have 8 level,but I want only map zoomin 4 level?
How to set?
0 Kudos
7 Replies
JeremyBixby
New Contributor III
set the currentLevel property on the AGSMapView object to 4.

mapView.currentLevel = 4;
0 Kudos
ZhaoMingJin
New Contributor II
set the currentLevel property on the AGSMapView object to 4.

mapView.currentLevel = 4;


SDK:
- (NSInteger) currentLevel [read, assign]
Current level of detail (scale level) displayed by the map.

only read !!!
can't set or write!!
0 Kudos
JeremyBixby
New Contributor III
Hmm...good point. 

Maybe the easiest thing, would be if ESRI would make that property write-able.

Other than that, you could probably work around it by setting the zoom level on the GPS object (if you have enabled GPS on the device):

 [mapView.gps start];
 mapView.gps.autoPan = YES;
 mapView.gps.zoomLevel = 6;


You could probably also do something like this with generic coordinate assignments:

 AGSEnvelope *myEnvelope = [[AGSEnvelope alloc] initWithXmin:2232848.00 ymin:2232843.00 xmax:233167.00 ymax:251425.00 spatialReference:mapView.spatialReference];
 [mapView zoomToEnvelope:myEnvelope animated:YES];
 
 [myEnvelope release];


There are a few other undocumented methods on the AGSMapView object, which will change your zoomLevel...

[mapView setZoomScale:4.0];
 [mapView setZoomScale:4.0 animated:YES];


This screws up your resolution, though.

My guess is, ESRI wants you to set it through the mapview.gps.zoomlevel property.  Actually, I would be curious to hear ESRI staff weigh in on this, if for no other reason, to hear some of the philosophy behind the ArcGIS iPhone SDK architecture...
0 Kudos
DiveshGoyal
Esri Regular Contributor
Here's how you could zoom to a scale level -


 int levelToZoomTo = 4;
 AGSLOD* lod = [tiledLayer.mapServiceInfo.tileInfo.lods objectAtIndex:levelToZoomTo];
 float zoomFactor = lod.resolution/self.mapView.resolution;
 AGSMutableEnvelope *newEnv =  
    [AGSMutableEnvelope envelopeWithXmin:self.mapView.envelope.xmin
     ymin:self.mapView.envelope.ymin 
     xmax:self.mapView.envelope.xmax 
     ymax:self.mapView.envelope.ymax
     spatialReference:self.mapView.spatialReference];
            
 [newEnv expandByFactor:zoomFactor];
 [self.mapView zoomToEnvelope:newEnv animated:YES];
0 Kudos
KOLDODUARTE
New Contributor
Hi Guys,

I try to zoom in my current location with a custom envelope. I do this envelope with those parameters:

AGSEnvelope *envelopeGPS = [AGSEnvelope envelopeWithXmin:mapView.gps.currentPoint.x    ymin:mapView.gps.currentPoint.y xmax:mapView.gps.currentPoint.x max:mapView.gps.currentPoint.x  spatialReference:self.mapView.spatialReference];  
  
[mapView zoomToEnvelope:envelopeGPS animated:YES];


With this form, the map goes to Africa... it is the center of the map.
I don´t use the autopan property because is too zoom for my base map and I don´t see it.

Best regards,
Koldo.
0 Kudos
HarikantJammi
New Contributor
This is what i use , without forming an envelope

[self.mapView centerAtPoint:((AGSPoint *)(graphic.geometry)) animated:YES];
  NSArray * lodsArray = self.worldTopoMapService.tileInfo.lods ;
//topomap service is AGSTiledMapServicelayer
  AGSLOD * finalLOD = [lodsArray objectAtIndex:5] ;
// 5 is the tile level to zoom to 
  while (self.mapView.mapScale >= finalLOD.scale) {
   [self.mapView zoomIn:YES] ;
  }

 
 
 

  [self.mapView showCalloutAtPoint:(AGSPoint *) graphic.geometry forGraphic:graphic] ;
0 Kudos
KOLDODUARTE
New Contributor
This is what i use , without forming an envelope

[self.mapView centerAtPoint: ((AGSPoint *)(graphic.geometry)) animated:YES];
  NSArray * lodsArray = self.worldTopoMapService.tileInfo.lods ;
//topomap service is AGSTiledMapServicelayer
  AGSLOD * finalLOD = [lodsArray objectAtIndex:5] ;
// 5 is the tile level to zoom to 
  while (self.mapView.mapScale >= finalLOD.scale) {
   [self.mapView zoomIn:YES] ;
  }

  [self.mapView showCalloutAtPoint: (AGSPoint *) graphic.geometry forGraphic:graphic] ;


Hi harikant_jammi,

Please, can you tell me what is "self.worldTopoMapService" and "graphic", because I don´t have those objects in my project, thanks!

BR,
Koldo.
0 Kudos