Select to view content in your preferred language

How to setFullExtent

951
4
11-28-2012 05:25 PM
dixonkwan1
Emerging Contributor
Dear all,
   I have a basic question..how to set the full extent of the layer or mapview?
0 Kudos
4 Replies
dixonkwan1
Emerging Contributor
when i use mLayer.getFullExtent() (the mLayer is one of the mapView's layer), but it returns null, so is it possible to setFullExtent to a layer?
0 Kudos
deleted-user-ATjHIWsdQYmT
Deactivated User
when i use mLayer.getFullExtent() (the mLayer is one of the mapView's layer), but it returns null, so is it possible to setFullExtent to a layer?


You'll have to be sure that mLayer is initialized. 
  mLayer.setOnStatusChangedListener(new OnStatusChangedListener(){
     private static final long serialVersionUID = 1L;
   public void onStatusChanged(Object source, STATUS status){
     if (OnStatusChangedListener.STATUS.INITIALIZED == status) {
            mapView.setExtent(mLayer.getFullExtent());
              }
         else if(OnStatusChangedListener.STATUS.INITIALIZATION_FAILED == status){
     dialog.dismiss(); 
     Toast toast = Toast.makeText(getApplicationContext(), "Failed to load Layer",Toast.LENGTH_SHORT);
     toast.setGravity(Gravity.BOTTOM, 0, 0);
     toast.show();
     }


   }
  });
0 Kudos
dixonkwan1
Emerging Contributor
Thanks for the reply, I have confirmed that the layer is initialized and added into mapView, but the getFullExtent is still returns null,

btw, I found only the first layer of the mapView has FullExtent, other return null.
0 Kudos
deleted-user-ATjHIWsdQYmT
Deactivated User
Here's what the API documentation says about getFullExtent();


getFullExtent
public Envelope getFullExtent()
Returns the full extent of the layer. Returns NULL if the layer does not have a full extent.

Returns:
an Envelope

objectSince:1.0


Maybe your layer does not have a full extent?

If you look at the REST endpoint of your layer, does it have a Full Extent defined?
0 Kudos