Description of multiple covers on the three hundred-degree map of Baidu Map

Source: Internet
Author: User
Tags ontap
(According to the old Luo video) How to mark multiple buildings on a map as a certain type of covering, you can use the itemizedoverlay class to process multiple items with the same type, display method, and processing method. Itemizedoverlay is an abstract class that is a subclass of overlay and contains an overlayitem list. Processing items from south to north are used to draw, create a translation boundary, draw a tag point for each vertex, and maintain a focal point selected item, it is also responsible for matching a screen click to an item and distributing the focus change event to the alternative listener. Draw (...): draws a mark point on each item. Getcenter (): by default, getlatspane6 () getlonspane6 () ONTAP (geopoint P, mapview) of the first item is returned: Click Event size () when a building is clicked (): Number of overlayitems.


Case study: add multiple buildings to a map

 

Import Java. util. arraylist; import Java. util. list; import COM. android. android_baidu_muloverlayitem.r; import COM. baidu. mapapi. bmapmanager; import COM. baidu. mapapi. geopoint; import COM. baidu. mapapi. itemizedoverlay; import COM. baidu. mapapi. mkgenerallistener; import COM. baidu. mapapi. mapactivity; import COM. baidu. mapapi. mapcontroller; import COM. baidu. mapapi. mapview; import COM. baidu. mapapi. overlayitem; Import android. graphics. drawable. drawable; 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; // key private string keystring = "Hangzhou" of Baidu map; // Add some controls on Baidu map, such as the enlarged or reduced control private mapcontroller; @ overridepublic void on Create (bundle savedinstancestate) {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 (); // set the zoom level to 12 mapcontrollers. setzoom (12); drawable = getresources (). getdrawable (R. drawable. icon_marka); mapview. getoverlays (). add (New myoverlayitem (drawable);} public class myoverlayitem extends it Emizedoverlay <overlayitem> {private list <overlayitem> List = new arraylist <overlayitem> (); // define a set of coordinates for the double type private double mlat1 = 39.90923; // It indicates that the latitude is private double mlon1 = 116.397428; // It indicates that the longitude is private double mlat2 = 39.9022; // It indicates that the latitude is private double mlon2 = 116.3922; // indicates the longitude private double mlat3 = 39.9033; // indicates the latitude private double mlon3 = 116.3933; // indicates the longitude // used to mark the coordinates on the map, mark public myoverlayitem (drawable Arg with an image 0) {super (arg0); // The geopoint geopoint1 = new geopoint (INT) (mlat1 * 1e6), (INT) of the first group of data on the map) (mlon1 * 1e6); // The annotation point geopoint geopoint2 = new geopoint (INT) (mlat2 * 1e6), (INT) of the second group of data on the map) (mlon2 * 1e6); // geopoint geopoint3 = new geopoint (INT) (mlat3 * 1e6), (INT) (mlon3 * 1e6); // annotation point, title, segment list. add (New overlayitem (geopoint1, "point1", "point1"); list. add (New overlayitem (geopoint2, "point2", "point2 ")); List. add (New overlayitem (geopoint3, "point3", "point3"); populate (); // implemented the map refresh function} // returns each coordinate in the specified list set @ overrideprotected overlayitem createitem (INT arg0) {return list. get (arg0);} // returns the number of coordinates in the list set @ overridepublic int size () {return list. size () ;}@ overridepublic Boolean ONTAP (int I) {toast. maketext (mainactivity. this, list. get (I ). getsnippet (), 1 ). show (); Return true ;}@overrideprotected void Ondestroy () {super. ondestroy (); If (bmapmanager! = NULL) {bmapmanager. Destroy (); bmapmanager = NULL ;}@overrideprotected void onresume () {super. onresume (); If (bmapmanager! = NULL) {bmapmanager. Start () ;}@ overrideprotected void onpause () {super. onpause (); If (bmapmanager! = NULL) {bmapmanager. Stop () ;}@ overrideprotected Boolean isroutedisplayed () {return false ;}}

 

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.