A way to add a callback to Geocoding JSON response on Google Maps API V3

So I have a URL like: http://maps.googleapis.com/maps/api/geocode/json?&sensor=false&address=1330+SW%203rd%20Ave,%20Portland,%20OR But it returns *just* JSON. Im looking to do a JSONP call. I want to do this without server side code. Is there a way to add a var name to it or a function? Normally APIs have a `callback` param or something. Or, do any of you know any hacks? My code right now is: 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 :( */ } )

以上就是A way to add a callback to Geocoding JSON response on Google Maps API V3的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏