const centerInt = ref(null);
const zoomCenterInt = ref(null)
//缩放结束
map.on('zoomend', () => {
updateCenterAndZoom();
});
//移动结束
map.on('moveend', () => {
updateCenterAndZoom();
});
const updateCenterAndZoom=() =>{
if (map) {
const centerPoint = map.getCenter();
centerInt.value = {
lat: centerPoint.lat,
lng: centerPoint.lng
};
zoomCenterInt.value = map.getZoom();
}
}
//定位飞入效果,zoom缩放层级,latlng经纬度
const zoomPos = (zoom, latlng) => {
map.flyTo(latlng, zoom, { animate: true, duration: 1 });
};
vue3中leaflet地图缩放、移动获取地图中心点坐标及缩放层级
最新推荐文章于 2025-07-09 16:31:56 发布