如何放大 Mapbox Leaflet 中的标记点击事件?
How to zoom on marker click event in Mapbox Leaflet?
我想在单击标记时放大它。我正在使用 Mapbox 和传单。
我试过了:
marker.on('click', function(e){
map.setView([e.lat, e.lng], 12);
});
但它给了我某种错误:
TypeError: t is null
我什至尝试过:
marker.on('click', function(e){
map.fitBounds(marker.getBounds());
});
要获取事件的经纬度,必须使用e.latlng:latlng reference。使用这个:
marker.on('click', function(e){
map.setView(e.latlng, 13);
});
尝试
marker.on('click', function(e){
map.setView([e.latlng.lat, e.latlng.lng], 12);
});
我想在单击标记时放大它。我正在使用 Mapbox 和传单。
我试过了:
marker.on('click', function(e){
map.setView([e.lat, e.lng], 12);
});
但它给了我某种错误:
TypeError: t is null
我什至尝试过:
marker.on('click', function(e){
map.fitBounds(marker.getBounds());
});
要获取事件的经纬度,必须使用e.latlng:latlng reference。使用这个:
marker.on('click', function(e){
map.setView(e.latlng, 13);
});
尝试
marker.on('click', function(e){
map.setView([e.latlng.lat, e.latlng.lng], 12);
});