Next I wrote a one hundred-degree map of Baidu map to build a development environment (Lao Luo video note sorting)
Show traffic map
// Display the traffic map mapview. settraffic (true );
Show satellite map
// Display the satellite map mapview. setsatellite (true );
Overview of How to overlay a map:
All contents that overlay or overwrite a map are collectively referred to as map covers. Covers such as annotation, vector image elements (including line and multi-deformation and circle), positioning icons, and other elements have their own geographical coordinates. When you drag or scale a map, they move accordingly.
The map API provides the following cover types:
Overlay: the abstract base class of the cover. All the covers inherit this class of method to display custom layers.
Myloactionoverlay: An overlay that displays the current user location.
Itemizedoverlay <item extends overlayitem>: a base class of overlay, which contains an overlayitem list, which is equivalent to a group of overlay entries. by inheriting this class, a group of interest points are displayed on the map.
Poioverlay: A local search layer that provides a location search service for a specific region. For example, you can search for a "park" in Beijing and use this park to display it on a map.
Routeoverlay: a layer of walking and driving navigation lines. The routes and key points of the walking and driving routes are displayed on the map.
Transitoverlay: A bus transfer line layer that displays the route and transfer location of a bus trip plan in a specific region on the map;
One practical case: demonstrate the description of map covering
Package COM. android. android_baidu_myoverlay; import COM. android. android_baidu_myoverlay.r; import COM. baidu. mapapi. bmapmanager; import COM. baidu. mapapi. geopoint; import COM. baidu. mapapi. mkgenerallistener; import COM. baidu. mapapi. mapactivity; import COM. baidu. mapapi. mapcontroller; import COM. baidu. mapapi. mapview; import COM. baidu. mapapi. overlay; import android. graphics. canvas; import android. graphics. paint; Im Port android. graphics. point; import android. OS. bundle; import android. widget. toast; public class mainactivity extends mapactivity {// Add the control of Baidu map private mapview; // the engine for loading maps private bmapmanager; // Baidu map's key private string keystring = "8c426377b3526b6bf3672c9ba3bb544d1e8289cd"; // Add some controls on Baidu map, such as the enlarged or reduced control private mapcontroller; @ override public void oncreate (bundle save Dinstancestate) {super. oncreate (savedinstancestate); setcontentview (R. layout. main); mapview = (mapview) This. findviewbyid (R. id. bmapview); bmapmanager = new bmapmanager (mainactivity. this); // The Key bmapmanager must be loaded. init (keystring, new mkgenerallistener () {public void ongetpermissionstate (INT arg0) {If (arg0 = 300) {toast. maketext (mainactivity. this, "The entered key is incorrect. Please verify it !! ", 1 ). show () ;}} public void ongetnetworkstate (INT arg0) {}}); this. initmapactivity (bmapmanager); // indicates that the zoom function mapview can be set. setbuiltinzoomcontrols (true); mapcontroller = mapview. getcontroller (); mapcontroller. setzoom (12); mapview. getoverlays (). add (New myoverlay ();} public class myoverlay extends overlay {// a point built on the map geopoint = new geopoint (INT) (39.915*1e6 ), (INT) (116.404*1e6); // declare a painter Private paint = new paint (); @ override public void draw (canvas arg0, mapview arg1, Boolean arg2) {super. draw (arg0, arg1, arg2); point = mapview. getprojection (). topixels (geopoint, null); arg0.drawtext ("* Here is Tiananmen Square", point. x, point. y, paint) ;}@ override protected void ondestroy () {super. ondestroy (); If (bmapmanager! = NULL) {bmapmanager. Destroy (); bmapmanager = NULL ;}@override protected void onresume () {super. onresume (); If (bmapmanager! = NULL) {bmapmanager. Start () ;}@ override protected void onpause () {// todo auto-generated method stub super. onpause (); If (bmapmanager! = NULL) {bmapmanager. Stop () ;}@ override protected Boolean isroutedisplayed () {// todo auto-generated method stub return false ;}}