css - google maps api全屏

标签 css api google-maps-api-3

您好,我正在开展一个元素,该元素需要在页眉和页脚之间放置一个特定的全屏谷歌地图。我敢肯定答案很简单,但我还是想问一下。该元素包含一个表单,用户可以在填写地址等后放置标记,不确定是否有任何自定义可能会干扰或任何...

过去,当我使用 google map API 时,我通常只是将 css 高度更改为 100%,但出于某种原因,它没有更改大小,而是完全删除了 map 。

#map {
height:500px;
width:1200px;
}

这是代码。

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);

最佳答案

看这里http://alistapart.com/article/conflictingabsolutepositions使用绝对定位设置顶部、左侧、底部、右侧值。

#map-canvas{
    position: absolute;
    top: 100px;
    left: 0;
    bottom: 100px;
    right: 0;
}

现在将您的窗口拖动到您喜欢的位置,并观察您的 map 保持完整大小。在进行响应式设计时也很棒。

关于css - google maps api全屏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17067196/

相关文章:

javascript - Ionic Serve- XMLHttpRequest 无法在浏览器上加载

css - Bootstrap 轮播使我的页脚显示在中间

javascript - 在 Grunt 中同时使用 Compass 和 Autoprefixer

html - CSS - 显示 : table leaves whitespace

javascript - 如何在 Google 地点 api 中使用附近搜索查找地点详细信息?

javascript - 使用 setTimeout() 函数对谷歌地图折线进行动画处理

javascript - 谷歌地图,加载点上的纬度/经度

javascript - jQuery 记住多个焦点事件的原始文本框值

获取剧集播出日期的API

android.content.res.Resources$NotFoundException API 级别 19