在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 :( */ }
)
没有找到相关结果
已邀请:
1 个回复
容淑阔九