我正在尝试在
Android应用程序的ArcGIS地图上添加标记.但是,添加图形图层后,我的地图不会出现.我是Android应用程序编程的新手,非常感谢任何帮助.我不确定我在这里做错了什么.提前致谢.
这是我的代码:
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(); } }
解决方法
解决方案:
public class SuggestionsFragment2 extends Fragment { MapView mMapView; Graphicslayer graphicslayer = new Graphicslayer(); Point point; @Override public View onCreateView(LayoutInflater inflater,Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_suggestions2,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"); //KNow when the map layer loaded mMapView.setonStatusChangedListener(new OnStatusChangedListener() { private static final long serialVersionUID = 1L; public void onStatusChanged(Object source,false); mMapView.addLayer(graphicslayer); Point point = GeometryEngine.project(x,y,mMapView.getSpatialReference()); graphicslayer.addGraphic(new Graphic(point,new SimpleMarkerSymbol(Color.RED,STYLE.CIRCLE))); } } }); //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(); }
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。