stephen_quan

Is Reprojection on the fly supported on the Map control?

Discussion created by stephen_quan on Jan 18, 2012
Latest reply on Feb 20, 2012 by stephen_quan
Hi, I've just been trying to get geographic coordinates to display on the Hello World Map sample with projection on the fly. I prefer to keep the data in geographic coordinates and not code reprojection if the map control can be coerce to do it for me.

<CODE>
public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.main);

  // Retrieve the map and initial extent from XML layout
  map = (MapView)findViewById(R.id.map);
  map.addLayer(new ArcGISDynamicMapServiceLayer("" +
    "http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"));

  // Add a BLUE DIAMOND point near San Bernadino using Web Mercator coordinates - this works!
  GraphicsLayer merclayer = new GraphicsLayer();
  merclayer.addGraphic(
   new Graphic(
    new Point(-13051775.04, 4066103.08),
    new SimpleMarkerSymbol(Color.BLUE, 15, STYLE.DIAMOND))
   );
  map.addLayer(merclayer);
 
  // Add a RED DIAMOND point in Australia using WGS84 geographic coordinates - fail (point is shown at equator)
  GraphicsLayer wgslayer = new GraphicsLayer(SpatialReference.create(4326), null);
  wgslayer.addGraphic(
    new Graphic(
     new Point(144, -37),
     new SimpleMarkerSymbol(Color.RED, 15, STYLE.DIAMOND))
    );
  map.addLayer(wgslayer);

  //Retrieve the non-configuration instance data that was previously returned.
  Object init = getLastNonConfigurationInstance();
   if (init != null) {
   map.restoreState((String) init);
  }
}
</CODE>

Outcomes