Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Map Infowindow not showing properly

The infowindow is not showing properly on my map when clicking on a marker. The website is here.

You'll also notice the map control isn't properly displayed either.

    var map;     var locations = <?php print json_encode(di_get_locations()); ?>;     var markers = []     jQuery(function($){         var options = {             center: new google.maps.LatLng(51.840639771473, 5.8587418730469),             zoom: 8,             mapTypeId: google.maps.MapTypeId.ROADMAP         };         map = new google.maps.Map(document.getElementById("map_canvas"), options);          for (var i=0; i < locations.length;i++) {             makeMarker(locations[i]);         }         centerMap();      });     function makeMarker(location) {         var markerOptions = {map: map, position: new google.maps.LatLng(location.lat, location.lng)};         var marker = new google.maps.Marker(markerOptions);         markers.push(marker);         var content = '';          var infowindow = new google.maps.InfoWindow(           { content: "test",             size: new google.maps.Size(50,50),             disableAutoPan : true           });           google.maps.event.addListener(marker, 'click', function(e) {             infowindow.open(map,marker);         });     }     function centerMap() {       map.setCenter(markers[markers.length-1].getPosition());     } 

Note: I'm using Google Maps JS V3.

like image 824
Jjj Avatar asked Mar 12 '12 07:03

Jjj


People also ask

How do I change the width of InfoWindow on Google Maps?

maps. InfoWindow({ content: some_text, maxWidth: 200 }); The documentation notes that the "value is only considered if it is set before a call to open. To change the maximum width when changing content, call close, setOptions, and then open."

What is InfoWindow in Google Map?

An InfoWindow displays content (usually text or images) in a popup window above the map, at a given location. The info window has a content area and a tapered stem. The tip of the stem is attached to a specified location on the map. Info windows appear as a Dialog to screen readers.

How do I know if InfoWindow is open?

Calling InfoWindow. getOpenedState() returns a boolean which reflects the state (opened/closed) of the infowindow.


2 Answers

The issue is forced by this format inside style.css:

img {     height: auto;     max-width: 100%;/* <--the problem occurs here*/ } 

Add this to the end of your style.css to apply the default-value for images inside the map:

#map_canvas img{max-width:none} 
like image 140
Dr.Molle Avatar answered Sep 16 '22 11:09

Dr.Molle


The issue can be you are using img{ max-width: 100%; } as universal.

Try this one in to your css

.gmnoprint img {     max-width: none;  } 
like image 23
Mo. Avatar answered Sep 18 '22 11:09

Mo.