Wordpress - Multi Tag Google Maps

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • thoschu96
    New Member
    • Jul 2015
    • 5

    Wordpress - Multi Tag Google Maps

    i tried to use the multi tag function in the google maps api, but i messed it up .. it show's all "locations" but, when i click on any, it always show's the info on and from the last "location" in the Array..

    anyone know's where i messed it up ?.. i cant find it

    Code:
    <!DOCTYPE html>
    <html>
    <head>
    <script src="http://maps.googleapis.com/maps/api/js">
    </script>
    
    <script>
    var locations = [
          ["<a href='http://www.rome.de'>Rome</a>", 50.002485, 8.554255, 4],
          ["<a href='http://www.athen.de'>Athen</a>", 50.002485, 8.554255, 5],
          ['Autohaus Gotta', 49.998909, 8.588143, 3],
          ['Friedhof', 50.007880, 8.572271, 2],
          ['Gundbach', 50.002485, 8.554255, 1]
    ];
    var mapPosition =  new google.maps.LatLng(49.990594, 8.573357);
    // var myCenter=new google.maps.LatLng(50.009088, 8.578590);
    // var myCenter=new google.maps.LatLng(locations[0][1], locations[0][2]);
    var marker, i;
    function initialize() {
      var mapProp = {
        center: mapPosition,   // Die Koordinaten von Walldorf
        zoom:13,  // das Zoomlevel der Karte
        mapTypeId:google.maps.MapTypeId.HYBRID,  // GoogleMap Kartenart definieren (ROADMAP, HYBRID)
        disableDefaultUI: true  // deaktivieren die ControlPanels
      };
      var map=new google.maps.Map(document.getElementById("googleMap"),mapProp);
    for (i = 0; i < locations.length; i++) {  
    var marker=new google.maps.Marker({
      position:new google.maps.LatLng(locations[i][1], locations[i][2]),map: map,
            clickable: true,
            url: locations[i][0]
      });
    marker.setMap(map);
    var infowindow = new google.maps.InfoWindow({
      content:locations[i][0]});
    google.maps.event.addListener(marker, 'click', function() {
       infowindow.open(map,marker);})
    };
    }
    google.maps.event.addDomListener(window, 'load', initialize);
    </script>
    </head>
    
    <body>
    <div id="googleMap" style="width:500px;height:380px;"></div>
    </body>
    
    </html>
Working...