谷歌地图 api v3 导航控制 css

发布于 2024-10-10 05:38:41 字数 81 浏览 0 评论 0原文

是否可以使用CSS更改Google地图API v3的navigationControl的位置?

我从谷歌搜索中找不到任何有用的信息。

Is this possible to change the location of navigationControl of Google map API v3 by using CSS?

I couldn't find any useful from google search.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

烟酉 2024-10-17 05:38:41

设置默认控件(例如 navigationControl)位置的推荐方法是使用 javascript 和 ControlPosition,您可以阅读有关 此处

The recommended way to set the locations of the default controls (such as the navigationControl) is using javascript and the ControlPosition which you can read about here.

伴随着你 2024-10-17 05:38:41

不,这是不可能的,或者至少非常困难,因为导航控件没有 id 或类名。

但是您可以通过插入一个“不可见”div 来“推动”该控件,如下所示:


var latlng = new google.maps.LatLng(-34.397, 150.644);
var myOptions = {
    zoom: 8,
    center: latlng,
    mapTypeId: google.maps.MapTypeId.ROADMAP,
    navigationControlOptions: {
        position: google.maps.ControlPosition.RIGHT_CENTER
    }
};
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

var pushDiv = document.createElement('div');
pushDiv.style.height = '250px';
map.controls[google.maps.ControlPosition.RIGHT_CENTER].push(pushDiv);

这里我将导航控件推向更接近顶部的位置。

No its not possible, or at least very difficult, because the navigation controls dont have an id or a class name.

But you can "push" the control by inserting an "invisible" div like this:


var latlng = new google.maps.LatLng(-34.397, 150.644);
var myOptions = {
    zoom: 8,
    center: latlng,
    mapTypeId: google.maps.MapTypeId.ROADMAP,
    navigationControlOptions: {
        position: google.maps.ControlPosition.RIGHT_CENTER
    }
};
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

var pushDiv = document.createElement('div');
pushDiv.style.height = '250px';
map.controls[google.maps.ControlPosition.RIGHT_CENTER].push(pushDiv);

Here I push the navigation control closer to the top.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文