"German map Android SDK" video tutorial

Source: Internet
Author: User
Tags polyline

The first two days attended the Open class held in Beihang University, feeling very good. Completed the teacher's assignment, but also successfully got the Gold Developer certificate!!

Now to share with you how to quickly learn the "high-powered map Android SDK" development. One day bag will! Even the environment how to configure, all in the video has OH.

Basic knowledge

Android Navigation SDK is a product for online navigation, product features include path planning, simulation navigation, GPS positioning, custom navigation interface, access to navigation broadcast information. In addition, the navigation path calculation of the product is combined with real-time traffic information to provide users with more reasonable, accurate and humanized navigation services. The Android navigation SDK also supports walking route planning and navigation to make your trip smoother.

Development Documentation: http://lbs.amap.com/api/android-navi-sdk/summary/

Video Teaching

First, how to use the Android SDK for development 01-lbs open Platform introduction and environment construction

Click to view video tutorial:http://v.163.com/paike/V8H1BIE6U/VA4PLC1AI.html

Map display

Map Display Code

 Public classBasicmapactivityextendsActivity {PrivateMapview Mapview; PrivateAMap AMap; @Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate); //R needs to refer to the package import COM.AMAPV2.APIS.R;Setcontentview (r.layout.basicmap_activity); Mapview=(Mapview) Findviewbyid (R.ID.MAP); Mapview.oncreate (savedinstancestate);//have to writeinit (); }     /*** Initialize AMAP object*/    Private voidinit () {if(AMap = =NULL) {AMap=Mapview.getmap (); }    }     /*** method must be overridden*/@Overrideprotected voidOnresume () {Super. Onresume ();    Mapview.onresume (); }     /*** method must be overridden*/@Overrideprotected voidOnPause () {Super. OnPause ();    Mapview.onpause (); }         /*** method must be overridden*/@Overrideprotected voidonsaveinstancestate (Bundle outstate) {Super. Onsaveinstancestate (outstate);    Mapview.onsaveinstancestate (outstate); }     /*** method must be overridden*/@Overrideprotected voidOnDestroy () {Super. OnDestroy ();    Mapview.ondestroy (); }}

Ii. How to develop 02-marker tags using the android SDK

Click to view video tutorial: http://v.163.com/paike/V8H1BJ7FL/VA4PMIKG3.html

Mark

Tag Code

Private voidAddmarkerstomap () {//declares an animated frame collection. ArrayList giflist =NewArrayList (); //add each frame of the picture. Giflist.add (Bitmapdescriptorfactory.fromresource (R.drawable.navi_map_flash));    Giflist.add (Bitmapdescriptorfactory.fromresource (R.DRAWABLE.NAVI_MAP_FLASH1)); //set the far small near-large effect, 2.1.0 is new; sets the period for which the picture resource is refreshed once. Chengdu = Amap.addmarker (NewMarkeroptions (). Anchor (0.5f, 0.5f). Position (Constants.chengdu). Title ("Chengdu City"). Snippet ("Chengdu City: 30.679879, 104.064855"). Icons (giflist). Perspective (true). Draggable (true). Period (50)); Chengdu.showinfowindow ();//setting displays a infowinfow by defaultMarkeroption =Newmarkeroptions ();    Markeroption.position (Constants.xian); Markeroption.title ("Xian City"). Snippet ("Xian City: 34.341568, 108.940174"); Markeroption.perspective (true); Markeroption.draggable (true);    Markeroption.icon (Bitmapdescriptorfactory.fromresource (R.drawable.arrow)); XIAN=Amap.addmarker (markeroption); //add a marker with the system default iconDrawma

Iii. How to use the Android SDK for development 03-Map Overlay Add

Click to view video tutorial: http://v.163.com/paike/V8H1BJ7FL/VA4POFD2H.html

Line

Polyline Code

Private voidSetupmap () {Mcolorbar.setonseekbarchangelistener ( This); Malphabar.setonseekbarchangelistener ( This); Mwidthbar.setonseekbarchangelistener ( This); Amap.movecamera (Cameraupdatefactory.zoomto (4)); //draw a dashed trianglePolyline = Amap.addpolyline ((Newpolylineoptions ()). Add (Constants.shanghai, constants.beijing, Constants.chengdu). Widt H (). Setdottedline (true). Geodesic (true). Color (Color.argb (255, 1, 1, 1))); //drawing a geodetic curve from Urumqi to HarbinAmap.addpolyline ((Newpolylineoptions ()). Add (NewLATLNG (43.828, 87.621),NewLATLNG (45.808, 126.55). Geodesic (true). Color (color.red)); }    /*** polyline Response events for fill color, transparency, brush width*/@Override Public voidOnprogresschanged (SeekBar SeekBar,intProgress,BooleanFromuser) {        if(Polyline = =NULL)        {            return; }        if(SeekBar = =Mcolorbar) {Polyline.setcolor (Color.argb (Progress,1, 1, 1)); }        Else if(SeekBar = =Malphabar) {            float[] PREVHSV =New float[3];            COLOR.COLORTOHSV (Polyline.getcolor (), PREVHSV);        Polyline.setcolor (Color.hsvtocolor (Progress, PREVHSV)); }        Else if(SeekBar = =Mwidthbar)        {Polyline.setwidth (progress); }        }

Iv. How to use the Android SDK for development 04-search function

Click to view video tutorial: http://v.163.com/paike/V8H1BIE6U/VA748DN20.html

V. How to use the Android SDK for development 04-positioning

Positioning

Locating code

/*** AMapV2 Map shows the location of small blue dots*/ Public classMultylocationactivityextendsActivityImplementsLocationsource, Amaplocationlistener {PrivateAMap AMap; PrivateMapview Mapview; PrivateOnlocationchangedlistener Mlistener; PrivateLocationmanagerproxy Mamaplocationmanager; @Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate);        Setcontentview (r.layout.locationsource_activity); Mapview=(Mapview) Findviewbyid (R.ID.MAP);        Mapview.oncreate (savedinstancestate);    Init (); }     /*** Initialize AMAP object*/    Private voidinit () {if(AMap = =NULL) {AMap=Mapview.getmap ();        Setupmap (); }    }     Private voidSetupmap () {Map.setlocationsource ( This);//Setting up location monitoringAmap.getuisettings (). setmylocationbuttonenabled (true);//sets whether the default positioning button is displayedAmap.setmylocationenabled (true);//set to True to display the anchor layer and trigger positioning, false to hide the anchor layer and not trigger positioning, false by default//set positioning type to positioning mode: Positioning (amap.location_type_locate), following (Amap.location_type_map_follow)//The map is rotated (amap.location_type_map_rotate) three modes according to direction of orientationAmap.setmylocationtype (amap.location_type_locate); }     /*** This method needs to exist*/@Overrideprotected voidOnresume () {Super. Onresume ();    Mapview.onresume (); }     /*** This method needs to exist*/@Overrideprotected voidOnPause () {Super. OnPause ();        Mapview.onpause ();    Deactivate (); }     /*** This method needs to exist*/@Overrideprotected voidOnDestroy () {Super. OnDestroy ();    Mapview.ondestroy (); }     /*** This method has been deprecated*/@Override Public voidonlocationchanged (location location) {}/*** Callback function after successful positioning*/@Override Public voidonlocationchanged (amaplocation amaplocation) {if(Mlistener! =NULL&& amaplocation! =NULL) {            if(Amaplocation.getamapexception (). GetErrorCode () = = 0) {mlistener.onlocationchanged (amaplocation);//Display system small Blue dot            }        }    }     /*** Activate location*/@Override Public voidActivate (Onlocationchangedlistener listener) {Mlistener=Listener; if(Mamaplocationmanager = =NULL) {Mamaplocationmanager= Locationmanagerproxy.getinstance ( This); //This method initiates a location request every fixed time, in order to reduce power consumption or network traffic consumption,//Note Set the interval for the appropriate location time and call the Removeupdates () method at the appropriate time to cancel the location request//Call the Destroy () method at the appropriate life cycle after the positioning is complete//where if the interval is-1, the position is fixed only onceMamaplocationmanager.requestlocationdata (Locationproviderproxy.amapnetwork,60*1000, 10, This); }    }      /*** Stop positioning*/@Override Public voidDeactivate () {Mlistener=NULL; if(Mamaplocationmanager! =NULL) {mamaplocationmanager.removeupdates ( This);        Mamaplocationmanager.destroy (); } Mamaplocationmanager=NULL; }}

After-school exercises

After the completion of the class exercises, you can get the Gold developer certificate! The teacher assigned the homework to say this:

Topic

Do a simple recording of GPs motion trajectory of small software.

function points
1. Record GPS location information in real time, draw track on map. (positioning, polyline overlay)
2. If you stay longer than 30 seconds at a certain location, you also need to use the marker tag. (Mark Marker)

How to submit
1) Send mail to <[email protected]>
2) need to submit a ZIP package containing apk and source program

Participate in the discussion

German certified developer QQ Group No. 253476702

"German map Android SDK" video tutorial

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.