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

时间:2019-01-30 21:36:46

标签: javascript google-maps vue.js vue2-google-maps

<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()我能得到一个特定的地点的纬度和液化天然气,但是,我想就根据给定的街道号码和/或街道名称引脚移。

1 个答案:

答案 0 :(得分:0)

我已经通过使用此端点找到了解决方案:

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

我将存储这些变量的变量串联起来,而不是实际的地址,所以每当其中一个变量发生更改时,我都会执行此API调用,在那里我会返回Lat和Lng以及另一堆东西,然后在这里将坐标推入markerArray中,并相应地进行销移。

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

相关问题