android arcgis 绘制圆_《ArcGIS Runtime SDK for Android开发笔记》——(15)、要素绘制Drawtools3.0工具DEMO...

packagecom.gis_luq.drawtoolsdemo;importandroid.app.Activity;importandroid.content.Context;importandroid.os.Bundle;importandroid.widget.Button;importcom.esri.android.map.GraphicsLayer;importcom.esri.android.map.MapOnTouchListener;importcom.esri.android.map.MapView;importcom.esri.android.map.ags.ArcGISTiledMapServiceLayer;importcom.esri.core.map.Graphic;importcom.esri.core.table.TableException;importcom.gis_luq.lib.Draw.DrawEvent;importcom.gis_luq.lib.Draw.DrawEventListener;importcom.gis_luq.lib.Draw.DrawTool;importjava.io.FileNotFoundException;public class MainActivity extends Activity implementsDrawEventListener {privateContext context;private MapView mapView = null;private ArcGISTiledMapServiceLayer arcGISTiledMapServiceLayer = null;private GraphicsLayer graphicsLayer = null;private Graphic selectGraphic = null;privateDrawTool drawTool;public MapOnTouchListener mapDefaultOnTouchListener;//默认点击事件

public DrawEventListener drawEventListener;//要素绘制点击事件

@Overrideprotected voidonCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

context= this;this.mapView = (MapView)this.findViewById(R.id.map);//设置UI和代码绑定

String strMapUrl="http://map.geoq.cn/ArcGIS/rest/services/ChinaOnlineCommunity/MapServer";this.arcGISTiledMapServiceLayer = newArcGISTiledMapServiceLayer(strMapUrl);this.mapView.addLayer(arcGISTiledMapServiceLayer);

graphicsLayer= newGraphicsLayer();this.mapView.addLayer(graphicsLayer);//初始化DrawTool实例

this.drawTool = new DrawTool(this.mapView);//将本Activity设置为DrawTool实例的Listener

this.drawTool.addEventListener(this);//设置地图事件

mapDefaultOnTouchListener = new MapOnTouchListener(this.mapView.getContext(), this.mapView);

drawEventListener= this;

ToolsOnClickListener toolsOnClickListener= newToolsOnClickListener(context,drawTool,selectGraphic,mapView);

Button btnDrawPoint= (Button)this.findViewById(R.id.btnDrawPoint);

btnDrawPoint.setOnClickListener(toolsOnClickListener);

Button btnDrawPolyline= (Button)this.findViewById(R.id.btnDrawPolyline);

btnDrawPolyline.setOnClickListener(toolsOnClickListener);

Button btnDrawFreePolyline= (Button)this.findViewById(R.id.btnDrawFreePolyline);

btnDrawFreePolyline.setOnClickListener(toolsOnClickListener);

Button btnDrawPolygon= (Button)this.findViewById(R.id.btnDrawPolygon);

btnDrawPolygon.setOnClickListener(toolsOnClickListener);

Button btnDrawFreePolygon= (Button)this.findViewById(R.id.btnDrawFreePolygon);

btnDrawFreePolygon.setOnClickListener(toolsOnClickListener);

Button btnDrawCircle= (Button)this.findViewById(R.id.btnDrawCircle);

btnDrawCircle.setOnClickListener(toolsOnClickListener);

Button btnDrawEnvlope= (Button)this.findViewById(R.id.btnDrawEnvlope);

btnDrawEnvlope.setOnClickListener(toolsOnClickListener);

Button btnDrawEditor= (Button)this.findViewById(R.id.btnDrawSave);

btnDrawEditor.setOnClickListener(toolsOnClickListener);

Button btnDrawUndo= (Button)this.findViewById(R.id.btnDrawUndo);

btnDrawUndo.setOnClickListener(toolsOnClickListener);

Button btnDrawDeleteNode= (Button)this.findViewById(R.id.btnDrawDeleteNode);

btnDrawDeleteNode.setOnClickListener(toolsOnClickListener);

}

@Overridepublic void handleDrawEvent(DrawEvent event) throwsTableException, FileNotFoundException {//将画好的图形(已经实例化了Graphic),添加到drawLayer中并刷新显示

this.graphicsLayer.addGraphic(event.getDrawGraphic());//修改点击事件为默认

this.mapView.setOnTouchListener(mapDefaultOnTouchListener);

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值