google-maps - 如何为Google Places API启用CORS

标签 google-maps cors ionic-framework google-places-api google-places

我已经尝试了所有可能的方法,以使我的应用程序正常运行,而无需“启用Chrome的CORS扩展程序”。我遵循了Google官方网站上有关身份验证 token 的步骤,尝试使用每个不同的 key ,但是没有任何效果。我收到以下错误:

XMLHttpRequest无法加载https://maps.googleapis.com/maps/api/place/nearbysearch/json?key=MyKey&location=33.854546,-84.35870369999999&types=restaurant&rankby=distance.在请求的资源上不存在“Access-Control-Allow-Origin” header 。因此,不允许访问原始http://localhost:8100

如果没有Chrome的CORS扩展程序,是否甚至可以从应用程序内部访问Google Places API?

最佳答案

可以使用JSONP代替CORS来完成您的任务。

请阅读以下内容以开始使用:Link1Link2

关于google-maps - 如何为Google Places API启用CORS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30178359/

相关文章:

javascript - Angular Google map - map 信息窗口

javascript - Google map 自定义信息窗口

python - 如何在 Google App Engine 上安装 googlemaps 模块

angular - ionic v4 : Using Proxy to resolve CORS fails

ios - ngCordova Camera - 拍摄像 instagram(iOS)这样的方形照片?

java - Cordova错误: Failed to execute shell command "getprop,dev.bootcomplete""

ios - 如何获得 MKPolyline 上的等距位置?

c# - 使用多个主机设置 CORS 配置

javascript - 跨源请求被阻止 : Occur even after CORS enabled on my API ;

javascript - 通过包含 AngularJS 中的子字符串的属性过滤对象数组