This commit is contained in:
2026-07-30 13:07:50 +08:00
parent 0eb2835215
commit 2aae14a627
3 changed files with 88 additions and 15 deletions
+8 -10
View File
@@ -57,7 +57,6 @@ function addMarkers(pois) {
clearMarkers()
if (!map || !pois.length) return
const bounds = L.latLngBounds()
const pinIcon = L.divIcon({
className: '',
html: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 42" width="32" height="42">
@@ -92,12 +91,6 @@ function addMarkers(pois) {
bounds.extend([lat, lng])
})
// 自动调整视野
if (pois.length === 1) {
map.setView(bounds.getCenter(), 15)
} else {
map.fitBounds(bounds, { padding: [40, 40], maxZoom: 16 })
}
}
function focusMarker(poi) {
@@ -105,7 +98,6 @@ function focusMarker(poi) {
const lng = parseFloat(poi.longitude)
if (isNaN(lat) || isNaN(lng)) return
map.setView([lat, lng], 16)
for (const marker of currentMarkers) {
const pos = marker.getLatLng()
if (Math.abs(pos.lat - lat) < 0.001 && Math.abs(pos.lng - lng) < 0.001) {
@@ -133,7 +125,6 @@ function drawRadiusCircle(lat, lng, radiusMeters) {
weight: 2,
dashArray: '6, 6',
}).addTo(map)
map.fitBounds(radiusCircle.getBounds(), { padding: [40, 40] })
}
function clearRadiusCircle() {
@@ -143,7 +134,14 @@ function clearRadiusCircle() {
}
}
defineExpose({ addMarkers, clearMarkers, focusMarker, drawRadiusCircle, clearRadiusCircle, flyTo })
// 只更新已有圆圈的大小,不改变地图视角
function updateRadiusCircle(radiusMeters) {
if (radiusCircle) {
radiusCircle.setRadius(radiusMeters)
}
}
defineExpose({ addMarkers, clearMarkers, focusMarker, drawRadiusCircle, clearRadiusCircle, updateRadiusCircle, flyTo })
</script>
<style scoped>