Select to view content in your preferred language

MapView Initial Extent

3291
4
07-31-2012 01:39 PM
LukeCatania
Occasional Contributor
I have tried to set the initial extent of the mapview to the world, but it seems to be overridden by the extent of the first layer loaded into the mapview.  How to I get around this?  All my layers are WGS_1984 Geographic. I have set a the initial extent in the xml as well as added onStatusChanged listener on each layer:


public void onStatusChanged(Object arg0, STATUS status) {
                /*
                 * Check if layer's new status = INITIALIZED. If it is,
                 * initialize UI elements
                 */
                if (status.equals(OnStatusChangedListener.STATUS.INITIALIZED)) {
                    System.out.println("onStatusChanged: "
                        + arcGISLocalTiledLayer.getUrl());
                    mapView.setExtent(new Envelope(-180, -90, 180, 90));
                }
            }
0 Kudos
4 Replies
AndyGup
Esri Regular Contributor
Luke,

Make sure you are listening for when the first layer has been initialized using the MapView's OnStatusChanged event, for example:

mapView = new MapView(this);
mapView.setOnStatusChangedListener(new OnStatusChangedListener() {
  private static final long serialVersionUID = 1L;
  
 @Override
 public void onStatusChanged(Object source, STATUS status) {
   if (OnStatusChangedListener.STATUS.INITIALIZED == status && source == _mapView) {
   //TODO Set your extent here
   }
   if (OnStatusChangedListener.STATUS.LAYER_LOADING_FAILED == status && source == _mapView){
   //TODO
   }
 }
}); 

-Andy
0 Kudos
ChristopherDonohue
Emerging Contributor
I'm experiencing the same issue even when I set the extent after the map is done initializing.
0 Kudos
NigelDsouza
Frequent Contributor
why don't you try
MapView.getMapBackgroundExtent();

It will set this to the Extent of the Map.

My question is do you want to set it to the full extent or a specific Extent like say when the Map gets initialized it should be set around a particular country or something.
0 Kudos
GSauers
Frequent Contributor
Has anyone found a solution for this?

I want to use 2 or more cached maps but the extent only allows me to view one of them.
0 Kudos