Baidu Map Api--markertool Click Add to Event

Source: Internet
Author: User

Baidu Map API to implement the tagging function, one is to use the marker in the overlay directly, so the advantage is that you can directly use the Official 2.0 to provide a variety of interfaces, but some complex requirements to achieve some cumbersome, such as the mouse to follow the model changes, click on the model changes and so on.

Another option is to use the Markertool Open Source Library provided in the 1.2 interface, which is basically enough for the real-world tagging function (http://developer.baidu.com/map/index.php?title=open/library)

However, when you implement a click event listener after labeling is added, you need to make appropriate changes to the source code, such as the Click event listener that implements the tag icon

Think of it like this:

Mkrtool.addeventlistener ("click", Function (e) {alert ("test"); });

In fact, the actual modification point should be the _clickhandler method in source code markertool.js, because the instance of Markertool will remove the click event after the clicked event is added, and it is only for the map object, as follows:

var MKR = new Bmap.marker (PT, {Icon:me._opts.icon});  This adds marker monitor Mkr.addeventlistener ("click", Function (e) {alert ("test"); }); Me._map.addoverlay (MKR);


Baidu Map Api--markertool Click Add to Event

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.