【发布时间】:2015-10-07 01:28:40
【问题描述】:
我需要使用 Bootstrap 框架将 Google 地图 DIV 放入另一个 DIV。
但是我的代码不能正常工作。 Google Maps DIV 不在框架内(灰色框架)。
您建议进行哪些调整?任何建议将不胜感激。
下面是代码:
sn-p HTML(使用 Bootstrap 框架):
<div class="thumbnail">
<img src="images/title2015.jpg" class="img-responsive">
<div class="caption">
<h4><span class="glyphicon glyphicon-map-marker"></span> Google Maps:</h4>
<div id="map_canvas" name="map_canvas"></div>
</div>
</div>
CSS:
#map_canvas{
width: 100%;
height: 260px;
float: left;
position: relative;
background-color: #f0f0f0;
overflow: hidden;
-webkit-transform: translateZ(0);
}
Javascript:
<script>
function initialize() {
var map_canvas = document.getElementById('map_canvas');
var myLatLng = new google.maps.LatLng(??.??????, ??.??????);
var map_options = {
center: myLatLng,
zoom: 16,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(map_canvas, map_options);
var marker = new google.maps.Marker({
position: myLatLng,
map: map,
title: 'Localization'
});
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
【问题讨论】:
标签: jquery html css twitter-bootstrap google-maps