Hello every one. I'm new to ArcGIS and I want to add path(polyline) on the map after giving coordinates where to draw. I follow the guide Display Information -> add graphics and text. But not displaying the path and even not occur any error.
MapView mMapView = null;
// The basemap switching menu items.
MenuItem mStreetsMenuItem = null;
MenuItem mTopoMenuItem = null;
MenuItem mGrayMenuItem = null;
MenuItem mOceansMenuItem = null;
// Create MapOptions for each type of basemap.
final MapOptions mTopoBasemap = new MapOptions(MapType.TOPO);
final MapOptions mStreetsBasemap = new MapOptions(MapType.STREETS);
final MapOptions mGrayBasemap = new MapOptions(MapType.GRAY);
final MapOptions mOceansBasemap = new MapOptions(MapType.OCEANS);
ArcGISTiledMapServiceLayer tms = new ArcGISTiledMapServiceLayer("http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer");
// The current map extent, use to set the extent of the map after switching basemaps.
Polygon mCurrentMapExtent = null;
GraphicsLayer mLocationLayer;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_gis2);
// Retrieve the map and initial extent from XML layout
mMapView = (MapView) findViewById(R.id.map);
mLocationLayer = new GraphicsLayer();
mMapView.addLayer(tms);
// Set the Esri logo to be visible, and enable map to wrap around date line.
mMapView.setEsriLogoVisible(false);
mMapView.enableWrapAround(true);
SimpleLineSymbol lineSymbol = new SimpleLineSymbol(Color.GREEN, 3, SimpleLineSymbol.STYLE.DASH);
Polyline lineGeometry = new Polyline();
lineGeometry.startPath(-302557, 7570663);
lineGeometry.lineTo(-302959, 7570868);
lineGeometry.lineTo(-303042, 7571220);
lineGeometry.lineTo(-302700, 7571803);
lineGeometry.lineTo(-304043, 7576654);
lineGeometry.lineTo(-300544, 7585289);
lineGeometry.lineTo(-294365, 7592435);
lineGeometry.lineTo(-290122, 7594445);
lineGeometry.lineTo(-285283, 7595488);
Graphic lineGraphic = new Graphic(lineGeometry, lineSymbol);
mLocationLayer.addGraphic(lineGraphic);
// Set a listener for map status changes; this will be called when switching basemaps.
mMapView.setOnStatusChangedListener(new OnStatusChangedListener() {
private static final long serialVersionUID = 1L;
@Override
public void onStatusChanged(Object source, STATUS status) {
// Set the map extent once the map has been initialized, and the basemap is added
// or changed; this will be indicated by the layer initialization of the basemap layer. As there is only
// a single layer, there is no need to check the source object.
if ((source == mMapView) && (status == STATUS.INITIALIZED)) {
boolean mIsMapLoaded = true;
}
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items from the Menu XML to the action bar, if present.
getMenuInflater().inflate(R.menu.menu_gis2, menu);
// Get the basemap switching menu items.
mStreetsMenuItem = menu.getItem(0);
mTopoMenuItem = menu.getItem(1);
mGrayMenuItem = menu.getItem(2);
mOceansMenuItem = menu.getItem(3);
// Also set the topo basemap menu item to be checked, as this is the default.
mTopoMenuItem.setChecked(true);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Save the current extent of the map before changing the map.
// mCurrentMapExtent = mMapView.getExtent();
// Handle menu item selection.
switch (item.getItemId()) {
case R.id.World_Street_Map:
mMapView.setMapOptions(mStreetsBasemap);
mStreetsMenuItem.setChecked(true);
return true;
case R.id.World_Topo:
mMapView.setMapOptions(mTopoBasemap);
mTopoMenuItem.setChecked(true);
return true;
case R.id.Gray:
mMapView.setMapOptions(mGrayBasemap);
mGrayMenuItem.setChecked(true);
return true;
case R.id.Ocean_Basemap:
mMapView.setMapOptions(mOceansBasemap);
mOceansMenuItem.setChecked(true);
return true;
default:
return super.onOptionsItemSelected(item);
}
}
@Override
protected void onPause() {
super.onPause();
mMapView.pause();
}
@Override
protected void onResume() {
super.onResume();
mMapView.unpause();
}
Please help me on this. Thank you