I'm using Leaflet 0.7.7, latest stable release, and I'm using a custom CRS inherited from L.CRS.Simple
.
CRS:
It is very similar to Simple CRS but with c
set to 1
(in Simple, c
is set to -1
).
L.CRS.XY = L.Util.extend({}, L.CRS.Simple, {
code: 'XY',
projection: L.Projection.LonLat,
transformation: new L.Transformation(1, 0, 1, 0)
});
The goal of this CRS is to have a real {x, y}
map system where y
becomes higher when reaching the bottom of the map (like a bitmap).
Code to test:
var southWest = L.latLng(133, 0);
var northEast = L.latLng(0, 170);
var bounds = L.latLngBounds(southWest, northEast);
document._map.setMaxBounds(bounds);
document._map.fitBounds(bounds);
document._markers[68].setLatLng(bounds.getNorthEast());
console.info('southWest', southWest);
// L.LatLng {lat: 133, lng: 0}
console.info('northEast', northEast);
// L.LatLng {lat: 0, lng: 170}
console.info('bounds', bounds);
// L.LatLngBounds (
_northEast: L.LatLng {lat: 133, lng: 170 }
_southWest: L.LatLng {lat: 0, lng: 0 }
)
Actually, as I have a custom CRS, I think these lines are the source of the problem because maximum and minimum values are not correct in a plane {x, y}
system (even if I would prefer to use "Point" but I can only use "LatLng" objects :confused: ).
So actually, it seems it is obvious that this issue comes from my code, but actually I'd like to find a solution for this that wouldn't need me to switch to L.CRS.Simple
in which y
coordinates get higher on top of the map.
So what's the solution to use bounds with this simple custom projection?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…