gpt4 book ai didi

javascript - 如何让谷歌地图使用 100% 的父容器?

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:20:09 24 4
gpt4 key购买 nike

我尝试过以多种不同的方式做到这一点,但最明显的是:

var map2 = new GMap2(document.getElementById("map2"), {size:"100%"});

那是行不通的。

最佳答案

Google says :

Unless you specify a size explicitly for the map using GMapOptions in the constructor, the map implicitly uses the size of the container to size itself.

所以设置你的 map 容器的大小填满所有可用空间:

<div id="map2" style="width: 100%; height: 100%"></div>

关于javascript - 如何让谷歌地图使用 100% 的父容器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1197444/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com