Is there an equivalent for GDownloadUrl function in Google Maps API v3

≯℡__Kan透↙ 提交于 2019-12-12 21:41:23

问题


I used the Google Maps API version 2 function GDownloadUrl on various places to download XML/JSON data. I am converting about 3 dozen map pages to version 3 and I am unable to find an equivalent of this function. Is there one or should I use another library for handling AJAX/XHR?


回答1:


There is no built in function in the google maps API v3 (there are several discussions in the v3 group if you want some history, including this one including an answer by Pamela Fox from google (at the time)). There is an example in the demo gallery (search for xml), and I have a version that I use in this example from Mike WIlliams' v2 tutorial that I translated to v3.




回答2:


There is no equivalent function in the API V3. I use this separate function that I wrote based on this example:

https://developer.mozilla.org/En/AJAX:Getting_Started#Step_3_.E2.80.93_A_Simple_Example

(It works fine in all browsers)




回答3:


Instead of...

    GDownloadUrl('https://your/url.json', function(data) {
        // ...
    });

...you can do this, assuming you have jQuery loaded and is available as $:

    $.get('https://your/url.json', function(data) {
        // ...
    });


来源:https://stackoverflow.com/questions/11539630/is-there-an-equivalent-for-gdownloadurl-function-in-google-maps-api-v3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!