3

我的 html 页面中有一个谷歌地图:

<div class="row">
        <div class="span6">
          <div id="map_canvas"></div>
        </div>
        <div class="span6">
          <h3>Heading</h3>
          <p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui. </p>
          <p><a class="btn" href="#">View details &raquo;</a></p>
       </div>

我的 javascript 地图设置:

 var settingsItemsMap = {
    zoom: 11,
    center: new google.maps.LatLng(51.056703, 3.719999),
    zoomControlOptions: {
      style: google.maps.ZoomControlStyle.LARGE
    },
    mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById('map_canvas'), settingsItemsMap );

我知道我必须将其添加到我的 css 文件中:

#map_canvas img{
  max-width: none;
}

但是我还是什么都没显示!我错过了什么吗?

4

1 回答 1

6
$(window).resize(function () {
    var h = $(window).height(),
        offsetTop = 190; // Calculate the top offset

    $('#map_canvas').css('height', (h - offsetTop));
}).resize();

这对我有用!

于 2013-01-14T22:45:29.717 回答