Google API wont return Location Label from XML

Discussion in 'Google API' started by Lost Oath, Oct 9, 2006.

  1. #1
    I'm using http://kung-fu.co.il/ckfa.asp for the map and http://kung-fu.co.il/data.xml for the data location.

    For some reason, clicking on the location point returns NULL instead of the label value. What am I missing?

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
      <head>
        <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
        <title>Google Maps JavaScript API Example</title>
        <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAA8jlppUrk568GKnIW_jY2dxRMCicQ4cOvVFQOd2gp7lREz5rVChSKxJDOcfpRZYOV0KZt8dITmhEmCg"
                type="text/javascript"></script>
        <script type="text/javascript">
        //<![CDATA[
    
        function load() {
          if (GBrowserIsCompatible()) {
            var map = new GMap2(document.getElementById("map"));
            map.addControl(new GSmallMapControl());
            map.addControl(new GMapTypeControl());
            map.setCenter(new GLatLng(29.705359, -95.504757), 13);
    
            // Creates a marker at the given point with the given number label
            function createMarker(point, label) {
              var marker = new GMarker(point);
              GEvent.addListener(marker, "click", function() {
                marker.openInfoWindowHtml("<b>Location:</b> " + label);
              });
              return marker;
            }
    
            // Download the data in data.xml and load it on the map. The format we
            // expect is:
            // <markers>
            //   <marker lat="37.441" lng="-122.141"/>
            //   <marker lat="37.322" lng="-121.213"/>
            // </markers>
            GDownloadUrl("data.xml", function(data) {
              var xml = GXml.parse(data);
              var markers = xml.documentElement.getElementsByTagName("marker");
              for (var i = 0; i < markers.length; i++) {
                var point = new GLatLng(parseFloat(markers[i].getAttribute("lat")),
                                        parseFloat(markers[i].getAttribute("lng")));
                map.addOverlay(createMarker(point, markers[i].getAttribute("lbl")));
              }
            });
          }
        }
    
        //]]>
        </script>
      </head>
      <body onload="load()" onunload="GUnload()">
        <div id="map" style="width: 500px; height: 300px"></div>
      </body>
    </html>
    Code (markup):
    <markers>
      <marker lat="29.705359" lng="-95.504757" lbl="I am here"/>
    </markers>
    Code (markup):

     
    Lost Oath, Oct 9, 2006 IP
  2. mad4

    mad4 Peon

    Messages:
    6,986
    Likes Received:
    493
    Best Answers:
    0
    Trophy Points:
    0
    #2
    It says "Location: I am here" for me. Seems to work fine. Maybe your xml file is being cached by your browser and you are seeing an old version?
     
    mad4, Oct 9, 2006 IP
    Lost Oath likes this.
  3. Lost Oath

    Lost Oath Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Indeed you right. :eek:
    Once I cleared the cash everything worked fine. Thanks.
     
    Lost Oath, Oct 9, 2006 IP
  4. mad4

    mad4 Peon

    Messages:
    6,986
    Likes Received:
    493
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Cool. Welcome to DP. :)
     
    mad4, Oct 9, 2006 IP