Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/455.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript vue2 google map无法加载库_Javascript_Google Api_Vue Component - Fatal编程技术网

Javascript vue2 google map无法加载库

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密钥已启用,可以从浏览

我想在我的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密钥已启用,可以从浏览器获取地理代码库,下面的请求有效

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);
           });
       })
   });