admin管理员组文章数量:1414628
I've got problem with leaflet map plugin and simple crs. When I was starting to play with it, I used default CRS and zoom levels 0-6, it worked fine. But I need to use pixel coordinates, not geographical, so I switched to Simple CRS which is exactly for that kind of situation, but then my map wouldn't show up and it would be just blank page. I googled something, didn't find a solution, but noticed, that others are using max zoom = 20 instead of min zoom = 0 as their starting point. So I switched my map to zoom levels 16-20 (I scrached some lowest zoom levels at that point). This got my map working until i zoomed in. Zoom levels 16, 17 and 18 work just fine, but level 19 is just blured 18 and 20 is blank. When inspecting network traffic, I found out that tiles for zoom levels 19 and 20 are not being requested. Moving two levels up gives me just blank map as with zoom levels 0-6. Also, when using zoom level 0-20, zoom levels 0-10 are not being requested too.
Secondary problem I have, is that the map won't let me zoom in on its right side, it keeps bouncing to the left.
I tested this in chrome and firefox, didn't bother with IE because its private pet project and I'm never gonna use it in IE.
Whole map can be seen here /
'use strict';
var map = L.map('map', {
minZoom: 16,
maxZoom: 20,
maxNativeZoom: 20,
continuousWorld: true,
reuseTiles: true,
// noWrap: false,
crs: L.CRS.Simple,
});
map.setView([0, 0], 18);
var southWest = map.unproject([0, 16384], map.getMaxZoom());
var northEast = map.unproject([12288, 0], map.getMaxZoom());
map.setMaxBounds(new L.LatLngBounds(southWest, northEast));
L.tileLayer('?img&z={z}&x={x}&y={y}', {
attribution: 'Map data © ???',
}).addTo(map);
var m = {
x: 200,
y: 400
}
var m2 = {
x: 16000,
y: 12000
}
var marker = L.marker(map.unproject([m.x, m.y], map.getMaxZoom())).addTo(map);
var marker = L.marker(map.unproject([m2.x, m2.y], map.getMaxZoom())).addTo(map);
map.on('click', function(event) {
console.log(event.latlng);
});
Can anyone please help me with this? Thx in advance.
I've got problem with leaflet map plugin and simple crs. When I was starting to play with it, I used default CRS and zoom levels 0-6, it worked fine. But I need to use pixel coordinates, not geographical, so I switched to Simple CRS which is exactly for that kind of situation, but then my map wouldn't show up and it would be just blank page. I googled something, didn't find a solution, but noticed, that others are using max zoom = 20 instead of min zoom = 0 as their starting point. So I switched my map to zoom levels 16-20 (I scrached some lowest zoom levels at that point). This got my map working until i zoomed in. Zoom levels 16, 17 and 18 work just fine, but level 19 is just blured 18 and 20 is blank. When inspecting network traffic, I found out that tiles for zoom levels 19 and 20 are not being requested. Moving two levels up gives me just blank map as with zoom levels 0-6. Also, when using zoom level 0-20, zoom levels 0-10 are not being requested too.
Secondary problem I have, is that the map won't let me zoom in on its right side, it keeps bouncing to the left.
I tested this in chrome and firefox, didn't bother with IE because its private pet project and I'm never gonna use it in IE.
Whole map can be seen here http://312raf./maptest/
'use strict';
var map = L.map('map', {
minZoom: 16,
maxZoom: 20,
maxNativeZoom: 20,
continuousWorld: true,
reuseTiles: true,
// noWrap: false,
crs: L.CRS.Simple,
});
map.setView([0, 0], 18);
var southWest = map.unproject([0, 16384], map.getMaxZoom());
var northEast = map.unproject([12288, 0], map.getMaxZoom());
map.setMaxBounds(new L.LatLngBounds(southWest, northEast));
L.tileLayer('?img&z={z}&x={x}&y={y}', {
attribution: 'Map data © ???',
}).addTo(map);
var m = {
x: 200,
y: 400
}
var m2 = {
x: 16000,
y: 12000
}
var marker = L.marker(map.unproject([m.x, m.y], map.getMaxZoom())).addTo(map);
var marker = L.marker(map.unproject([m2.x, m2.y], map.getMaxZoom())).addTo(map);
map.on('click', function(event) {
console.log(event.latlng);
});
Can anyone please help me with this? Thx in advance.
Share Improve this question asked Jun 4, 2014 at 6:24 sparklossparklos 4624 silver badges10 bronze badges1 Answer
Reset to default 6Ok, so apparently you need to provide minZoom, maxZoom and other params (continuousWorld, noWrap) to tile layer as well, then it works fine
本文标签: javascriptLeaflet Simple CRSStack Overflow
版权声明:本文标题:javascript - Leaflet Simple CRS - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745176707a2646272.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论