Selçuklu Ebrar
Selçuklu Ebrar

Reputation: 2269

InfoWindow with google maps api

How can I display two Infowindow on my map.

in my code I can open only one InfoWindow, but I will display at same time twoo InfoWindow on my map what can I do. my code is:

function load() {

    if (GBrowserIsCompatible()) {

        var map = new GMap2(document.getElementById("map"));
        map.setCenter(new GLatLng( 38.736946, 35.310059), 6);

        map.openInfoWindow(new GLatLng( 38.582526,  42.846680),
        document.createTextNode("Van Gölü"));
    }
}

Upvotes: 0

Views: 232

Answers (2)

Selçuklu Ebrar
Selçuklu Ebrar

Reputation: 2269

this code is working :

<!DOCTYPE html>
<html>
  <head>
    <META http-equiv=content-type content=text/html;charset=x-mac-turkish>
    <style type="text/css">
      html { height: 100% }
      body { height: 100%; margin: 0; padding: 0 }
      #map_canvas { height: 100% }
    </style>
 <script src="js/jquery.js"></script>
    <script type="text/javascript"
      src="https://maps.googleapis.com/maps/api/js?key=mykey&sensor=false">
    </script>
    <script type="text/javascript">
      var map;
function initialize() {
        var mapOptions = {
          center: new google.maps.LatLng(39.078908,35.244141),
          zoom: 6,
          mapTypeId: google.maps.MapTypeId.ROADMAP
        };
            map = new google.maps.Map(document.getElementById("map_canvas"),
            mapOptions);
    infoWindow = new google.maps.InfoWindow();
        var windowLatLng = new google.maps.LatLng(38.668356,33.376465);
        infoWindow.setOptions({
        content: "Tuz Golu",
        position: windowLatLng,
    });
    infoWindow.open(map); 

      infoWindow2 = new google.maps.InfoWindow();
        var windowLatLng2 = new google.maps.LatLng(38.565348,42.868652);
        infoWindow2.setOptions({
        content: "Van Golu",
        position: windowLatLng2,
    });
    infoWindow2.open(map);
}
</script>
  </head>
  <body onload="initialize()">
  <div id="map_canvas" style="width:65%; height:40%"></div>
</body>
</html>

Upvotes: 0

geocodezip
geocodezip

Reputation: 161324

The Google Maps API v2 native InfoWindow only supports one per map. The Google Maps API v3 removes that limitation.

Either use a custom InfoWindow or migrate your application to the Google Maps API v3.

As @duncan observed, that Google Maps API v2 has been officially deprecated as of May 19, 2010 and will not be supported after May 19, 2013. New development in that API is strongly discouraged.

Upvotes: 1

Related Questions