因此,这些谷歌地图工作正常,然后他们突然间没有。我做的唯一改变是上传标记的新图像。经过检查,我可以看到新标记正确加载,控制台不会产生任何错误(Chrome和FF)。我试过在真假之间翻转传感器,也没有运气。当我删除传感器attrib时,它踢回了需要它的标准警报错误。
我错过了一些简单的东西吗?
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?key=MYAPIKEY&sensor=false">
</script>
<script type="text/javascript">
var wildbasin = new google.maps.LatLng(30.310716, -97.824238);
var seucampus = new google.maps.LatLng(30.229723, -97.755275);
var austin = new google.maps.LatLng(30.275079, -97.792053);
var basinm = 'http://www.test.stedwards.edu/sites/default/files/wildbasinmarker_1.png';
var campusm = 'http://www.test.stedwards.edu/sites/default/files/maincampusmarker_0.png';
var map;
function initialize() {
var myOptions = {
zoom: 12,
center: austin,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById('map_canvas'), myOptions);
var campus = new google.maps.Marker({
position: seucampus,
map: map,
title:"St.Edward's University",
icon: campusm
});
var thebasin = new google.maps.Marker({
position: wildbasin,
map: map,
title:"Wild Basin",
icon:basinm
});
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
<div id="map_canvas"></div>
答案 0 :(得分:2)
虽然地图默认为100%宽度,但您需要为包含div设置高度。例如,这将解决您的问题:
<div id="map_canvas" style="height:400px;"></div>