Google maps not showing up

烂漫一生 提交于 2019-12-23 07:27:51

问题


I have a written a simple code which would display the location on the google map. But for some reasons its not showing up. Any idea whats happening?

<html>
<head>
<title>Google Maps </title>
<script type="text/javascript" 
src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
(function() {
   window.onload = function(){
   var latlng = new google.maps.LatLng(57.8, 14.0);
   var options = {
      zoom: 6,
      center: latlng,
      mapTypeId: google.maps.MapTypeId.ROADMAP
        }; 
  var map = new google.maps.Map(document.getElementById('map'), options);
        }
    })();
</script>
</head>
<body>
<div id="map"></div>
</body>
</html>

回答1:


You need to set dimensions for your map container, try this:

<style type="text/css">
     #map {
        width: 500px;
        height: 500px;
      }
    </style>


来源:https://stackoverflow.com/questions/7419280/google-maps-not-showing-up

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!