【发布时间】:2016-07-13 12:19:57
【问题描述】:
我正在尝试使用该地点的平面图像制作配送中心地图。我需要能够放大和缩小以保持良好的图像质量。到目前为止,我一直在使用 Leaflet 来绘制 Map 和 MapTiler 来创建一个平铺模式,该模式可以在没有任何质量损失和良好性能的情况下进行缩放。
我已经完成了所有设置并且可以正常工作,但是我需要我的 Tile Layer 中心与地图中心相匹配。无论我做什么,Tile Layer 的左上角总是从地图的 (0,0) 坐标开始。
例如,在缩放级别 3 下,我的图像是 1536x1280 像素,因此在谈论绝对像素坐标时,左上角应该位于地图的坐标 (-768,640)。
这是我的主要脚本:
var map = L.map('map',{
crs: L.CRS.Simple,
center:[0,0]
}).setView([0,0],3);
//mapHeight and mapWidth are the pixel dimensions of the flat image at max zoom level.
//In this case it's 6144x4608px. By default the tiles size is 256x256px.
var southWest = map.unproject([ 0, mapHeight], getMaxZoom());
var northEast = map.unproject([ mapWidth, 0 ], getMaxZoom());
var mapBounds = new L.LatLngBounds(southWest, northEast);
L.tileLayer('tile/{z}/{x}/{y}.png',{
minZoom: 2,
maxZoom: 5,
noWrap:true,
bounds:mapBounds
}).addTo(map);
我弄乱了中心、setView 和边界,但没有成功让 Tile Layer 移动。
Leaflet 的文档可以在这里找到http://leafletjs.com/reference.html
如果可以,请帮助我。谢谢。
【问题讨论】:
标签: javascript jsp maps leaflet coordinates