


Introduction to the click event of Baidu Map in mobile H5 (code example)
The content of this article is an introduction to the click event (code example) of Baidu Map in mobile H5. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you. .
According to the official explanation of Baidu Maps, the following four events can be monitored in the mobile H5 page:
touchstart, touchmove, touchend, longpress
And if the click event is monitored on the map, the code in this event will not be executed on the mobile terminal.
When I made a request before, I monitored the touchend event for the map. I never thought that when I dragged the map, the code in the touchend was also executed. So you need to simulate a tap event like zepto to solve this problem. My code is:function initMap(baseData) { var mp = new BMap.Map('map'); var point = new BMap.Point( baseData.data.gardenLongitude, baseData.data.gardenLatitude ); mp.centerAndZoom(point, 15); // 保存 touch 对象信息 var obj = {}; mp.addEventListener('touchstart', function (e) { obj.e = e.changedTouches ? e.changedTouches[0] : e; obj.target = e.target; obj.time = Date.now(); obj.X = obj.e.pageX; obj.Y = obj.e.pageY; }); mp.addEventListener('touchend', function (e) { obj.e = e.changedTouches ? e.changedTouches[0] : e; if ( obj.target === e.target && // 大于 750 可看成长按了 ((Date.now() - obj.time) <p class="comments-box-content"></p>
The above is the detailed content of Introduction to the click event of Baidu Map in mobile H5 (code example). For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



In recent days, Ice Universe has been steadily revealing details about the Galaxy S25 Ultra, which is widely believed to be Samsung's next flagship smartphone. Among other things, the leaker claimed that Samsung only plans to bring one camera upgrade

OnLeaks has now partnered with Android Headlines to provide a first look at the Galaxy S25 Ultra, a few days after a failed attempt to generate upwards of $4,000 from his X (formerly Twitter) followers. For context, the render images embedded below h

The Vivo Y300 Pro just got fully revealed, and it's one of the slimmest mid-range Android phones with a large battery. To be exact, the smartphone is only 7.69 mm thick but features a 6,500 mAh battery. This is the same capacity as the recently launc

Samsung has not offered any hints yet about when it will update its Fan Edition (FE) smartphone series. As it stands, the Galaxy S23 FE remains the company's most recent edition, having been presented at the start of October 2023. However, plenty of

In recent days, Ice Universe has been steadily revealing details about the Galaxy S25 Ultra, which is widely believed to be Samsung's next flagship smartphone. Among other things, the leaker claimed that Samsung only plans to bring one camera upgrade

The Redmi Note 14 Pro Plus is now official as a direct successor to last year'sRedmi Note 13 Pro Plus(curr. $375 on Amazon). As expected, the Redmi Note 14 Pro Plus heads up the Redmi Note 14 series alongside theRedmi Note 14and Redmi Note 14 Pro. Li

OnePlus'sister brand iQOO has a 2023-4 product cycle that might be nearlyover; nevertheless, the brand has declared that it is not done with itsZ9series just yet. Its final, and possibly highest-end,Turbo+variant has just beenannouncedas predicted. T

Motorola has released countless devices this year, although only two of them are foldables. For context, while most of the world has received the pair as the Razr 50 and Razr 50 Ultra, Motorola offers them in North America as the Razr 2024 and Razr 2
