use*_*573 2 css api google-maps-api-3
嗨,我正在开发一个项目,需要一个特定的全屏谷歌地图坐在页眉和页脚之间.我确定答案很简单,但我想我还是会问.该项目包含一个表单,用户可以在填写地址后删除标记等,不确定是否有任何自定义可能会受到干扰或任何内容......
当我在过去使用谷歌地图API时,我通常只是将css高度更改为100%,但由于某种原因而不是更改大小,它会完全删除地图.
#map {
height:500px;
width:1200px;
}
Run Code Online (Sandbox Code Playgroud)
这是代码.
var map;
var marker;
var Longitude = -1.8822221000000354;
var Latitude = 50.72569620000001;
var zoom = 20;
var bounds = new google.maps.LatLngBounds();
var markers;
var new_marker;
var C;
var popupbubblepath = <%= this.popupbubble.ToString() %>;
var infowindow = new google.maps.InfoWindow();
var ib;
function LoadMap() {
// Create an array of styles.
var styles = [
{
stylers: [
{ saturation: -100 }, { lightness: -100 }
]
},{
featureType: "all",
elementType: "all",
}
];
// Create a new StyledMapType object, passing it the array of styles,
// as well as the name to be displayed on the map type control.
//var styledMap = new google.maps.StyledMapType(styles, {name: "Styled Map"});
var myOptions = {
zoom: zoom,
center: new google.maps.LatLng(Latitude, Longitude),
mapTypeControl: false,
scaleControl: false,
streetViewControl: true,
overviewMapControl: false,
zoomControl: true,
mapTypeControlOptions: {
style:google.maps.MapTypeControlStyle.DROPDOWN_MENU,
position:google.maps.ControlPosition.LEFT_BOTTOM
},
zoomControlOptions: {
style: google.maps.ZoomControlStyle.SMALL
},
panControl: false,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
map = new google.maps.Map(document.getElementById("map"), myOptions);
Run Code Online (Sandbox Code Playgroud)
在这里查看http://alistapart.com/article/conflictingabsolutess使用绝对定位设置顶部,左侧,底部,右侧vaules.
#map-canvas{
position: absolute;
top: 100px;
left: 0;
bottom: 100px;
right: 0;
}
Run Code Online (Sandbox Code Playgroud)
现在将窗口拖到您的心脏内容,并观看您的地图保持全尺寸.做响应式设计时也很棒.