这是我的代码:
public class SuggestionsFragment extends Fragment { MapVIEw mMapVIEw; Graphicslayer graphicslayer = new Graphicslayer(); Point point;@OverrIDepublic 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;}@OverrIDepublic voID onDestroy() { super.onDestroy();}@OverrIDepublic voID onPause() { super.onPause(); mMapVIEw.pause();}@OverrIDepublic voID onResume() { super.onResume(); mMapVIEw.unpause();}}解决方法 解决方案:
public class SuggestionsFragment2 extends Fragment {MapVIEw mMapVIEw;Graphicslayer graphicslayer = new Graphicslayer();Point point;@OverrIDepublic 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;}@OverrIDepublic voID onDestroy() { super.onDestroy();}@OverrIDepublic voID onPause() { super.onPause(); mMapVIEw.pause();}@OverrIDepublic voID onResume() { super.onResume(); mMapVIEw.unpause();}总结
以上是内存溢出为你收集整理的如何在android上的ArcGIS地图中添加标记?全部内容,希望文章能够帮你解决如何在android上的ArcGIS地图中添加标记?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)