[英]VueJS + Quasar Framework + Google Maps JS API
could you please help me to import Google Maps API to my VUE app created with Quasar Framework? 您能帮我将Google Maps API导入到使用Quasar Framework创建的VUE应用中吗?
I have installed google-maps 我已经安装了谷歌地图
I have followed the instructions here and I create a gmapApi.js file 我已按照此处的说明进行操作,并创建了一个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']
}
Then I added gmapApi on my quasar.conf.js under plugins 然后我在quasar.conf.js的插件下添加了gmapApi
// app plugins (/src/plugins)
plugins: [
'gmapApi'
]
Then, how do I reference the gmap in a Vue component? 然后,如何在Vue组件中引用gmap? lets say I want to reverse geolocate a position 可以说我想反转地理位置
I tried 我试过了
var geocoder = new this.$gmaps.maps.Geocoder()
But I get an error that maps is undefined. 但是我得到一个错误,地图是不确定的。
What am I missing here? 我在这里想念什么? Am I even on the right track? 我是否在正确的轨道上?
Nevermind, found it 没关系,找到了
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.