DrawTool2.0 for the ArcGIS for Android starter Program

Source: Internet
Author: User
Tags polyline

From: http://blog.csdn.net/arcgis_mobile/article/details/8084763

Gispace Blog "ArcGIS for Android Starter Program Drawtool" http://blog.csdn.net/gispace/article/details/6723459 in ArcGIS Android SDK 0.9 version of the implementation of drawing a variety of several graphics. The ArcGIS Android SDK is currently version 2.0 and is larger than the previous version, so porting the previous version to version 2.0. Source code : http://download.csdn.net/detail/arcgis_mobile/4659389

This program mainly explains how to handle the various events interacting with Mapview, to encapsulate the geometry drawing tool class Drawtool in the subscription publishing mode, using the following method:

[Java]View Plaincopy
  1. <span style="Font-family:courier new;font-size:18px;"  > Packagecn.com.esrichina.drawtool;
  2. Import android.app.Activity;
  3. Import Android.os.Bundle;
  4. Import Android.view.Menu;
  5. Import Android.view.MenuInflater;
  6. Import Android.view.MenuItem;
  7. Import Com.esri.android.map.GraphicsLayer;
  8. Import Com.esri.android.map.MapView;
  9. Import Com.esri.android.map.ags.ArcGISTiledMapServiceLayer;
  10. Public class Drawtoolactivity extends Activity implements Draweventlistener {
  11. private Mapview Mapview;
  12. private Graphicslayer Drawlayer;
  13. private Drawtool Drawtool;
  14. public void OnCreate (Bundle savedinstancestate) {
  15. super.oncreate (savedinstancestate);
  16. Setcontentview (R.layout.main);
  17. This.mapview = (mapview) This.findviewbyid (R.ID.MAP);
  18. //Add Basemap
  19. This.mapview
  20. . AddLayer (new Arcgistiledmapservicelayer (
  21. "Http://www.arcgisonline.cn/ArcGIS/rest/services/ChinaOnlineCommunity/MapServer"));
  22. //Draw geometry on Drawlayer
  23. This.drawlayer = new Graphicslayer ();
  24. This.mapView.addLayer (this.drawlayer);
  25. This.drawtool = new Drawtool (This.mapview);
  26. //This class implements the Daweventlistener interface
  27. This.drawTool.addEventListener (this);
  28. }
  29. Public Boolean oncreateoptionsmenu (Menu menu) {
  30. Menuinflater inflater = this.getmenuinflater ();
  31. Inflater.inflate (R.menu.menu, menu);
  32. return true;
  33. }
  34. @Override
  35. Public Boolean onoptionsitemselected (MenuItem item) {
  36. switch (Item.getitemid ()) {
  37. Case R.id.point:
  38. Drawtool.activate (Drawtool.point);
  39. Break ;
  40. Case R.id.envelope:
  41. Drawtool.activate (Drawtool.envelope);
  42. Break ;
  43. Case R.id.polygon:
  44. Drawtool.activate (Drawtool.polygon);
  45. Break ;
  46. Case R.id.polyline:
  47. Drawtool.activate (Drawtool.polyline);
  48. Break ;
  49. Case R.id.freehandpolygon:
  50. Drawtool.activate (Drawtool.freehand_polygon);
  51. Break ;
  52. Case R.id.freehandpolyline:
  53. Drawtool.activate (Drawtool.freehand_polyline);
  54. Break ;
  55. Case R.id.circle:
  56. Drawtool.activate (drawtool.circle);
  57. Break ;
  58. Case R.id.clear:
  59. This.drawLayer.removeAll ();
  60. this.drawTool.deactivate ();
  61. Break ;
  62. }
  63. return true;
  64. }
  65. //Implement the methods defined in Draweventlistener
  66. public void Handledrawevent (Drawevent event) {
  67. //will draw a graphic (already instantiated graphic), add to Drawlayer and refresh the display
  68. this.drawLayer.addGraphic (Event.getdrawgraphic ());
  69. }
  70. @Override
  71. protected void OnDestroy () {
  72. Super.ondestroy ();
  73. }
  74. }</span>


The Android emulator executes as follows:

DrawTool2.0 for the ArcGIS for Android starter Program

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.