我正在尝试在Vue JS项目中使用Google Map API。我正在使用两个Google Maps服务:-第一个是时区API =>效果很好-第二个是Elevation API =>获取跨域读取阻止我验证了邮递员中的url作品尝试使用Ajax和vue-resource不使用海拔APIaxios .get(`https://maps.googleapis.com/maps/api/elevation/json?locations=${latitude},${longitude}&key=APIKEY`) .then(response => { console.log(response); return response.result.elevation; }) .catch(error => { console.log(error); });WORKS TIMEZONE APIaxios .get(`https://maps.googleapis.com/maps/api/timezone/json?location=${place.latitude},${place.longitude}×tamp=${moment().unix()}&key=APIKEY`) .then(response => { console.log(response); return response.result.elevation; }) .catch(error => { console.log(error); });结果是:-从来源' https://test.test '访问' https://maps.googleapis.com/maps/api/elevation/json?locations=51.49602489999999,-0.17026260000000093&key=APIKEY '处的XMLHttpRequest已被CORS阻止策略:所请求的资源上不存在“ Access-Control-Allow-Origin”标头。和警告:跨域读取阻止(CORB)阻止了跨域响应https://maps.googleapis.com/maps/api/elevation/json?locations=51.49602489999999,-0.17026260000000093&key=APIKEY,MIME类型为application / json
添加回答
举报
0/150
提交
取消