In a leaflet map that uses EPSG 25831 to get WMS request, it works fine to call to "project" function to get UTM coordinates of one coordinates pair that I got from the map in WGS84, but inverse function to "unproject" a pair of coordinates in UTM in order to get this equivalent in WGS84 doesn't work.
The console message is "unproject is not a function"
The example code:
var crs = new L.Proj.CRS('EPSG:25831',
'+proj=utm +zone=31 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs',
{
resolutions: [2000, 1100, 550, 275, 100, 50, 25, 10, 5, 2, 1, 0.5, 0.25]//,
//origin: [0, 0]
}),
map = new L.Map('map', {
crs: crs,
continuousWorld: true
});
L.tileLayer.wms("http://server/service?", {
layers: 'topographic',
format: 'image/png',
transparent: true,
continuousWorld: true
}).addTo(map);
map.setView([41.3, 1], 6);
// UTM to 4326
var point = L.point(4651000,400000);
var newPoint = crs.unproject(point);
console.info(newPoint);
In the other hand, "project" function, works fine:
var testPoint = new L.latLng(42.12, 1);
var geo_point = crs.project(testPoint);
console.info(geo_point);
Versions used are, Leaflet: 0.7.7, proj4leaflet: 0.7.2, proj4: I don't know, it was at the Proj4Leaflet-0.7.2.zip from: github.com/kartena/Proj4Leaflet/releases
Any suggestion?
Best Answer
Finnally a collegue has found the solution. "project" and "unproject" functions are inside a L.Proj.Projection object, so to call unproject, the right way is:
crs.projection.unproject(point);