Drawtool of ArcGIS for Android getting started Program

Source: Internet
Author: User
Tags polyline

ArcGIS for Android is a mobile development kit developed by ESRI Based on the Android platform. Like ArcGIS for iOS and ArcGIS for Windows Phone, ArcGIS for Android accesses the rest Services released by ArcGIS Server, including dynamic services, slicing services, element services, and other map services, query, identify, GP, and other spatial analysis services.

ArcGIS for Android provides good development materials, including api reference and sample. To facilitate development, ArcGIS plugin for eclipse is also provided to create a project based on ArcGIS for Android. As for how to configure the development environment, how to use ArcGIS for Android SDK to achieve the basic functions of MobileGIS, you can refer to the ox magic king for Android ArcGIS series of technical articles (OX magic king blog: http://blog.csdn.net/warrenwyf ).

After learning a little about ArcGIS for Android, I found that the response to the gesture event in development is a matter of time, so I wrote a get started program called drawtool. Drawtool is a tool class that can draw points, lines, rectangles, polygon, and circles. It is encapsulated in a simple way to meet General drawing requirements. Through this program, you can better understand how to handle various gesture events in ArcGIS for Android. The drawtoolactivity. Java in the program shows how to call drawtool.

Drawtoolactivity. Java code, source code: http://download.csdn.net/source/3552287

 

Drawtool2.0 in ArcGIS Android SDK 2.0:Http://blog.csdn.net/arcgis_mobile/article/details/8084763

 

Package COM. esrichina. android; import android. app. activity; import android. graphics. color; import android. OS. bundle; import android. view. menu; import android. view. menuinflater; import android. view. menuitem; import COM. ESRI. android. map. graphicslayer; import COM. ESRI. android. map. mapview; import COM. ESRI. core. symbol. markersymbol; import COM. ESRI. core. symbol. simplemarkersymbol; import COM. esrichina. android. ext. drawtool. drawevent; import COM. esrichina. android. ext. drawtool. draweventlistener; import COM. esrichina. android. ext. drawtool. drawtool; import COM. esrichina. demo. geocoding. r;/***** @ author ropp gispace@yeah.net ** to respond to the drawing event of drawtool, The draweventlistener interface */public class drawtoolactivity extends activity implements draweventlistener {private mapview; private graphicslayer drawlayer; private drawtool; private markersymbol; Public void oncreate (bundle savedinstancestate) {super. oncreate (savedinstancestate); setcontentview (R. layout. main); this. mapview = (mapview) This. findviewbyid (R. id. map); this. drawlayer = new graphicslayer (this. mapview. getcontext (); this. mapview. addlayer (this. drawlayer); // initialize the drawtool instance this. drawtool = new drawtool (this. mapview); // set this activity to the listener this of the drawtool instance. drawtool. addeventlistener (this); // you can set various symbol this when drawing a drawtool instance as needed. markersymbol = new simplemarkersymbol (color. red, 20, simplemarkersymbol. style. circle); // This. drawtool. setmarkersymbol (markersymbol);} @ override public Boolean oncreateoptionsmenu (menu) {menuinflater Inflater = This. getmenuinflater (); Inflater. inflate (R. menu. menu, menu); Return true ;}@ override public Boolean onoptionsitemselected (menuitem item) {Switch (item. getitemid () {case R. id. point: drawtool. activate (drawtool. point); break; case R. id. envelope: drawtool. activate (drawtool. envelope); break; case R. id. polygon: drawtool. activate (drawtool. polygon); break; case R. id. polyline: drawtool. activate (drawtool. polyline); break; case R. id. freehandpolygon: drawtool. activate (drawtool. freehand_polygon); break; case R. id. freehandpolyline: drawtool. activate (drawtool. freehand_polyline); break; case R. id. circle: drawtool. activate (drawtool. circle); break; case R. id. clear: This. drawlayer. clear (); this. drawlayer. postinvalidate (); this. drawtool. deactivate (); break;} return true;} // implement the public void handledrawevent (drawevent event) method defined in draweventlistener {// you can draw a picture (graphic has been instantiated ), add to drawlayer and refresh and display this. drawlayer. addgraphic (event. getdrawgraphic (); this. drawlayer. postinvalidate ();}}

As follows:

 

Related Article

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.