3
我想在Android應用程序的ArcGIS地圖上添加一個標記。但是,添加圖形圖層後,我的地圖不出現。我是Android應用程序編程新手,非常感謝任何幫助。我不確定我在這裏做錯了什麼。提前致謝。如何將標記添加到Android上的ArcGIS地圖?
這裏是我的代碼:
public class SuggestionsFragment extends Fragment {
MapView mMapView;
GraphicsLayer graphicsLayer = new GraphicsLayer();
Point point;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_suggestions,
container, false);
//Retrieve the map and initial extent from XML layout
mMapView = (MapView)rootView.findViewById(R.id.map);
//Create the layer
final Layer oneMapLayer = new ArcGISTiledMapServiceLayer("http://e1.onemap.sg/arcgis/rest/services/BASEMAP/MapServer");
mMapView.addLayer(graphicsLayer);
Point point = new Point(1.3799775, 103.84877200000005);
graphicsLayer.addGraphic(new Graphic(point,new SimpleMarkerSymbol(Color.RED,10,STYLE.CIRCLE)));
//Know when the map layer loaded
mMapView.setOnStatusChangedListener(new OnStatusChangedListener() {
private static final long serialVersionUID = 1L;
public void onStatusChanged(Object source, STATUS status) {
if (source == oneMapLayer && status == STATUS.LAYER_LOADED) {
mMapView.centerAt(1.3799775, 103.84877200000005, false);
mMapView.setScale(1500,false);
}
}
});
//Add dynamic layer to MapView
mMapView.addLayer(oneMapLayer);
return rootView;
}
@Override
public void onDestroy() {
super.onDestroy();
}
@Override
public void onPause() {
super.onPause();
mMapView.pause();
}
@Override
public void onResume() {
super.onResume();
mMapView.unpause();
}
}
如果地圖不出現,有因API密鑰。 – Abdellah 2014-10-09 07:35:02
回覆:@Abdellah,但地圖出現,如果我刪除 mMapView.addLayer(graphicsLayer); Point point = new Point(1.3799775,103.84877200000005); (新的圖形(指向,新的SimpleMarkerSymbol(Color.RED,10,STYLE.CIRCLE)));圖形圖層.addGraphic – Alxy 2014-10-09 07:37:39