ArcGis中GraphicsLayer图层图层用来添加标记画线等等,例如点击定位后,在地图上标出当前的位置同时以当前位置作为地图中心可以用如下代码:
Drawable drawable = getResources().getDrawable(R.drawable.arrow); PictureMarkerSymbol picSymbol = new PictureMarkerSymbol(drawable); Point loc= new Point(1.4191862462692365E7,5183685.4328131145); //获取的定位 Graphic g = new Graphic(loc, picSymbol); graphicsLayer.addGraphic(g); map.centerAt(loc, true);
要想实时更新的话,不要graphicsLayer.removeAll();然后再重新添加图层,那样很卡。用如下代码:
Drawable drawable = getResources().getDrawable(R.drawable.arrow); PictureMarkerSymbol picSymbol = new PictureMarkerSymbol(drawable); Point loc= new Point(1.4191862462692365E7,5183685.4328131145); //获取的定位 Graphic g = new Graphic(loc, picSymbol); graphicsLayer.updateGraphic(1, g); map.centerAt(loc, true);
id为添加的元素的id。
时间: 2024-09-28 16:19:56