MapView zoomToScale and zoomToResolution not working

7607
9
05-24-2012 07:35 AM
LukeCatania
New Contributor III
I tried both MapView zoomToScale and zoomToResolution.  In zoomToScale I tried 24000 as the scale parameter.  In zoomToResolution, I tried .5, which is the highest resolution of my data.  Am I misinterpreting these parameters,  The only thing that it does is pan the map to center it around the point.  No zooming occurs.  I want to be able to zoom to the point and zoom to the highest res of the data in the mapview.
0 Kudos
9 Replies
AndyGup
Esri Regular Contributor
You could do a two step process:

1) centerAt()
2) setScale()

-Andy
0 Kudos
LukeCatania
New Contributor III
I tried both MapView zoomToScale and zoomToResolution.  In zoomToScale I tried 24000 as the scale parameter.  In zoomToResolution, I tried .5, which is the highest resolution of my data.  Am I misinterpreting these parameters,  The only thing that it does is pan the map to center it around the point.  No zooming occurs.  I want to be able to zoom to the point and zoom to the highest res of the data in the mapview.


Same issue.  It pans to the point. but does not zoom to the scale.
0 Kudos
deleted-user-ATjHIWsdQYmT
Occasional Contributor III
are you using the correct map units?  I tried setting my scale to 1200 (1":100ft) and it worked. 

When you call the CenterAt() method, try setting the animation property to false, see if that solves your problem.  map.CenterAt(point,false);
As Andy points out in the thread below, perhaps the pan animation from CenterAt() is not completing before you are setting the scale, thus nothing is happening.

see this thread:
http://forums.arcgis.com/threads/51928-Callout-doesn-t-move-with-MapView.centerAt?highlight=animatio...
0 Kudos
AndyGup
Esri Regular Contributor
And, here's a code snippet showing the basic pattern:

map.setOnSingleTapListener(new OnSingleTapListener() {
 
 /**
  * 
  */
 private static final long serialVersionUID = 1L;

 @Override
 public void onSingleTap(float x, float y) {
  double _x = x;
  double _y = y;
  double scale = 500000;
  
  Point pt = new Point(_x,_y);
  map.centerAt(pt,true);
  map.setScale(scale);
 }
});


-Andy
0 Kudos
LukeCatania
New Contributor III
are you using the correct map units?  I tried setting my scale to 1200 (1":100ft) and it worked. 

When you call the CenterAt() method, try setting the animation property to false, see if that solves your problem.  map.CenterAt(point,false);
As Andy points out in the thread below, perhaps the pan animation from CenterAt() is not completing before you are setting the scale, thus nothing is happening.

see this thread:
http://forums.arcgis.com/threads/51928-Callout-doesn-t-move-with-MapView.centerAt?highlight=animatio...


Well, it turned out I had the call in the wrong if-then clause.  I did get the zoomToScale to work, but whenever I use the zoomToResolution, the app freezes up, I get the error:

05-24 15:50:57.420: E/gralloc(15219): GetBufferLock timed out for thread 15219 buffer 0x41 usage 0x30 LockState 2

constantly in my logcat window and the tablet device reboots.

I need to use zoomToResolution because I have a GeoLocate button on my app and I want to zoom to the user's current location when that button is pressed and I want to zoom all the way down to tha map's highest resoltuion.  There is a getMaxResolution, but there is no getMaxScale.  I want to make the call mapView.zoomToResolution(currentLocation, mapView.getMaxResolution()), but cannot since the app continually freezes and the tablet reboots due to this GetBufferLock error.
0 Kudos
AndyGup
Esri Regular Contributor
Luke, a few questions related to the GetBufferLock error:

1) Have you verified with the Eclipse debugger that your app crashes as soon as you "step into" zoomToResolution()?

2) And, that happens 100% of the time?

3) Can you copy the entire crash sequence from Logcat and either paste or attach it?

4) What's the make/model of the device?

5) Android OS version?

6) ArcGIS SDK version?

7) Code snippet of the method where the error is happening?

Thanks,

-Andy
0 Kudos
LukeCatania
New Contributor III
Luke, a few questions related to the GetBufferLock error:

1) Have you verified with the Eclipse debugger that your app crashes as soon as you "step into" zoomToResolution()?

2) And, that happens 100% of the time?

3) Can you copy the entire crash sequence from Logcat and either paste or attach it?

4) What's the make/model of the device?

5) Android OS version?

6) ArcGIS SDK version?

7) Code snippet of the method where the error is happening?

Thanks,

-Andy


I meant I wanted to use getMinResolution().  It seems to be working now.  Here's some of the info.

1) No.
2) No.  But it has happened many times.  I found a suggestion to run "adb shell top -t" and look at the actual thread/Process that is causing the error and found it to be com.android.systemui, but did not find what call caused it yet.
3) I will when it happens again.
4) Motorola Xoom
5) 4.0.4
6) 1.1
7)
public class GeoUpdateHandler implements LocationListener {
  @Override
  public void onLocationChanged(Location location) {
   if (geoLocate) {
    currentLocation = location;
    double lat = location.getLatitude();
    double lng = location.getLongitude();
    System.out.println("onLocationChanged, Location: "
      + location.getLongitude() + ", "
      + location.getLongitude());
    Point point = new Point(lng, lat);
    System.out.println("Max Resolution: " + mapView.getMaxResolution());
    System.out.println("Min Resolution: " + mapView.getMinResolution());
     mapView.zoomToResolution(point, mapView.getMinResolution());
    System.out.println("onLocationChanged, Point: " + point.getY()
      + ", " + point.getX());
    Map<String, Object> userLocationAttributes = new HashMap<String, Object>();
    Graphic userlocationGraphic = new Graphic(1, point,
      new SimpleMarkerSymbol(Color.RED, 10, STYLE.CIRCLE),
      userLocationAttributes, null);
    graphicsLayer.addGraphic(userlocationGraphic);
   }
  }
0 Kudos
PatriziaPeller
New Contributor
Hi everybody!

Please help me, i just can't get zooming to work. I tried all the possible solutions mentioned in any conversations on the topic but nothing will work. 😞

I'm currently developing on a Samsung Galaxy S1 with Android 2.2.1 and ArcGIS version 1.1.1. and i've tried all the following possibilities:

1) add an OnZoomListener to the map an have it deal with the scaling

2) switch from zoomToScale() to centerAt() + setScale()

3) switch from zoomToScale() to zoomToResolution()

I've even tripple-checked if the center point is correctly initialized or if I might first perform a GeometryEngine.project() on the coordinates, but that won't do the trick either.

Can anybody help me please? My code currently is the same as in the tutorial, once again.

Greetings!
0 Kudos
AneteFridrihsone
New Contributor II

Im having exact same problems. Di somebody figure this out??

Thanks!

0 Kudos