zoukankan      html  css  js  c++  java
  • ArcGIS for Android入门程序之DrawTool2.0

    来自:http://blog.csdn.net/arcgis_mobile/article/details/8084763

    GISpace博客《ArcGIS for Android入门程序之DrawTool》http://blog.csdn.net/gispace/article/details/6723459 在ArcGIS Android SDK 0.9版本实现绘制各种几个图形。ArcGIS Android SDK目前版本为2.0,较之前版本变化较大,故将之前版本移植到2.0版本下。源代码下载地址http://download.csdn.net/detail/arcgis_mobile/4659389

    该程序主要说明如何处理与MapView交互的各种事件,以订阅发布模式封装几何图形绘制工具类DrawTool,使用方法如下:

    [java] view plaincopy
     
    1. <span style="font-family:Courier New;font-size:18px;">package cn.com.esrichina.drawtool;  
    2.   
    3. import android.app.Activity;  
    4. import android.os.Bundle;  
    5. import android.view.Menu;  
    6. import android.view.MenuInflater;  
    7. import android.view.MenuItem;  
    8.   
    9. import com.esri.android.map.GraphicsLayer;  
    10. import com.esri.android.map.MapView;  
    11. import com.esri.android.map.ags.ArcGISTiledMapServiceLayer;  
    12.   
    13. public class DrawToolActivity extends Activity implements DrawEventListener {  
    14.   
    15.     private MapView mapView;  
    16.     private GraphicsLayer drawLayer;  
    17.     private DrawTool drawTool;  
    18.   
    19.     public void onCreate(Bundle savedInstanceState) {  
    20.         super.onCreate(savedInstanceState);  
    21.         setContentView(R.layout.main);  
    22.   
    23.         this.mapView = (MapView) this.findViewById(R.id.map);  
    24.         // 添加底图  
    25.         this.mapView  
    26.                 .addLayer(new ArcGISTiledMapServiceLayer(  
    27.                         "http://www.arcgisonline.cn/ArcGIS/rest/services/ChinaOnlineCommunity/MapServer"));  
    28.         // 在drawLayer上绘制几何图形  
    29.         this.drawLayer = new GraphicsLayer();  
    30.         this.mapView.addLayer(this.drawLayer);  
    31.         this.drawTool = new DrawTool(this.mapView);  
    32.         // 此类实现DawEventListener接口  
    33.         this.drawTool.addEventListener(this);  
    34.     }  
    35.   
    36.     public boolean onCreateOptionsMenu(Menu menu) {  
    37.         MenuInflater inflater = this.getMenuInflater();  
    38.         inflater.inflate(R.menu.menu, menu);  
    39.         return true;  
    40.     }  
    41.   
    42.     @Override  
    43.     public boolean onOptionsItemSelected(MenuItem item) {  
    44.         switch (item.getItemId()) {  
    45.         case R.id.point:  
    46.             drawTool.activate(DrawTool.POINT);  
    47.             break;  
    48.         case R.id.envelope:  
    49.             drawTool.activate(DrawTool.ENVELOPE);  
    50.             break;  
    51.         case R.id.polygon:  
    52.             drawTool.activate(DrawTool.POLYGON);  
    53.             break;  
    54.         case R.id.polyline:  
    55.             drawTool.activate(DrawTool.POLYLINE);  
    56.             break;  
    57.         case R.id.freehandpolygon:  
    58.             drawTool.activate(DrawTool.FREEHAND_POLYGON);  
    59.             break;  
    60.         case R.id.freehandpolyline:  
    61.             drawTool.activate(DrawTool.FREEHAND_POLYLINE);  
    62.             break;  
    63.         case R.id.circle:  
    64.             drawTool.activate(DrawTool.CIRCLE);  
    65.             break;  
    66.         case R.id.clear:  
    67.             this.drawLayer.removeAll();  
    68.             this.drawTool.deactivate();  
    69.             break;  
    70.         }  
    71.         return true;  
    72.     }  
    73.   
    74.     // 实现DrawEventListener中定义的方法  
    75.     public void handleDrawEvent(DrawEvent event) {  
    76.         // 将画好的图形(已经实例化了Graphic),添加到drawLayer中并刷新显示  
    77.         this.drawLayer.addGraphic(event.getDrawGraphic());  
    78.     }  
    79.   
    80.     @Override  
    81.     protected void onDestroy() {  
    82.         super.onDestroy();  
    83.     }  
    84. }</span>  


    在Android模拟器执行效果图如下:

  • 相关阅读:
    161028、Nginx负载均衡实现tomcat集群方案简要小结
    161027、Java 中的 12 大要素及其他因素
    161026、更快速将你的页面展示给用户[前端优化篇]
    161025、java提高篇之关键字static
    161024、并发控制中的乐观锁与悲观锁
    161021、spring异步调用,完美解决!
    161020、web调试工具fiddler介绍及使用
    RuntimeError: cryptography requires setuptools 18.5 or newer, please upgrade to a newer version of setuptool
    PyCharm IDE环境下,执行unittest不生成测试报告问题解决
    (转)selenium使用Xpath+CSS+JavaScript+jQuery的定位方法(治疗selenium各种定位不到,点击不了的并发症)
  • 原文地址:https://www.cnblogs.com/gisoracle/p/4355746.html
Copyright © 2011-2022 走看看