Skip to content Skip to sidebar Skip to footer

Leaflet Latlngbounds With Simpler Crs & Projection

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 s

Solution 1:

EDIT:

It sounds like Leaflet internally assumes that y points increase when going down (like in images), and it should be the opposite for latitude (i.e. decrease when going down), as the min, max, <= and >= comparisons are hard-coded.

So there is probably no possibility to make up a CRS that will give you a latitude in the same direction as the Y points. Except if you are ready to modify every function that compares latitudes within Leaflet library…

You may still be able to "manipulate" numbers like you wish, if you use an intermediate conversion function every time you have to provide coordinates, and the opposite when you have to read coordinates.

That would also give you the opportunity to revert the latitude (y) and longitude (x) order to be [x, y].

For example:

functionrevertLat(x, y) {
  return [-y, x];
}

Demo: http://jsfiddle.net/ve2huzxw/101/


Original answer:

Any reason for not directly customizing L.LatLngBounds as well, so that it fits your need?

First of all, if you do not exactly need southWest and northEast, but just corners for your bounds, you can use L.LatLngBounds as is. For instance, all Leaflet methods would keep working even if the corners are not exactly southWest and northEast: map.fitBounds, L.imageOverlay etc. should work fine.

Otherwise, you would have to customize many methods in L.LatLngBounds (extend, pad, contains, intersects) to revert the min / max and <= / >= comparisons.

Post a Comment for "Leaflet Latlngbounds With Simpler Crs & Projection"