1

我已经使用 Google Maps Geocoding API Webservice 几个月了,最近它给了我这个错误:

XMLHttpRequest cannot load http://maps.googleapis.com/maps/api/geocode/json?address=1600%2BAmphitheatr…in%2BView%2C%2BCA&sensor=false. Origin is not allowed by Access-Control-Allow-Origin.

我正在使用以下代码:

$.getJSON( "http://maps.googleapis.com/maps/api/geocode/json",
 { address : "1600+Amphitheatre+Parkway,+Mountain+View,+CA", sensor : "false" },
 function(data) {
  if (data.status == "OK") {
   alert("ok!");
  }
});

根据 https://developers.google.com/maps/documentation/geocoding/ ,我应该能够使用上面的webservice api。

我还在 Google API 控制台中启用了 Google Maps v3 API 和 Static Maps API,并将我的域设置为允许引用域,但无济于事。

任何人都知道为什么这突然停止工作以及我该如何解决?如果可能的话,我希望能够继续使用 Web 服务而不是 Javascript API。

4

0 回答 0