I'm using ArcGIS for Android SDK 10.2.8 and trying to place a simple graphic based on current GPS coordinates obtained through Android's location services. I followed the basic guide here:
Add graphics and text—ArcGIS Runtime SDK for Android | ArcGIS for Developers
I am using ESRI's topo basemap. The map loads as expected and initially centers on the GPS coordinates provided. On pressing a provided button, the map should draw a SimpleMarkerSymbol at the coordinates and re-center the map on the coordinates, if the map has been moved. What actually happens when I press the button is the map will re-center on the coordinates but no graphic appears.
To do a little testing, I tried also displaying a toast with the graphic layer UID. It returns a number, leading me to believe the graphic layer is correctly created....but still no graphic appears on the map. Is there something I am missing in my code? My code for the button is below:
public void setPoint(View view) {
Button clickedButton = (Button) view;
if (clickedButton == findViewById(R.id.add_point)) {
mMapView = (MapView) findViewById(R.id.map);
SpatialReference webSR = SpatialReference.create(3857);
Point gps_mercator = GeometryEngine.project(latitude, longitude, webSR);
GraphicsLayer gl = new GraphicsLayer();
SimpleMarkerSymbol simpleMarker = new SimpleMarkerSymbol(Color.RED, 5, SimpleMarkerSymbol.STYLE.CIRCLE);
Graphic pointGraphic = new Graphic(gps_mercator, simpleMarker);
gl.addGraphic(pointGraphic);
mMapView.addLayer(gl);
mMapView.centerAt(latitude, longitude, true);
}
}