传单:图像叠加和缩放级别
Leaflet: Image Overlay and zoom levels
我在我的地图中添加了图像(图像叠加层)。我可以 "adjust" 缩放级别吗?
在缩放级别 17 时,栅格地图的分辨率与屏幕分辨率相比太低。在缩放级别 16 时,栅格地图不再可读。
是否可以定义类似 "zoomlevel 17: 1px of the image = 1px of the screen" 的内容?
请原谅我蹩脚的英语。
非常感谢!
var map = L.map('image-map', {
minZoom: 16,
maxZoom: 18,
}).setView([46.975768, 7.436308], 17);
var imageUrl = '../Bilder/Karten/Normalansicht.png',
imageBounds = [[46.966635, 7.415942], [46.998849, 7.470108]];
L.imageOverlay(imageUrl, imageBounds).addTo(map);
map.setMaxBounds(imageBounds);
Is it possible to define something like "zoomlevel 17: 1px of the
image = 1px of the screen"?
没有
但是,您 可以 做的是使用 CRS.Simple
。在此坐标系中,缩放级别 0 时 1 个地图单位 = 1px。您必须调整图像叠加坐标以达到您想要的屏幕 resolution/image 分辨率。
在 http://leafletjs.com/examples/crs-simple/crs-simple.html
查看 CRS.Simple 上的教程
另一种选择是使用分数缩放控件(仅在 Leaflet 1.0.0-beta 中可用,在 0.7.x 系列中不可用)。通过设置 zoomSnap
和 zoomDelta
选项,用户将能够设置缩放级别,例如16.25、16.5 和 16.75。
没有这方面的教程,但您可以在 https://github.com/Leaflet/Leaflet/blob/master/debug/map/zoom-delta.html
查看一些测试代码
我在我的地图中添加了图像(图像叠加层)。我可以 "adjust" 缩放级别吗?
在缩放级别 17 时,栅格地图的分辨率与屏幕分辨率相比太低。在缩放级别 16 时,栅格地图不再可读。
是否可以定义类似 "zoomlevel 17: 1px of the image = 1px of the screen" 的内容?
请原谅我蹩脚的英语。 非常感谢!
var map = L.map('image-map', {
minZoom: 16,
maxZoom: 18,
}).setView([46.975768, 7.436308], 17);
var imageUrl = '../Bilder/Karten/Normalansicht.png',
imageBounds = [[46.966635, 7.415942], [46.998849, 7.470108]];
L.imageOverlay(imageUrl, imageBounds).addTo(map);
map.setMaxBounds(imageBounds);
Is it possible to define something like "zoomlevel 17: 1px of the image = 1px of the screen"?
没有
但是,您 可以 做的是使用 CRS.Simple
。在此坐标系中,缩放级别 0 时 1 个地图单位 = 1px。您必须调整图像叠加坐标以达到您想要的屏幕 resolution/image 分辨率。
在 http://leafletjs.com/examples/crs-simple/crs-simple.html
查看 CRS.Simple 上的教程另一种选择是使用分数缩放控件(仅在 Leaflet 1.0.0-beta 中可用,在 0.7.x 系列中不可用)。通过设置 zoomSnap
和 zoomDelta
选项,用户将能够设置缩放级别,例如16.25、16.5 和 16.75。
没有这方面的教程,但您可以在 https://github.com/Leaflet/Leaflet/blob/master/debug/map/zoom-delta.html
查看一些测试代码