Javascript vue2 google map无法加载库
我想在我的app.js中加载带有vue2谷歌地图组件的地理代码库Javascript vue2 google map无法加载库,javascript,google-api,vue-component,Javascript,Google Api,Vue Component,我想在我的app.js中加载带有vue2谷歌地图组件的地理代码库 import*作为“vue2谷歌地图”中的VueLogleMaps Vue.use(VueLogleMaps{ 负载:{ 关键字:, 图书馆:“地点,地理编码”, 语言:"en",, } }) 在加载页面时,我得到404错误 https://maps.googleapis.com/maps-api-v3/api/js/38/11/geocode.js net::ERR_ABORTED 404 我的api密钥已启用,可以从浏览
import*作为“vue2谷歌地图”中的VueLogleMaps
Vue.use(VueLogleMaps{
负载:{
关键字:,
图书馆:“地点,地理编码”,
语言:"en",,
}
})
在加载页面时,我得到404
错误
https://maps.googleapis.com/maps-api-v3/api/js/38/11/geocode.js net::ERR_ABORTED 404
我的api密钥已启用,可以从浏览器获取地理代码库,下面的请求有效
https://maps.googleapis.com/maps/api/geocode/json?latlng=<lat>,<lng>&key=<my_api_key>
https://maps.googleapis.com/maps/api/geocode/json?latlng=,&键=
最后,我在组件初始化时加载地理代码库是错误的,为了加载地理代码库,我使用了组件的$mapPromise方法
navigator.geolocation.getCurrentPosition(position => {
this.$refs.gmap.$mapPromise.then(() => {
let geocoder = new google.maps.Geocoder()
let home = new google.maps.LatLng(position.coords.latitude, position.coords.longitude)
geocoder.geocode({
location: home
},
function(geocoderResults) {
console.log('google result' , geocoderResults);
});
})
});