我使用 MapboxGL.js,当点击多边形时我想调用我的函数(例如,打开弹出窗口)。
在移动设备上,事件发生时出现错误touchstart(jsfiddle 脚本中的第 103 行):
“无法阻止被动事件侦听器调用内的默认”。
谁能解释一下为什么这个错误出现在手机上而不是台式电脑上?
map.on('touchstart', 'places', function(e) {
const features_in_point = map.queryRenderedFeatures(
[e.point.x, e.point.y],
{
layers: ['places']
}
);
const selected_ids = features_in_point.map(f => f.id);
const selected_features = PLACES_GEOJSON.features.filter(f => selected_ids.includes(f.id))
draw.deleteAll();
draw.add({
'type': 'FeatureCollection',
'features': selected_features
});
});
Run Code Online (Sandbox Code Playgroud)
这是带有示例的 JSfiddle:
https ://jsfiddle.net/petrovnn/ose40zpL/2/
我需要编写chrome扩展名,引用新版Google Maps网站.
但是,在新的谷歌地图预览我不能给链接因为我无法计算新的缩放参数.
例如,网址新的Google地图:https://www.google.com/maps/preview#!data=! 1m4!1m3!1d4112402! 2d-62.7728736! 3d44.829016
新的缩放参数很奇怪:
zoom 23 http://google.com/maps/preview#!data=!1m4!1m3!1d 1145 !2d29.6765085!3d59.868445
...
zoom 12 http://google.com/maps/preview#!data=!1m4!1m3!1d 77910 !2d29.6765085!3d59.868445
zoom 11 http://google.com/maps/preview#!data=!1m4!1m3!1d 155852 !2d29.6765085!3d59.868445
zoom 10 http://google.com/maps/preview#!data=!1m4!1m3!1d 311710 !2d29.6765085!3d59.868445
zoom 9 http://google.com/maps/preview#!data=!1m4!1m3!1d 623333 !2d29.568544!3d59.8698115
zoom 8 http://google.com/maps/preview#!data=!1m4!1m3!1d 1247028 !2d29.568544!3d59.8698115
zoom 7 http://google.com/maps/preview#!data=!1m4!1m3!1d 2493322 !2d29.568544!3d59.8698115
zoom 6 http://google.com/maps/preview#!data=!1m4!1m3!1d 4987951 !2d29.568544!3d59.8698115
zoom 5 http://google.com/maps/preview#!data=!1m4!1m3!1d 9979726 !2d29.568544!3d59.8698115
zoom 4 http://google.com/maps/preview#!data=!1m4!1m3!1d 19959453 !2d29.568544!3d59.8698115
zoom 3 http://google.com/maps/preview#!data=!1m4!1m3!1d 40027823 !2d29.568544!3d52.0636483
zoom 2 http://google.com/maps/preview#!data=!1m4!1m3!1d 80266577 !2d29.568544!3d48.7705008
zoom 1 http://google.com/maps/preview#!data=!1m4!1m3!1d 100000000 !2d29.568544!3d47.3841015
? ? …Run Code Online (Sandbox Code Playgroud)