Leaflet LatLngBounds with simpler CRS & projection

后端 未结 1 1288
眼角桃花
眼角桃花 2020-12-12 06:51

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 simil

相关标签:
1条回答
  • 2020-12-12 07:29

    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:

    function revertLat(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.

    0 讨论(0)
提交回复
热议问题