通过给定的特定用户输入移动标记

Shift marker by given specific user input

<template>
   GmapMarker
   v-for="(marker, index) in markerArray"
   :key="index"
   :position="marker.position"
   @dragend="getCoordinates"
   :draggable="true"
  />                              
</template>

<script>


 methods: {
 getCoordinates: function(e) {
 //log of the lat and lng of where the pin is currently situated.
     }
}
</script>

我目前正在使用 vue2-google-maps 插件,但是,我想弄清楚如何通过提供特定的街道号码和街道名称来移动标记。 通过使图钉可拖动并通过 getCoordinates() 我能够获得特定地点的纬度和经度,但是,我想根据给定的街道编号 and/or 街道名称进行图钉移位。

我使用这个端点找到了解决方案:

https://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&key=YOUR_API_KEY

我没有使用实际地址,而是连接了存储这些变量的变量,因此只要其中一个发生变化,我就会执行此 API 调用,然后我进入 return Lat 和 Lng 以及另一堆东西,然后在这里我将坐标推入我的 markerArray,并相应地移动引脚。

参考:https://developers.google.com/maps/documentation/geocoding/intro