Note that there are some explanatory texts on larger screens.

plurals
  1. POGet Google Maps v3 to resize height of InfoWindow
    primarykey
    data
    text
    <p>When I click a marker and the InfoWindow appears, the height does not adjust if the length of the content is longer that the InfoWindow default height (90px). </p> <ul> <li>I am using text-only, no images.</li> <li>I have tried maxWidth.</li> <li>I have checked for inherited CSS.</li> <li>I have wrapped my content in a div and applied my CSS to that, including a height.</li> <li>I have even tried forcing the InfoWindow to resize with jQuery using the domready event on the InfoWindow.</li> </ul> <p>I only have a few hairs left. Here is my JS:</p> <pre><code>var geocoder; var map; var marker; function initialize() { geocoder = new google.maps.Geocoder(); var latlng = new google.maps.LatLng(41.8801,-87.6272); var myOptions = { zoom: 13, center: latlng, mapTypeId: google.maps.MapTypeId.ROADMAP }; map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); } function codeAddress(infotext,address) { geocoder.geocode({ 'address': address }, function (results, status) { if (status == google.maps.GeocoderStatus.OK) { map.setCenter(results[0].geometry.location); var image = '/path-to/mapMarker.png'; var infowindow = new google.maps.InfoWindow({ content: infotext, maxWidth: 200 }); var marker = new google.maps.Marker({ map: map, position: results[0].geometry.location, icon: image }); google.maps.event.addListener(marker, 'click', function () { infowindow.open(map, marker); }); } }); } function checkZipcode(reqZip) { if ( /[0-9]{5}/.test(reqZip) ) { $.ajax({ url: 'data.aspx?zip=' + reqZip, dataType: 'json', success: function(results) { $.each(results.products.product, function() { var display = "&lt;span id='bubble-marker'&gt;&lt;strong&gt;"+this.name+"&lt;/strong&gt;&lt;br&gt;"+ this.address+"&lt;br&gt;"+ this.city+", "+this.state+" "+this.zip+"&lt;br&gt;"+ this.phone+"&lt;/span&gt;"; var address = this.address+","+ this.city+","+ this.state+","+ this.zip; codeAddress(display,address); }); }, error: function() { $('#information-bar').text('fail'); } }); } else { $('#information-bar').text('Zip codes are five digit numbers.'); } } $('#check-zip').click(function() { $('#information-bar').text(''); checkZipcode($('#requested-zipcode').val()); }); initialize(); </code></pre> <p>InfoText and Address come from an AJAX query of an XML file. Data is not the issue, as it always comes through correctly. codeAddress() is called after the data has been retrieved and formatted.</p> <p>HTML in the file:</p> <pre><code>&lt;div id="google_map"&gt; &lt;div id="map_canvas" style="width:279px; height:178px"&gt;&lt;/div&gt; &lt;/div&gt; </code></pre> <p>CSS for my InfoWindow content (no other CSS applies to the map):</p> <pre><code>#bubble-marker{ font-size:11px; line-height:15px; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload