I'm currently trying to display a dataset on a webapp using Leaflet. All the dataset is projected into French projection Lambert II ESPG 27572.

Instead of converting coordinates, I'm trying to setup Leaflet with this ESPG:27572. I gave it a first try using proj4leaflet :

var crs = new L.Proj.CRS('ESPG:27572',
    '+proj=lcc +lat_1=46.8 +lat_0=46.8 +lon_0=0 +k_0=0.99987742 +x_0=600000 +y_0=2200000 +a=6378249.2 +b=6356515 +towgs84=-168,-60,320,0,0,0,0 +pm=paris +units=m +no_defs',
    {
        resolutions: [
            8192, 4096, 2048, 1024, 512, 256, 128,
            64, 32, 16, 8, 4, 2, 1, 0.5
        ],
        origin: [0, 0],
        bounds: L.bounds([5168.43, 1730142.53], [1013247.20, 2698564.20])
    }),
    map = new L.Map('map', {
        crs: crs,
    });

L.tileLayer('https://api.geosition.com/tile/osm-bright-3006/{z}/{x}/{y}.png', {
    maxZoom: 14,
    minZoom: 0,
    attribution: 'Map data &copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap contributors</a>, Imagery &copy; <a href="http://www.kartena.se/">Kartena</a>'
}).addTo(map);

map.setView([0,0], 2);

It returns a white map with no console message. Commenting the bounds line "did the trick", except the map is centered on South Africa instead of France.

//bounds: L.bounds([5168.43, 1730142.53], [1013247.20, 2698564.20])

I think that I'm not far from the solution, as when I insert a marker which is supposed to be in France :

L.marker([656513, 2626522]).addTo(map);

I'm getting the marker, in the sea near South Africa, but correctly positionned if France was over South Africa.

Expectation : enter image description here

Result : enter image description here

  • The map you are using in your tile layer description is Swedish SWEREF99 EPSG 3006 (epsg.io/3006) , not French EPSG 27572 (epsg.io/27572). – TomazicM Nov 17 at 18:20
  • @TomazicM that's true but it shouldn't bother us as long as this is only background tiles right ? – Vincent Monteil Nov 20 at 9:19
  • See my answer below. – TomazicM Nov 23 at 20:57
  • Thanks @TomazicM I wasn't notified :) – Vincent Monteil Nov 26 at 13:26
up vote 0 down vote accepted

With proj4leaflet plugin you only tell Leaflet what is the actual projection of your tile layer when it differs from the standard EPSG 3857. There is no way in Leaflet to transform tile layer to another CRS on the fly. This is expensive operation even for servers.

In your example tile layer is EPSG 3006. You cannot trasform it to EPSG 27572, so you'll have to transform you dataset.

Besides that you tile layer is for Sweden (http://epsg.io/3006) and is so even in the case of data transformation useles for data intended for France.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.