How to use Proj4Leaflet for custom projections
masterProj4Leaflet allows you to use any projection supported by Proj4js within a Leaflet map. This is achieved by creating a new L.Proj.CRS instance and passing it to the Leaflet map options. This enables support for custom tile layers, GeoJSON in non-WGS84 projections, and image overlays using projected coordinates.
// RT90 with map's pixel origin at RT90 coordinate (0, 0)
var crs = new L.Proj.CRS('EPSG:2400',
'+lon_0=15.808277777799999 +lat_0=0.0 +k=1.0 +x_0=1500000.0 ' +
'+y_0=0.0 +proj=tmerc +ellps=bessel +units=m ' +
'+towgs84=414.1,41.3,603.1,-0.855,2.141,-7.023,0 +no_defs',
{
resolutions: [8192, 4096, 2048] // 3 example zoom level resolutions
}
);
var map = L.map('map', {
crs: crs,
continuousWorld: true,
worldCopyJump: false
});
L.tileLayer('http://tile.example.com/example/{z}/{x}/{y}.png').addTo(map);