Question

Here is a sample of the XML:

<markers><marker name="Faulkner State Community College" lat="30.853801" lng="-87.776692" type="PS" number="279" address="CFOT, CPCT" /></markers>

The parser is picking up name, lat, lan, and address. It's not picking up type and number. The output for type and number is undefined. I don't need them converted to anything other than a string.

Here is my code:

var markerNodes = xml.documentElement.getElementsByTagName("marker");
    for (var i = 0; i < markerNodes.length; i++) {
        var name = markerNodes[i].getAttribute("name");
        var address = markerNodes[i].getAttribute("address");
        var type = markerNodes[i].getAttribute("type");
        var number = markerNodes[i].getAttribute("number");
        var latlng = new google.maps.LatLng(
            parseFloat(markerNodes[i].getAttribute("lat")),
            parseFloat(markerNodes[i].getAttribute("lng")));


        createMarker(latlng, name, address, type, number);
   }

And here is the code for 'createMarker', just in case:

function createMarker(latlng, name, address, type, number) {
    var html = "<font face=\"Arial\" size=\"2\"><b><a href=\"school.php?school_number=" + number + "\">" + name + "</a></b> <br/>Certifications: " + address + "<br/>School #: " + number + "</font>";
    var marker = new google.maps.Marker({
    map: map,
    position: latlng,
    icon: customIcon(type)
  });
  google.maps.event.addListener(marker, 'click', function() {
    infoWindow.setContent(html);
    infoWindow.open(map, marker);
  });
  markers.push(marker);
}
Was it helpful?

Solution

I had two sets of the markerNodes parsing and was editing the wrong set.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top