Привет, сразу извиняюсь, если можно куда то то закинуть код для лучшей наглядности , подскажите я закину.
Я используя forwardGeocoder по адресу конвертирую в координаты. Далее по координатам я отрисовываю маркер.
Мне нужно добиться того, что бы после изменения позиции маркера его новые координаты выводились в консоль.
Проект на VueJS.
———————————-
Код с помощью которого я отрисовываю маркеры
mounted() {
mapboxgl.accessToken = this.accessToken;
//Map init
let map = new mapboxgl.Map({
container: "mapContainer",
style: "mapbox://styles/mapbox/streets-v11",
center: [23.8223, 53.6688],
zoom: 7,
})
//ForwardGeoCodding logic
geocodingClient
.forwardGeocode({
query: 'Belarus, Homel',
})
.send()
.then(response => {
const match = response.body;
console.log('match: ', match)
let result = match.features[0].center
let latitude = match.features[0].center[0]
console.log(latitude)
let longitude = match.features[0].center[1]
console.log(longitude)
console.log('Coordinates from query', result)
this.fetchedGeoData.push({
//result
latitude,
longitude,
})
console.log('Fetched Geo Data: ', this.fetchedGeoData)
return result
})
.then(res => {
const geoData = res
console.log('response: ', res)
console.log('FlyTo new Point!')
map.flyTo({
center: geoData,
zoom: 12,
speed: 0.5,
})
return geoData
})
.then(res => {
let newMarker = res
console.log('Set marker from local state')
//Init marker
let marker = new mapboxgl.Marker({
color: "yellow",
draggable: true
})
.setLngLat(newMarker)
.addTo(map);
let lngLat = marker.getLngLat();
console.log(lngLat)
return newMarker
})
},