gpt4 book ai didi

javascript - 更改默认的 Google Maps Api 默认缩放控件图像?

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:06:05 25 4
gpt4 key购买 nike

您能否更改 Google Maps Api 缩放控件的默认图像以便创建我自己的图像?

最佳答案

不可以,您不能将缩放控件的图像更改为 Google 提供的三个选项以外的任何其他选项:

The Zoom control may appear in one of the following style options:

google.maps.ZoomControlStyle.SMALL displays a mini-zoom control, consisting of only + and - buttons. This style is appropriate for small maps. On touch devices, this control displays as + and - buttons that are responsive to touch events.

google.maps.ZoomControlStyle.LARGE displays the standard zoom slider control. On touch devices, this control displays as + and - buttons that are responsive to touch events.

google.maps.ZoomControlStyle.DEFAULT picks an appropriate zoom control based on the map's size and the device on which the map is running.

但是您可以构建 custom controls并将它们放在 map 上。您将必须设置适当的事件处理程序并管理控件的状态,但这是可以做到的。

slider 控件可能有点棘手,但如果您只想放大和缩小按钮,则无需管理状态即可。

事件看起来类似于:

//zoom in control click event
google.maps.event.addDomListener(zoomIn, 'click', function() {
var currentZoomLevel = map.getZoom();
if(currentZoomLevel != 21){
map.setZoom(currentZoomLevel + 1);
}
});

//zoom out control click event
google.maps.event.addDomListener(zoomOut, 'click', function() {
var currentZoomLevel = map.getZoom();
if(currentZoomLevel != 0){
map.setZoom(currentZoomLevel - 1);
}
});

关于javascript - 更改默认的 Google Maps Api 默认缩放控件图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7838982/

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