在Google Maps API V3上向Geocoding JSON响应添加回调的方法

|| 所以我有一个类似的URL: http://maps.googleapis.com/maps/api/geocode/json?&sensor=false&address=1330+SW%203rd%20Ave、%20Portland、%20OR 但它仅返回JSON。我正在寻找一个JSONP调用。我想在没有服务器端代码的情况下执行此操作。有没有一种方法可以向其或函数添加var名称?通常,API具有
callback
参数。或者,你们中的任何人都知道任何骇客吗?我现在的代码是:
createScriptTag:function(the_src,callback){
    var headID = document.getElementsByTagName(\"head\")[0],         
        newScript = document.createElement(\'script\');
    newScript.type = \'text/javascript\';
    newScript.onload=callback;
    newScript.src = the_src;
    headID.appendChild(newScript);
  }

 //Then call it like:
 createScriptTag(
   \'http://maps.googleapis.com/maps/api/geocode/json?&sensor=false&address=1330+SW%203rd%20Ave,%20Portland,%20OR\',
   function(){ /* I can\'t do anything with the JSON :( */ }
 )
    
已邀请:
在我看来,您正在使用Geocoder API而不是Maps API。根据文档,Geocoder API不适用于实时使用: http://code.google.com/apis/maps/documentation/geocoding/   该服务通常是为   静态地理编码(预先已知)   申请地址   地图上的内容;这项服务不是   旨在实时响应   例如,用户输入。对于动态   地理编码(例如,在用户内   界面元素),请咨询   JavaScript API文档   V2客户端地理编码器,JavaScript API   V3客户端地理编码器或Maps API   适用于Flash Client Geocoder。 也许您需要查看http://code.google.com/apis/maps/documentation/javascript/services.html#Geocoding,它是内置回调的客户端。尽管我认为该API的许可要求将地理编码结果与Google地图结合使用。     

要回复问题请先登录注册