package com.esri.android.test; import android.app.Activity; import android.graphics.Color; import android.os.Bundle; import com.esri.android.map.GraphicsLayer; import com.esri.android.map.MapView; import com.esri.android.map.ags.ArcGISDynamicMapServiceLayer; import com.esri.core.geometry.GeometryEngine; import com.esri.core.geometry.Point; import com.esri.core.geometry.SpatialReference; import com.esri.core.map.Graphic; import com.esri.core.symbol.SimpleMarkerSymbol; import com.esri.core.symbol.SimpleMarkerSymbol.STYLE; public class HelloWorldMapActivity extends Activity { MapView map = null; SpatialReference webMercator = SpatialReference.create(102100); SpatialReference wgs84 = SpatialReference.create(4326); 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")); */ GraphicsLayer graphicsLayer = new GraphicsLayer(); Point redlands1 = (Point) GeometryEngine.project(new Point(-117.1990, 34.05564), wgs84, webMercator); Point redlands2 = (Point) GeometryEngine.project(new Point(-117.1922, 34.05797), wgs84, webMercator); graphicsLayer.addGraphic(new Graphic(redlands1, new SimpleMarkerSymbol(Color.GREEN, 15, STYLE.CIRCLE))); graphicsLayer.addGraphic(new Graphic(redlands2, new SimpleMarkerSymbol(Color.RED, 15, STYLE.CIRCLE))); map.addLayer(graphicsLayer); Object init = getLastNonConfigurationInstance(); if (init != null) { map.restoreState((String) init); } } protected void onPause() { super.onPause(); map.pause(); } protected void onResume() { super.onResume(); map.unpause(); } }
Solved! Go to Solution.
GraphicsLayer graphicsLayer = new GraphicsLayer(webMercator, null);
GraphicsLayer graphicsLayer = new GraphicsLayer(webMercator, null);