Javascript VueJS+;类星体框架&x2B;谷歌地图JSAPI
你能帮我把谷歌地图API导入我用Quasar框架创建的VUE应用程序吗 我已经安装了 我按照说明创建了一个gmapApi.js文件Javascript VueJS+;类星体框架&x2B;谷歌地图JSAPI,javascript,vue.js,google-maps-api-3,quasar,Javascript,Vue.js,Google Maps Api 3,Quasar,你能帮我把谷歌地图API导入我用Quasar框架创建的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
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的plugins下添加了GMAPPI
// 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)
})
})