GPS track recorded on ArcGIS Android chart

Source: Internet
Author: User

Record GPS tracks on ArcGIS Android map

 Public classMainactivityextendsActivity {Mapview mmapview; Locationdisplaymanager Ldisplaymanager=NULL;    Graphicslayer Gpsgraphicslayer;    Polyline Mpolyline; intPointcount = 0; @Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate);        Setcontentview (R.layout.activity_main); //After the content of this activity is set//The map can accessed from the layoutMmapview =(Mapview) Findviewbyid (R.ID.MAP); Arcgistiledmapservicelayer Tile=NewArcgistiledmapservicelayer ("Http://map.geoq.cn/ArcGIS/rest/services/ChinaOnlineCommunity_Mobile/MapServer");        Mmapview.addlayer (tile); Gpsgraphicslayer=NewGraphicslayer ();        Mmapview.addlayer (Gpsgraphicslayer); Mpolyline=NewPolyline (); Mmapview.setonstatuschangedlistener (NewOnstatuschangedlistener () {@Override Public voidonstatuschanged (Object source, status status) {if(Source = = Mmapview && Status = =STATUS. INITIALIZED) {Ldisplaymanager= Mmapview.getlocationdisplaymanager ();//Get LocationdisplaymanagerLdisplaymanager.setautopanmode (LocationDisplayManager.AutoPanMode.OFF); Ldisplaymanager.setshowlocation (false);//does not show current position, coordinate system inconsistent coordinate offset criticalLdisplaymanager.setshowpings (false); Ldisplaymanager.setaccuracycircleon (false); Ldisplaymanager.setallownetworklocation (true); Ldisplaymanager.setlocationlistener (NewLocationlistener () {@Override Public voidonlocationchanged (Location loc) {//Mars coordinate conversion                            Double[] GCJ =COORDINATECONVERT.WGS2GCJ (Loc.getlatitude (), Loc.getlongitude ()); Point Wgspoint=NewPoint (Gcj[1], gcj[0]); Point P=(point) Geometryengine.project (Wgspoint, Spatialreference.create (spatialreference.                            WKID_WGS84), mmapview.getspatialreference ()); Simplemarkersymbol Ptsym=NewSimplemarkersymbol (Color.Blue, 15, SimpleMarkerSymbol.STYLE.CIRCLE); Graphic Graphic=NewGraphic (p, Ptsym,NULL); if(Pointcount = = 0) {Mpolyline.startpath (P.getx (), p.gety ()); Mmapview.zoomto (P,17); } Else{Mpolyline.lineto (P.getx (), p.gety ());//Dot Draw lineMmapview.centerat (P,true);                            } gpsgraphicslayer.removeall (); Simplelinesymbol Linesym=NewSimplelinesymbol (Color.Red, 10); Graphic g=NewGraphic (Mpolyline, Linesym);                            Gpsgraphicslayer.addgraphic (g); Pointcount++;                        Gpsgraphicslayer.addgraphic (graphic); } @Override Public voidonproviderdisabled (String arg0) {} @Override 
     Public voidonproviderenabled (String arg0) {} @Override  Public voidOnstatuschanged (String arg0,intarg1, Bundle arg2)  {                        }                    }); //ActionListenerLdisplaymanager.start ();    }            }        }); }}

GPS track recorded on ArcGIS Android chart

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.