简体   繁体   中英

Error loading markers in Google Maps to Website

What I'm doing here is taking info from an XML file I got online (actually 2 of them, here's one example ), and using it to create markers on a custom google map. Everything works fine on my local machine in Safari (doesn't work in Chrome or Firefox), the xml file loads, I grab all of the information I need, and create the markers successfully. Here's my code:

function loadXml(xmlText) {
    if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
        xmlhttp=new XMLHttpRequest();
    } else {// code for IE6, IE5
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlhttp.open("GET",xmlText,false);
    xmlhttp.send();
    xmlDoc=xmlhttp.responseXML;
    return xmlDoc;
}

For some reason, though, when I publish my code onto a website, the map shows up, but none of the markers show up ( here's the site ). When I tried to figured out what my problem was, this is what I found in the error console:

uncaught exception: {Exception... "Component returned falure code: 0x80004005 (NS_ERROR_FALIURE" nresult: "0x80004005 (NS-ERROR-FALIRE)" location:"JS frame :: http://getmethere.zzl.org/ :: load XML :: line 171" data: no]

I'm not entirely sure what's going on here, I just borrowed this portion of my code from somewhere else. But from what I got, there's something wrong with my loadXml function. The parameter takes in the url that contains the XML file (see the link in the first sentence). Can anyone suggest a solution??

Thanks!!!

You are loading resources from a different site, for example http://www.capitalbikeshare.com/stations/bikeStations.xml . I am getting a NETWORK_ERR: XMLHttpRequest Exception 101 , which is an Access-Control-Allow-Origin problem. This means that the other site does not allow you to retrieve content from their site, so try hosting the XML file on your own site instead (assuming you have the rights).

Some quick Googling gives this page: http://helpful.knobs-dials.com/index.php/0x80004005_%28NS_ERROR_FAILURE%29_and_other_firefox_errors

I wonder if the browser just can't find or access the XML file which you're loading.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM