我在模拟地图点击方面遇到了困难。以下是我的代码。
map.fire('click', function ()
{
newDropoff({lng: 27.4199870950609,lat: 53.240419723523775});
updateDropoffs(dropoffs);
})
这段代码是从这个指南中获取的。
map.on('click', function (e) {
// When the map is clicked, add a new drop off point
// and update the `dropoffs-symbol` layer
newDropoff(map.unproject(e.point));
updateDropoffs(dropoffs);
});
有人知道我代码中应该纠正什么吗?PS我已经检查过其他来源了。
map.fire('click', { lngLat: new mapboxgl.LngLat(17.42, 43.24)})
,但是出现了以下错误:Unhandled Promise Rejection: TypeError: undefined is not an object (evaluating 't.originalEvent.target') - StanoriginalEvent
),则需要手动添加它们。 - Steve Bennett