This commit is contained in:
@@ -21,6 +21,7 @@ const token = '13f4c06b-cb7e-4eeb-81f1-af52f12587b2'
|
||||
const mapContainer = ref<HTMLDivElement | null>(null)
|
||||
const { coords } = useGeolocation()
|
||||
const coordsReady = ref(false)
|
||||
const mapInstance = ref<any | null>(null)
|
||||
|
||||
const initMap = async (lat: number, lon: number) => {
|
||||
if (!window.ymaps) {
|
||||
@@ -38,6 +39,7 @@ const initMap = async (lat: number, lon: number) => {
|
||||
zoom: 10,
|
||||
controls: ['zoomControl'],
|
||||
})
|
||||
mapInstance.value = map
|
||||
|
||||
props.pickupPoints.forEach((point) => {
|
||||
const placemark = new window.ymaps.Placemark(
|
||||
@@ -53,6 +55,15 @@ const initMap = async (lat: number, lon: number) => {
|
||||
})
|
||||
}
|
||||
|
||||
const centerMap = (lat: number, lon: number) => {
|
||||
if (!mapInstance.value)
|
||||
return
|
||||
|
||||
mapInstance.value.setCenter([lat, lon], 18)
|
||||
}
|
||||
|
||||
defineExpose({ centerMap })
|
||||
|
||||
watch(
|
||||
() => coords.value,
|
||||
async (val) => {
|
||||
|
||||
Reference in New Issue
Block a user