Baidu Map JS API Mobile, PHONEGAP custom Overlay Click event cannot execute bug resolution

Source: Internet
Author: User

When you add a click event to a custom overlay, you will find that the mobile side is not triggering at all, which is a bug.

I recently developed a second edition for my Map app, and I was bothered to add behavior to a cover, the Click event of the custom overlay was not triggered on the iphone, and the open Source Library in the Baidu Map JS API involved a custom overlay Click event that was not valid.

I worry for this bug for a long time, until today, QQ Group in the Netizen (in this first thank the Netizen mooring) told me the solution: the custom overlay event on the iphone triggers the map's click event by default, if map defines the Click event, The Click event of the custom overlay is also triggered passively.

The implementation method can change the click event of the custom overlay to Touchstart or touchend move Touch event, Advance Map.click event Execution (because the Click event will be delayed by about 300 milliseconds on the mobile side for a specific reason not detailed here, Please own Google), this time can be set tmpfun = Map.onclick;map.onclick = null, in the touch event set map.onclick = Tmpfun; This causes the Click event of the custom overlay to be triggered by the Map.click, but does not trigger the Map.click "event".

Specific code:

Tmpfun = Map.onclick;
Map.onclick = null;
Myname.addeventlistener ("Touchstart", function () {
Map.onclick = Tmpfun;
Alert ("click");
});

Reprinted from: Http://imwelkin.lofter.com/post/1ce8cc_7dc4e1

Baidu Map JS API Mobile, PHONEGAP custom Overlay Click event cannot execute bug resolution

Related Article

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.