admin管理员组文章数量:1394534
I am trying to Set the Width and the height of the google map. I want to make it larger on the html page. I am trying to change the styles but the widht and height of the maps is not changing. it seems that my styles are not affecting the map. Can anyone help me to fix the issue
Here is the code
<!DOCTYPE html>
<html ng-app="myApp">
<head>
<!-- Style Sheets includes -->
<link rel="stylesheet" href="css/bootstrap.min.css">
<style>
html, body, #map {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
#map {
position: relative;
}
</style>
<link href="css/customstyle.css" rel="stylesheet" type="text/css">
<!-- Script includes -->
<script data-require="angular.js@*" data-semver="1.3.14" src="js/angular.js"></script>
<script src="js/jquery-2.1.4.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/ui-bootstrap-tpls-0.12.0.js"></script>
<script src="#"></script>
<script src=""></script>
<script src="data.js"></script>
<script src="app.js"></script>
</head>
<body ng-controller="ApplicationController as appctrl">
<div class="container">
<div id="map" ></div>
</div>
</body>
</html>
I am trying to Set the Width and the height of the google map. I want to make it larger on the html page. I am trying to change the styles but the widht and height of the maps is not changing. it seems that my styles are not affecting the map. Can anyone help me to fix the issue
Here is the code
<!DOCTYPE html>
<html ng-app="myApp">
<head>
<!-- Style Sheets includes -->
<link rel="stylesheet" href="css/bootstrap.min.css">
<style>
html, body, #map {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
#map {
position: relative;
}
</style>
<link href="css/customstyle.css" rel="stylesheet" type="text/css">
<!-- Script includes -->
<script data-require="angular.js@*" data-semver="1.3.14" src="js/angular.js"></script>
<script src="js/jquery-2.1.4.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/ui-bootstrap-tpls-0.12.0.js"></script>
<script src="#"></script>
<script src="https://maps.googleapis./maps/api/js"></script>
<script src="data.js"></script>
<script src="app.js"></script>
</head>
<body ng-controller="ApplicationController as appctrl">
<div class="container">
<div id="map" ></div>
</div>
</body>
</html>
Share
Improve this question
asked Dec 5, 2015 at 13:21
imadfooki fookiimadfooki fooki
1872 gold badges2 silver badges9 bronze badges
2
- There is no map code in the question. – geocodezip Commented Dec 5, 2015 at 18:39
- possible duplicate of google maps height 100% of div parent – geocodezip Commented Dec 5, 2015 at 18:43
1 Answer
Reset to default 5If the div map is inside other div (eg: container) all the parent div must have an height and width setted .. in your case the
<div class="container">
is not setted
try this way
html, body, .container, #map {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
#map {
position: relative;
}
code snippet:
function initialize() {
var map = new google.maps.Map(
document.getElementById("map"), {
center: new google.maps.LatLng(37.4419, -122.1419),
zoom: 13,
mapTypeId: google.maps.MapTypeId.ROADMAP
});
}
google.maps.event.addDomListener(window, "load", initialize);
html, body, .container, #map {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
#map {
position: relative;
}
<script src="https://maps.googleapis./maps/api/js"></script>
<div class="container">
<div id="map"></div>
</div>
本文标签: javascriptWidth and height of the Google mapStack Overflow
版权声明:本文标题:javascript - Width and height of the Google map - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744100054a2590832.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论