Google Maps: nur 1marker auf der Karte sichtbar

212N3rD

Cadet 4th Year
Registriert
Juli 2008
Beiträge
70
ich hoffe ihr könnt mir helfen:
ich habe eine xml liste mit 3 adressen.
von diesen 3 adressen werden nur 1 auf der karte angezeigt.
liegt es an der for- schleife?
kann mir jmd weiterhelfen?

HTML:
<!DOCTYPE html >
  <head>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
    <title>Jamara Stützpunkthändler-HongNor</title>
    <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
    <script type="text/javascript">
    //<![CDATA[

   

    function load() {
      var map = new google.maps.Map(document.getElementById("map"), {
        center: new google.maps.LatLng(51.165691, 10.451526000000058),
        zoom: 5,
        mapTypeId: 'roadmap'
      });
      var infoWindow = new google.maps.InfoWindow;

      // Change this depending on the name of your PHP file
      downloadUrl("phpsqlajax_genxml2_.php", function(data) {
        var xml = data.responseXML;
        var markers = xml.documentElement.getElementsByTagName("marker");
        for (var i = 0; i < markers.length; i++) {
          var name = markers[i].getAttribute("name");
          var address = markers[i].getAttribute("address");
		      var plz = markers[i].getAttribute("plz");
			      var ort = markers[i].getAttribute("ort");
				      var homepage = markers[i].getAttribute("homepage");
					    var telefon = markers[i].getAttribute("telefon");
          var type = markers[i].getAttribute("type");
          var point = new google.maps.LatLng(
              parseFloat(markers[i].getAttribute("lat")),
              parseFloat(markers[i].getAttribute("lng")));
          var html = "<b>" + name + "</b> <br/>" + address + "<br>" + plz + " " + ort + "<br>Tel. " + telefon + "<br><a target='_blank' href=http://" + homepage + ">" + homepage + "</a>";
          var icon = customIcons[type] || {};
          var marker = new google.maps.Marker({
            map: map,
            position: point,
            icon: icon.icon
          });
               bindInfoWindow(marker, map, infoWindow, html);
        }
      });
    }

    function bindInfoWindow(marker, map, infoWindow, html) {
      google.maps.event.addListener(marker, 'click', function() {
        infoWindow.setContent(html);
        infoWindow.open(map, marker);
      });
    }

    function downloadUrl(url, callback) {
      var request = window.ActiveXObject ?
          new ActiveXObject('Microsoft.XMLHTTP') :
          new XMLHttpRequest;

      request.onreadystatechange = function() {
        if (request.readyState == 4) {
          request.onreadystatechange = doNothing;
          callback(request, request.status);
        }
      };

      request.open('GET', url, true);
      request.send(null);
    }

    function doNothing() {}

    //]]>

  </script>

  </head>

  <body onload="load()">
    <div id="map" style="width: 800px; height: 500px"></div>
  </body>

</html>
 
Versuchs mal
Zeile 37-42 ersetzen durch:

bindInfoWindow(new google.maps.Marker({map: map, position: point, icon: icon.icon}), map, infoWindow, html);
 
Zurück
Oben