Thursday 11 August 2011

ArcGIS Android - Persisting map state

ESRI documentation describes how to use onRetainNonConfigurationInstance for handling map rotation so that the scale, centre and layer state of the map is saved when onCreate is called (e.g http://help.arcgis.com/en/arcgismobile/10.0/apis/android/help/#/My_first_application/011900000005000000/) While this works fine I would like my application to remember map setting not only when the phone is rotated, but also when the user closes and re-enters the application. For this to work I save the map state values to the PreferenceManager like this when app is paused:
@Override
protected void onPause() {
        super.onPause();
        SharedPreferences settings = getSharedPreferences("mapPreference", 0);
        SharedPreferences.Editor ed = settings.edit();
        ed.putString("mapstate", map.retainState());
        ed.commit();
    }
 
And then retrieve the map settings in the onCreate method:
@Override
public void onCreate(Bundle savedInstanceState) {    	
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

// get the map settings
SharedPreferences settings = getSharedPreferences("mapPreference", 0);
         String mapState = settings.getString("mapstate", null);
         if (mapState != null){
        	map.restoreState(mapState);
         } 

Tuesday 9 August 2011

ArcGIS - Cascading WMS is a No-Go

So I wanted to add geographic information to the geological map. I have access to a long series of a nice WMS at http://www.kortforsyningen.dk/ which would be an excellent option. But alas, it is not possible with the ArcGIS server to publish a WMS based on a mxd-file that includes a WMS: http://support.esri.com/en/knowledgebase/techarticles/detail/35903.

This is pretty annoying - Cascading a WMS would be no problem if I had used MapServer. Well, now I am married to ESRI so I have to suffer the consequences...

Instead I found a georeferenced map image that I put on a transparent layer and add it on top of the geological map layer. Result is not as nice as it would have been if I could have used WMS from kortforsyningen but it is usable: