Use Swift in the Swift Foundation-the high-gold map Practice (i) to use the Gao de map, where Android practice is used to include positioning, moving map animations, getting network data, marker tags and clicks, Infowindow custom interfaces and clicks, and click on the no marker map above to hide Infowindow and other functions. Look directly at the code
Package Com.carmap.ui;import Android.graphics.color;import Android.location.location;import android.os.Bundle; Import Android.util.log;import Android.view.view;import Android.view.view.onclicklistener;import Android.view.animation.animation;import Android.view.animation.animation.animationlistener;import Android.view.animation.animationutils;import Android.widget.imageview;import com.amap.api.location.AMapLocation; Import Com.amap.api.location.amaplocationlistener;import Com.amap.api.location.locationmanagerproxy;import Com.amap.api.location.locationproviderproxy;import Com.amap.api.maps.amap;import Com.amap.api.maps.amap.infowindowadapter;import Com.amap.api.maps.amap.oncamerachangelistener;import Com.amap.api.maps.amap.oninfowindowclicklistener;import Com.amap.api.maps.amap.onmapclicklistener;import Com.amap.api.maps.amap.onmaploadedlistener;import Com.amap.api.maps.amap.onmarkerclicklistener;import Com.amap.api.maps.cameraupdatefactory;import Com.amap.api.maps.locationsource;import CoM.amap.api.maps.mapview;import Com.amap.api.maps.uisettings;import Com.amap.api.maps.model.bitmapdescriptorfactory;import Com.amap.api.maps.model.cameraposition;import Com.amap.api.maps.model.latlng;import Com.amap.api.maps.model.marker;import Com.amap.api.maps.model.markeroptions;import Com.amap.api.maps.model.mylocationstyle;import Com.carmap.R;import com.carmap.ui.base.baseactivity;/** * * @author Jwzhangjie * */public class Mapactivity extends Baseactivity implements A Maplocationlistener,locationsource, Onmarkerclicklistener, Oninfowindowclicklistener,infowindowadapter, Onmaploadedlistener, Oncamerachangelistener,animationlistener, Onclicklistener, Onmapclicklistener {private MapView Mapview;private AMap amap;private locationmanagerproxy amapmanager;private onlocationchangedlistener mListener; Private uisettings muisettings;private amaplocation alocation;private Animation centermarker;private ImageView Centerimageview;private Marker currentmarker;private Boolean isFirst = True;privAte ImageView locate; @Overrideprotected void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate) ; Setcontentview (r.layout.activity_map); Mapview = (Mapview) Findviewbyid (R.id.mapview); Mapview.oncreate ( savedinstancestate);//This method must be rewritten centermarker = Animationutils.loadanimation (this,r.anim.center_map_bounds); Centerimageview = (ImageView) Findviewbyid (r.id.centermarkerimg); locate = (ImageView) Findviewbyid (r.id.locate); Initmap ();} /** * Initialize AMap object */private void Initmap () {if (AMap = = null) {AMap = Mapview.getmap (); muisettings = Amap.getuisettings ();} Custom system positioning small blue dot mylocationstyle mylocationstyle = new Mylocationstyle (); Mylocationstyle.mylocationicon ( Bitmapdescriptorfactory.fromresource (r.drawable.transdrawable));//Set the small blue dot icon Mylocationstyle.strokecolor ( Color.argb (0, 0, 0, 0));//Set the border color of the Circle Mylocationstyle.radiusfillcolor (Color.argb (0, 0, 0, 0));// Set the fill color of the Circle Mylocationstyle.strokewidth (0f);//Set the border thickness of the circle Amap.setmylocationstyle (Mylocationstyle); Amap.setmylocationrotateangle (AMAP);Setlocationsource (this);//Set Location monitoring muisettings.setmylocationbuttonenabled (false); Whether to display the default positioning button amap.setmylocationenabled (true);//Whether it can trigger positioning and display the positioning layer Amap.setmylocationtype (amap.location_type_locate); Muisettings.settiltgesturesenabled (false);//Set whether the map can be tilted muisettings.setscalecontrolsenabled (true);// Sets whether the default scale of the map displays muisettings.setzoomcontrolsenabled (false); Initmaplistener ();} private void Initmaplistener () {Amap.setonmaploadedlistener (this), Amap.setoncamerachangelistener (this); Amap.setonmarkerclicklistener (This), Amap.setoninfowindowclicklistener (This), Amap.setinfowindowadapter (this);// Set Custom Infowindow style Amap.setonmapclicklistener (this); Centermarker.setanimationlistener (this); Locate.setonclicklistener (this);} /** * method must be rewritten */@Overrideprotected void Onresume () {super.onresume (); Mapview.onresume ();} /** * method must be rewritten */@Overrideprotected void OnPause () {super.onpause (); Mapview.onpause ();} /** * method must be rewritten */@Overrideprotected void onsaveinstancestate (Bundle outstate) {super.onsaveinstancestate (outstate); Mapview.onSaveinstancestate (outstate);} /** * method must be rewritten */@Overrideprotected void OnDestroy () {Super.ondestroy (); Mapview.ondestroy ();} @Overridepublic void onlocationchanged (location location) {} @Overridepublic void onstatuschanged (String provider, int Status, Bundle extras) {} @Overridepublic void onproviderenabled (String provider) {} @Overridepublic void Onproviderdisabled (String provider) {} @Overridepublic void onlocationchanged (Amaplocation alocation) {if (alocation! = NULL) {this.alocation = Alocation;if (Mlistener! = null) mlistener.onlocationchanged (alocation);//display system small blue dot if (IsFirst) { IsFirst = False;amap.movecamera (cameraupdatefactory.changelatlng (New Latlng (Alocation.getlatitude (), Alocation.getlongitude ()))); Cameraupdatefactory.zoomto (16); Markeroptions markeroption = new Markeroptions (); Markeroption.position (New Latlng (Alocation.getlatitude (), Alocation.getlongitude ()); Markeroption.title ("Shanghai") Snippet ("Shanghai: 34.341568, 108.940174"); markeroption.draggable (true); Marker Marker = Amap.addmarker (markeroption); Marker.setobject ("11");//This can store user data}}} @SuppressWarnings ("deprecation") @Overridepublic void Activate ( Onlocationchangedlistener listener) {Mlistener = listener;if (Amapmanager = = null) {Amapmanager = Locationmanagerproxy.getinstance (this);/* * 1.0. Version 2 new method, set true to indicate that the hybrid location contains GPS positioning, false for pure network positioning, the default is true *///location API positioning using GPS and network hybrid positioning method, the shortest time is 2000 milliseconds amapmanager.requestlocationupdates (Locationproviderproxy.amapnetwork, 2000, 10, this);}} /** * Stop positioning */@Overridepublic void deactivate () {Mlistener = Null;if (Amapmanager! = null) {amapmanager.removeupdates (this) ; Amapmanager.destory ();} Amapmanager = null;} @Overridepublic boolean Onmarkerclick (Marker Marker) {currentmarker = Marker; LOG.E ("Marker", marker.getobject () + "marker:" + marker.getposition (). latitude+ ":" +marker); return false;} @Overridepublic View getinfocontents (Marker Marker) {log.e ("Marker", Marker.getobject () + "getinfocontents:" + Marker.getid ()); return null;} @Overridepublic View Getinfowindow (Marker Marker) {log.e ("Marker", MarkEr.getobject () + "Getinfowindow:" + Marker.getid ()); View Infowindow = Getlayoutinflater (). Inflate (R.layout.custom_info_window, null); render (marker, Infowindow); return Infowindow;} @Overridepublic void Oninfowindowclick (Marker Marker) {log.e ("Marker", Marker.getobject () + "Oninfowindowclick:" + Marker.getid ());} @Overridepublic void onmaploaded () {centerimageview.startanimation (centermarker); Cameraupdatefactory.zoomto (16); LOG.E ("Load", "onmaploaded");} @Overridepublic void Oncamerachange (Cameraposition arg0) {} @Overridepublic void Oncamerachangefinish (cameraposition arg0) {centerimageview.startanimation (centermarker); LOG.E ("Load", "oncamerachangefinish+ Get Background Data");} @Overridepublic void Onanimationstart (Animation Animation) {Centerimageview.setimageresource (r.drawable.green_pin_ Lift);} @Overridepublic void Onanimationrepeat (Animation Animation) {} @Overridepublic void Onanimationend (Animation Animation ) {Centerimageview.setimageresource (r.drawable.green_pin);} @Overridepublic void OnClick (View V{int id = v.getid (); switch (ID) {case r.id.locate:log.e ("Load", "locate"); Amap.animatecamera ( CAMERAUPDATEFACTORY.CHANGELATLNG (New Latlng (Alocation.getlatitude (), Alocation.getlongitude ())); Break;default: Break;}} /** * Custom Infowinfow window, dynamically modify the contents of */public void Render (Marker Marker, view view) {}//Click on the non-Marker area, The Infowindow that will be displayed hides @overridepublic void Onmapclick (latlng latlng) {if (Currentmarker! = null) { Currentmarker.hideinfowindow ();}}}
Package Com.carmap.ui.base;import Android.content.intent;import android.support.v4.app.fragmentactivity;/** * * @author Jwzhangjie * */public class Baseactivity extends Fragmentactivity{public Intent startintent;public void Startcha Nge (Class name) {startintent = new Intent (); Startintent.setclass (this, name); StartActivity (startintent);} public void Startchange (Class name, Boolean close) {Startchange (name); if (close) finish ();}}
The bounce animation for a picture in the center of the map is set as follows, Bounce_interpolator is a bouncing animation, and the bounce and stop are two different pictures, so the Onanimationstart and Onanimationend are set separately.
<?xml version= "1.0" encoding= "Utf-8"? ><set xmlns:android= "Http://schemas.android.com/apk/res/android" android:fillafter= "true" android:fillenabled= "true" android:interpolator= "@android: Anim/bounce_ Interpolator "> <translate android:duration=" " android:fromydelta=" -100% " android: Toydelta= "0%"/></set>
@Overridepublic void Onanimationstart (Animation Animation) {Centerimageview.setimageresource (r.drawable.green_pin_ Lift);} @Overridepublic void Onanimationrepeat (Animation Animation) {} @Overridepublic void Onanimationend (Animation Animation ) {Centerimageview.setimageresource (r.drawable.green_pin);}
The above Mapactivity.java contains the above functions
Android Gold Map use