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
Javascript 谷歌地图地理编码API中的CORS错误_Javascript_Google Maps - Fatal编程技术网

Javascript 谷歌地图地理编码API中的CORS错误

Javascript 谷歌地图地理编码API中的CORS错误,javascript,google-maps,Javascript,Google Maps,我正面临一个相当突然的谷歌地图地理编码问题。直到昨天,一切都很好,但从那时起,我在对他们的地理编码API的任何请求上都收到了CORS错误 我的请求: https://maps.googleapis.com/maps/api/geocode/json?latlng=18.92187618976372,72.82581567764282&key=<API_KEY> 响应标题: access-control-allow-origin:* alternate-protocol:44

我正面临一个相当突然的谷歌地图地理编码问题。直到昨天,一切都很好,但从那时起,我在对他们的地理编码API的任何请求上都收到了CORS错误

我的请求:

https://maps.googleapis.com/maps/api/geocode/json?latlng=18.92187618976372,72.82581567764282&key=<API_KEY>
响应标题:

access-control-allow-origin:*
alternate-protocol:443:quic,p=1
cache-control:public, max-age=86400
content-encoding:gzip
content-length:1279
content-type:application/json; charset=UTF-8
date:Thu, 23 Jul 2015 09:50:49 GMT
expires:Fri, 24 Jul 2015 09:50:49 GMT
server:mafe
status:200
vary:Accept-Language
x-frame-options:SAMEORIGIN
x-xss-protection:1; mode=block
错误消息:

XMLHttpRequest cannot load https://maps.googleapis.com/maps/api/geocode/json?latlng=18.92187618976372,72.82581567764282&key=<API_KEY>. A wildcard '*' cannot be used in the 'Access-Control-Allow-Origin' header when the credentials flag is true. Origin 'http://domain' is therefore not allowed access.
XMLHttpRequest无法加载https://maps.googleapis.com/maps/api/geocode/json?latlng=18.92187618976372,72.8258156764282&key=。当凭据标志为true时,不能在“Access Control Allow Origin”标头中使用通配符“*”。起源'http://domain因此,不允许访问。

我的系统是以这样一种方式设置的:我的前端由我的逻辑服务器跨域提供服务。为此,我将我的
withCredentials
标志设置为
true
。由于Maps的API使用了
*
通配符,
with credentials
给出了一个错误


为了解决这个问题,我对标记设置为false的Maps调用使用了一个单独的XHR方法。

您的代码是什么样子的?@geocodezip,我解决了这个问题。看看下面。:)
XMLHttpRequest cannot load https://maps.googleapis.com/maps/api/geocode/json?latlng=18.92187618976372,72.82581567764282&key=<API_KEY>. A wildcard '*' cannot be used in the 'Access-Control-Allow-Origin' header when the credentials flag is true. Origin 'http://domain' is therefore not allowed access.