0

所以这些谷歌地图工作正常,然后突然就不行了。我所做的唯一更改是为标记上传新图像。经过检查,我可以看到新标记正在正确加载,并且控制台没有产生错误(Chrome 和 FF)。我试过在真假之间翻转传感器,也没有运气。当我删除传感器属性时,它会退回需要它的标准警报错误。

我错过了一些简单的东西吗?

<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>
4

1 回答 1

2

虽然地图默认为 100% 宽度,但您需要为包含的 div 设置高度。例如,这将解决您的问题:

<div id="map_canvas" style="height:400px;"></div>
于 2012-07-25T23:34:16.763 回答