Select to view content in your preferred language

switching base map on android

3911
7
10-10-2012 12:23 AM
dixonkwan1
Emerging Contributor
Dear all,
       I found "The first layer that is added to the MapView using either approach presented previously will defines its initial extent, resolution, and spatial reference for the entire map. To change any of these attributes, use the corresponding setter methods; otherwise the MapView will maintain these initial values during the lifetime of the object." in MapView API Reference page.

     the problem is, when i switch local map to arcgis online base map. extent, resolution especially full-extent follow the first layer that is soooo annoying, so I decided to reset MapView.
     I've tried reset/reinitialize/new MapView but it doesn't work excepts switch activity, so I wonder if there is any methods that make MapView back to initialze states?
0 Kudos
7 Replies
AndyGup
Esri Regular Contributor
Dixon, can you explain the requirements for when you switch from local map to ArcGIS Online base map? Usually when you swap maps the intention is to keep the exact same extent and zoom level.

And, is the ArcGIS Online base map a "WebMap" or an ArcGIS Server Map Service (REST endpoint)?

If you need to change the extent and resolution/zoom level there are methods for those that you can apply that after a layer has been added to the map, for example:

zoomToResolution(Point centerPt, double res) 
setExtent(Geometry geometry) 

-Andy
0 Kudos
dixonkwan1
Emerging Contributor
Dixon, can you explain the requirements for when you switch from local map to ArcGIS Online base map? Usually when you swap maps the intention is to keep the exact same extent and zoom level.

And, is the ArcGIS Online base map a "WebMap" or an ArcGIS Server Map Service (REST endpoint)?

If you need to change the extent and resolution/zoom level there are methods for those that you can apply that after a layer has been added to the map, for example:

zoomToResolution(Point centerPt, double res) 
setExtent(Geometry geometry) 

-Andy


Andy,
         Thx for the reply. Yes, usually maps are using the exact same extent and zooming level, but the requirement is: using the local map at start, if user needs online map service, the app pops warning dialog for using internet service which may cost. and the local map is a clipped version, so when swap to online map, the full extent, minimum resolution etc are limited.
         I'm currently using ArcGIS REST service, and there is another question if you don't mind. How to avoid "map data not yet available" tiled images display on the map when there are no images on the map? I know setMinResolution(double res) would solve the problem, but the ArcGIS android app seems using different way. it zooms the minimum LOD if the next level of LOD has no image, so i wonder how to do this.
0 Kudos
AndyGup
Esri Regular Contributor
it zooms the minimum LOD if the next level of LOD has no image, so i wonder how to do this.


I think that's an internal workaround, and I'm not sure what they've done exactly. Maybe someone else on the forums has workaround code for Android?

What our team has done for the other APIs when an app is designed for a specific geographic region we define polygons and zoom levels for areas where we know there are null tiles. Then set a listener on the layer and when it met the right criteria (e.g. polygon extent is within the view port and min zoom level is true) we reset the zoom level. 

Also note, I've been told the upcoming release is intended to include null tile support.

-Andy
0 Kudos
ChristopherDonohue
Emerging Contributor
I'm having a similar issue. I try to replace the map layer with a different one and it doesnt show up on the MapView.

mapView.removeLayer(currentMapLayer);
currentMapLayer = new ArcGISLocalTiledLayer("file:///mnt/sdcard/"+mapFileName);
mapView.addLayer(currentMapLayer);
mapView.setExtent(currentMapLayer.getFullExtent());
0 Kudos
JessicaSena
Emerging Contributor
Hi,

I'm having the same problem. Finally, how did you solve it?

Thanks in advanced,
0 Kudos
GSauers
Frequent Contributor
I am also still looking for an answer to this issue, had anyone had any luck?

Thanks
0 Kudos
ColleenDixon
Emerging Contributor
Add me to the list of still needing an answer!

In our case, if we have a base map added and zoom down as far as we can go, then change base maps, we can't zoom down any further.  If we restart the app, we can zoom in correctly, in this case 3 or 4 more levels .

I see the Resolution is the problem, that we need to set this again after changing layers.  My problem is MapView has setMaxResolution and setMinResolution, but Layer only has getResolution, which looks like it's the current resolution.  (MapView.getResolution = Layer.getResolution).  I tried setScale, but MapView has setScale and Layer has getMinScale and getMaxScale.  I really need get Min/Max Resolution on the layer, or some other way to figure this out.
0 Kudos