gpt4 book ai didi

leaflet - 如何将缩放控件放置在右下角?

转载 作者:行者123 更新时间:2023-12-03 09:00:33 25 4
gpt4 key购买 nike

我正在使用 ngx-leaflet。默认情况下, map 在左上角显示缩放控件。但是我找不到如何改变它的定位。

这是一个过时的方法:

options = {
layers: L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { maxZoom: 10, attribution: '...' }),
zoom: 5,
zoomControl: false,
center: L.latLng(46.879966, -121.726909)
};

mapReady(map: L.Map) {
map.addControl(L.control.zoom({ position: 'bottomright' }));
}

.

<div class="leaflet-container grow z-0" leaflet [leafletZoom]="leafletZoom" [leafletCenter]="leafletCenter" (leafletMapReady)="($event)">
<div [leafletLayer]="tileLayer"></div>
<div *ngFor="let marker of markerLayers " [leafletLayer]="marker"></div>
</div>

source

是否有更新的方法可以使用最新版本的 ngx-leaflet (3.0) 来执行此操作?

这是一个屏幕截图,显示控制对象上没有缩放方法: enter image description here

最佳答案

由于您使用的是直接导入,因此您需要执行以下操作:

import { control, Map, latLng, tileLayer } from 'leaflet';

options = {
layers: tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { maxZoom: 10, attribution: '...' }),
zoom: 5,
zoomControl: false,
center: latLng(46.879966, -121.726909)
};

mapReady(map: Map) {
map.addControl(control.zoom({ position: 'bottomright' }));
}

关于leaflet - 如何将缩放控件放置在右下角?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50849035/

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