Select to view content in your preferred language

How do you change the extent on Helloworld?

741
3
04-14-2012 05:38 PM
JohnAllen
Deactivated User
How do you change the (initExtent = ) on the Helloworld application from ESRI?

I just want my app to open to a different location other than San Diego.

The Helloworld app's extent code looks like this:
initExtent = "-1.3296373526814876E7 3930962.41823043 -1.2807176545789773E7 4201243.7502468005">

What projection or coordinate system is that?

Need some guidance.
0 Kudos
3 Replies
SimonKlein
Regular Contributor
You could change the initExtent in the xml layout file to the one you like.
The numbers should be an Envelope I guess.

You could navigate and zoom to the location and zoomlevel you want and add an singletab listener to the map.
So when you are at the location you want print the mapView.getExtent in the onsingletab method. The coordinates of this polygon you then could set as your initial extent in the xml.
0 Kudos
JohnAllen
Deactivated User
I figured it out.

ESRI's World Street Map - map service is in Web Mercator.

I published my own map service with some point data located on the area i needed to be zoomed into, and made sure the map layer coordinate system in ArcMap was set to Web Mercator (Auxillery) then published it as a map service

I changed the Hello world code to look like this:

JAVA CODE:
________________
package com.dhec.MPOS;

import com.esri.android.map.MapView;
import com.esri.android.map.ags.ArcGISDynamicMapServiceLayer;
import com.esri.android.map.ags.ArcGISTiledMapServiceLayer;
import android.app.Activity;
import android.os.Bundle;

public class Mapscreen extends Activity {
MapView map = null;

/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.mapscreen);

  // Retrieve the map and initial extent from XML layout
  map = (MapView)findViewById(R.id.map);
  // Add dynamic layer to MapView
  map.addLayer(new ArcGISTiledMapServiceLayer("" +
  "http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"));
  map.addLayer(new ArcGISDynamicMapServiceLayer("" +
     "http://<myserver>/ArcGIS/rest/services/Mobile/TESTJohn/MapServer"));

}

protected void onPause() {
  super.onPause();
  map.pause();
}

protected void onResume() {
  super.onResume();
  map.unpause();
}
}
_______

For the initExtent = ""

I used the initial extent from the rest service from my map service i published.
0 Kudos
JohnAllen
Deactivated User
Note: In the above code I removed my server name and put <my server>.
If you copy and paste, make sure you actually put your server.
0 Kudos