gpt4 book ai didi

r - 传单setView缩放级别为R中的非整数(十进制)值?

转载 作者:行者123 更新时间:2023-12-04 15:31:15 26 4
gpt4 key购买 nike

使用 leaflet R 包,有没有办法将 zoom 设置为非整数(即十进制)值?

也就是说,介于这两个缩放级别之间:

enter image description here

例子

随着 zoom 从第 3 级移动到第 4 级,它看起来好像正在四舍五入到最接近的整数

下面唯一改变的是zoom参数

library(leaflet)
library(dplyr)

leaflet() %>%
addTiles() %>%
setView(lng=174.768, lat=-36.852, zoom = 3) %>%
addMarkers(lng=174.768, lat=-36.852, popup="The birthplace of R")


leaflet() %>%
addTiles() %>%
setView(lng=174.768, lat=-36.852, zoom = 3.2) %>%
addMarkers(lng=174.768, lat=-36.852, popup="The birthplace of R")

leaflet() %>%
addTiles() %>%
setView(lng=174.768, lat=-36.852, zoom = 3.4) %>%
addMarkers(lng=174.768, lat=-36.852, popup="The birthplace of R")

leaflet() %>%
addTiles() %>%
setView(lng=174.768, lat=-36.852, zoom = 3.6) %>%
addMarkers(lng=174.768, lat=-36.852, popup="The birthplace of R")


leaflet() %>%
addTiles() %>%
setView(lng=174.768, lat=-36.852, zoom = 3.8) %>%
addMarkers(lng=174.768, lat=-36.852, popup="The birthplace of R")


leaflet() %>%
addTiles() %>%
setView(lng=174.768, lat=-36.852, zoom = 4) %>%
addMarkers(lng=174.768, lat=-36.852, popup="The birthplace of R")

问题

有没有办法设置非整数(小数)缩放?

注意 ?setView 导致 zoom pan options ,返回 404

最佳答案

你需要分数缩放:

var map = L.map('map', {zoomSnap: 0.25});

这里有更多关于它的信息: https://leafletjs.com/examples/zoom-levels/

我在我的一张 map 上使用它是这样的:

var map = L.map('map', {attributionControl: false, crs: L.CRS.Simple, zoomSnap: 0.25, minZoom: -3});

...

map.setView(xy(<%= @image.width.to_i/2 %>, <%= @image.height.to_i/2 %>), -1.5);

关于r - 传单setView缩放级别为R中的非整数(十进制)值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61233935/

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