|
POST
|
John, here's a code snippet that should help. It doesn't cover everything you asked for but should give you a good idea of how to implement the listeners. @Override
public void onStatusChanged(Object source, STATUS status) {
if (OnStatusChangedListener.STATUS.INITIALIZED == status && source == _mapView) {
_isMapLoaded = true;
setMapType(_maptype);
if(_center_lat == null || _center_lon == null){
latlon = new Point(_DEFAULT_LON,_DEFAULT_LAT);
}
else{
latlon = new Point(_center_lon,_center_lat);
}
Point point = (Point)GeometryEngine.project(latlon,SpatialReference.create(4326), _mapView.getSpatialReference());
_mapView.centerAt(point,false);
if(_center_scale == null){
_mapView.setScale(_DEFAULT_SCALE);
}
else{
_mapView.setScale(_center_scale);
}
Log.d("MapViewController", "setOnStatusChangedListener() STATUS: " + status);
dispatchStatusEvent(new MapViewControllerEvent(MapViewEvent.STATUS_INITIALIZED), status.toString()); //custom event
}
if (OnStatusChangedListener.STATUS.LAYER_LOADING_FAILED == status && source == _mapView){
Log.d("MapViewController", "setMapListeners() STATUS: " + status + ", " + status.toString());
displayToast("There was a map problem with loading a layer: " + status.toString());
dispatchStatusErrorEvent(new MapViewControllerEvent(MapViewEvent.STATUS_LAYER_LOADING_FAILED), status.toString()); //custom event
}
}
-Andy
... View more
08-10-2012
07:07 AM
|
0
|
0
|
1904
|
|
POST
|
Not sure if this will help or not since it's not the exact code you are asking about. However, this snippet shows one example for iterating through the layers and work with the various properties: Layer[] layerArr = map.getLayers();
for(Layer layer : layerArr)
{
Boolean visible = layer.isVisible();
if(layer instanceof ArcGISTiledMapServiceLayer && visible == true){
ArcGISTiledMapServiceLayer tempMap = (ArcGISTiledMapServiceLayer) layer;
ArcGISLayerInfo[] info = tempMap.getLayers();
Log.d("test","Layer name= " + tempMap.getName() + ", " + info[0].getName());
String name = info[0].getName().toLowerCase();
Boolean vis = info[0].isVisible();
if(name.equals("world street map")){
layerButton.setText("Topo");
streetLayer.setVisible(false);
topoLayer.setVisible(true);
}
if(name.equals("topographic info")){
layerButton.setText("Streets");
streetLayer.setVisible(true);
topoLayer.setVisible(false);
}
}
}
-Andy
... View more
08-08-2012
12:11 PM
|
0
|
0
|
1406
|
|
POST
|
I agree with Andrew. Other examples are when you are running an application with multiple views (Activities), or when you minimize the application and then start it back up. During those conditions and depending on how you coded your app the GPS may resume before the map is loaded and then your mapping code may throw an error since the map won't be ready. When you minimize the app or return to your MapView Activity, the best practice is to test to make sure the map is loaded after onResume() is called. You can accomplish this by using a Handler. Each Handler runs a single thread off of the main User Interface and you can check to see if the STATUS.INITIALIZED has occured. And once the map is loaded (and visible) then use the GPS. Using this pattern you can ensure that everything happens in the correct order and you can fail gracefully if, for example, that map didn't load because of a poor internet connection. If anyone needs the code for this scenario ping me agup at esri dot com. I also blogged about using onResume() here: http://www.andygup.net/?p=779. -Andy
... View more
08-08-2012
11:57 AM
|
0
|
0
|
1904
|
|
POST
|
Did you look at the addLayer(Layer layer, int index) method? You can add a layer using an index. Conversely, you can also remove a layer using removeLayer(int index). -Andy
... View more
08-08-2012
11:32 AM
|
0
|
0
|
1406
|
|
POST
|
@totogogo that issue was fixed in the latest version and you took the recommended steps. Did you clean the project and also delete the old copy of the app off your phone? If that still doesn't work, I recommend opening a support ticket. That way we can collect all the details of your environment. -Andy
... View more
08-08-2012
11:21 AM
|
0
|
0
|
1011
|
|
POST
|
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
... View more
08-01-2012
10:59 AM
|
0
|
0
|
819
|
|
POST
|
Andrew, we've confirmed that this is one of those cases where the NIM was indirectly related and the solution fixed the problem. -Andy
... View more
08-01-2012
09:36 AM
|
0
|
0
|
325
|
|
POST
|
I saw that too right after I posted it. We're running this down now to make 100% sure. -Andy
... View more
07-31-2012
08:58 AM
|
0
|
0
|
1719
|
|
POST
|
The system says NIM081315 is resolved: http://support.esri.com/en/bugs/nimbus/TklNMDgxMzE1 Are you still having problems when using the latest SDK? If you are then please consider opening another support ticket. We may have missed something unique in your setup or configuration. Opening a ticket will help us track down and document any loose ends. -Andy
... View more
07-31-2012
06:54 AM
|
0
|
0
|
1719
|
|
POST
|
@gabrielspmoreira Please contact your nearest Esri sales office to make sure you get all your questions correctly answered: http://www.esri.com/about-esri/contact.html -Andy
... View more
07-17-2012
01:10 PM
|
0
|
0
|
696
|
|
POST
|
Simon, Enrique, sounds like you need to open a tech support ticket. They can fully capture the information related to this problem, they can submit a bug fix request, and we'll be able to track the problem. -Andy
... View more
07-13-2012
06:57 AM
|
0
|
0
|
1901
|
|
POST
|
@mggl if the setOnPanListener(null) pattern doesn't work then make sure you don't have another listener enabled somewhere. Chances are that another listener is overriding. -Andy
... View more
06-25-2012
09:47 AM
|
0
|
0
|
1229
|
|
POST
|
Robert, Try upgrading to ArcGIS for Android SDK v2. That was a known bug that should be fixed in the latest version. -Andy
... View more
06-22-2012
02:25 PM
|
0
|
0
|
982
|
|
POST
|
Chris, this issue is also referred to in this forum post (scroll to the bottom): http://forums.arcgis.com/threads/58443-MapView-zoomToScale-and-zoomToResolution-not-working Back on May 24, I thought Luke got things running again.... -Andy
... View more
06-18-2012
08:15 AM
|
0
|
0
|
406
|
| Title | Kudos | Posted |
|---|---|---|
| 2 | 08-01-2025 06:20 AM | |
| 1 | 05-27-2025 12:39 PM | |
| 1 | 04-23-2025 06:56 AM | |
| 1 | 04-23-2025 07:09 AM | |
| 1 | 04-08-2025 09:05 AM |
| Online Status |
Offline
|
| Date Last Visited |
12-05-2025
07:24 AM
|