Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/google-maps/4.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
Google maps 如何为Google Places API启用CORS_Google Maps_Cors_Ionic Framework_Google Places Api_Google Places - Fatal编程技术网

Google maps 如何为Google Places API启用CORS

Google maps 如何为Google Places API启用CORS,google-maps,cors,ionic-framework,google-places-api,google-places,Google Maps,Cors,Ionic Framework,Google Places Api,Google Places,我已经尽了一切可能让我的应用程序工作,而不需要“为Chrome启用CORS扩展”。我遵循谷歌官方网站上关于AuthToken的步骤,尝试使用每一个不同的密钥,但没有任何效果。我得到以下错误: XMLHttpRequest无法加载https://maps.googleapis.com/maps/api/place/nearbysearch/json?key=MyKey&location=33.854546,-84.358703699999&types=餐厅&rankby=距离。请求的资源上不存在“

我已经尽了一切可能让我的应用程序工作,而不需要“为Chrome启用CORS扩展”。我遵循谷歌官方网站上关于AuthToken的步骤,尝试使用每一个不同的密钥,但没有任何效果。我得到以下错误:

XMLHttpRequest无法加载
https://maps.googleapis.com/maps/api/place/nearbysearch/json?key=MyKey&location=33.854546,-84.358703699999&types=餐厅&rankby=距离。
请求的资源上不存在“访问控制允许原点”标题。来源<代码>http://localhost:8100因此,不允许访问


甚至可以从应用程序内部访问Google Places API,而不使用Chrome的CORS扩展吗?

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


请阅读以下内容开始:,

显然,谷歌的网络电话还不具体。唯一的解决方法是在代码中引用它们的“位置”库并使用api调用。如果您需要PostRequestJSONP,那么它是无用的。JSONP是不安全的,我相信它甚至被Google API阻止了,不推荐使用。改用谷歌api客户端库