kartena / Proj4Leaflet

Smooth Proj4js integration with Leaflet.
http://kartena.github.io/Proj4Leaflet/
BSD 2-Clause "Simplified" License
589 stars 173 forks source link

How to use EPSG:2169 with Leaflet #169

Open jcb81 opened 4 years ago

jcb81 commented 4 years ago

Hello all,

I'm trying to use Leaflet with a specific projection EPSG:2169 (Luref, or Luxembourg). I saw that if I don't use a "standard" projection like WGS84, I have to use Proj4Leaflet and reference it to the map.

That's what I did for now :

this.crs = new L.Proj.CRS('EPSG:2169',
'+proj=tmerc +lat_0=49.83333333333334 +lon_0=6.166666666666667 +k=1 +x_0=80000 +y_0=100000 +ellps=intl +towgs84=-189.681,18.3463,-42.7695,-0.33746,-3.09264,2.53861,0.4598 +units=m +no_defs');

this.map = L.map('map', {
  center: [ 74000, 96000 ],
  zoom: 3,
  crs: this.crs,
});

When I load the page with the map, the console gives me these errors :

Cannot read property '3' of undefined
Cannot read property 'x' of undefined

After some Googling, I found that I have to define "resolutions" option. I don't know exactly how it is used, but I took from a sample and here is now how looks the CRS :

this.crs = new L.Proj.CRS('EPSG:2169',
'+proj=tmerc +lat_0=49.83333333333334 +lon_0=6.166666666666667 +k=1 +x_0=80000 +y_0=100000 +ellps=intl +towgs84=-189.681,18.3463,-42.7695,-0.33746,-3.09264,2.53861,0.4598 +units=m +no_defs',
{
  resolutions: [8192, 4096, 2048, 1024, 512, 256, 128]
});

Now when the map is loaded, I have this error in console :

TypeError: coordinates must be finite numbers

And now I don't know what to do next. Anyone here already had this kind of issue ?

Many thanks in advance.

MarciaBM commented 3 months ago

I have the same error with the EPSG:3763 projection, any news about this?