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