[英]VueJS + Quasar Framework + Google Maps JS API
您能帮我将Google Maps API导入到使用Quasar Framework创建的VUE应用中吗?
我已经安装了谷歌地图
我已按照此处的说明进行操作,并创建了一个gmapApi.js文件
import GoogleMapsLoader from 'google-maps'
// leave the export, even if you don't use it
export default ({ app, router, Vue }) => {
Vue.prototype.$gmaps = GoogleMapsLoader
Vue.prototype.$gmaps.KEY = 'MY-KEY'
Vue.prototype.$gmaps.LIBRARIES = ['places']
}
然后我在quasar.conf.js的插件下添加了gmapApi
// app plugins (/src/plugins)
plugins: [
'gmapApi'
]
然后,如何在Vue组件中引用gmap? 可以说我想反转地理位置
我试过了
var geocoder = new this.$gmaps.maps.Geocoder()
但是我得到一个错误,地图是不确定的。
我在这里想念什么? 我是否在正确的轨道上?
没关系,找到了
this.$gmaps.load(function (google) {
let geocoder = new google.maps.Geocoder()
let point = new google.maps.LatLng(position.coords.latitude, position.coords.longitude)
console.log(point)
geocoder.geocode({'latLng': point}, function (locations, status) {
console.log(status + ' ' + locations)
})
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.