Hello.
I have been working with the openstreetmap extension and with some minor change to code managed to apply a custom projection of a map for a limited area using proj4 and proj4leaflet.
Currently it is a bit of a hack, but could be improved by allowing us to pass an options object to the map object.
my change to code is the following
in users/extensions.php
$proj4 = array(
Extension::getBaseURL().'user/extensions/proj4leaflet/proj4.js',
Extension::getBaseURL().'user/extensions/proj4leaflet/proj4leaflet.js',
Extension::getBaseURL().'user/extensions/proj4leaflet/epsg3057crs.js'
); array_splice( $dbr_extensions['openstreetmap']['javascript'], 3, 0, $proj4);
contents of epsg3057crs.js
var crs = new L.Proj.CRS('EPSG:3057',
'+proj=lcc +lat_1=64.25 +lat_2=65.75 +lat_0=65 +lon_0=-19 +x_0=500000 +y_0=500000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs',
{
resolutions: [2048,1024,512,256,128,64,32,16,8,4,2,1,0.5,0.25,0.125,0.0625],
origin: [0, 0],
bounds: L.bounds([0, 0], [1048576, 1048576])
}
);
in extensions/openstreetmap/openstreetmap.js line 35
this.map = L.map(this.map_id, { crs: crs });
My report
select 'dbr.openstreetmap','coordinates','Test',800,600;
select 'dbr.openstreetmap.tiles','https://secret.map.domain/mapcache/tms/1.0.0/aerial@isn93/{z}/{x}/{y}.jpg',"{ minZoom: 0, maxZoom: 15, tms: true, crossOrigin: null}";
select 64.14244,-21.927561
This works great, but no other openstreetmap will now work in the system.
1. Is there a way to pass the crs object in options in the initial definition of openstreetmap.
2. The crs option (Projections) can not be added or changed after the map object is initialized. Is there any way we could create a javascript variable (crs) and include the additional javascript libraries in dbr.javascript before the leaflet library is processed - is skipping onload enough here maybe?
Of course I could copy the openstreetmap extension and create a fully new one, but it feels like a bit of overkill.