小编EdL*_*ner的帖子

获取Google Maps v3以调整InfoWindow的高度

当我单击标记并显示InfoWindow时,如果内容的长度超过InfoWindow默认高度(90px),则不会调整高度.

  • 我使用纯文字,没有图像.
  • 我试过maxWidth.
  • 我检查了继承的CSS.
  • 我已经将我的内容包装在一个div中并将我的CSS应用到包含高度的CSS中.
  • 我甚至尝试使用InfoWindow上的domready事件强制InfoWindow使用jQuery调整大小.

我只剩下几根头发.这是我的JS:

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, …
Run Code Online (Sandbox Code Playgroud)

infowindow google-maps-api-3

16
推荐指数
2
解决办法
2万
查看次数

标签 统计

google-maps-api-3 ×1

infowindow ×1