Select to view content in your preferred language

Cannot make GraphicsLayer the first layer in MapView

2353
1
Jump to solution
02-20-2012 08:01 PM
StephenQuan
Deactivated User
I got the Hello World Map sample working with a GraphicsLayer containing two points (two points on the ESRI Redlands campus). When I run the sample with the World_Street_Map ArcGIS Online layer as the first layer in my MapView it all works fine. However, when I remove the ArcGIS Online layer the GraphicsLayer and its points are no longer shown. Instead, I get a blank empty white screen. I just simply want a map that has the GraphicsLayer, any advice on how to do that?

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();  } }
0 Kudos
1 Solution

Accepted Solutions
StephenQuan
Deactivated User
I found the solution by changing how I instantiate the GraphicsLayer to use the other constructor:

GraphicsLayer graphicsLayer = new GraphicsLayer(webMercator, null);

View solution in original post

0 Kudos
1 Reply
StephenQuan
Deactivated User
I found the solution by changing how I instantiate the GraphicsLayer to use the other constructor:

GraphicsLayer graphicsLayer = new GraphicsLayer(webMercator, null);
0 Kudos