I get an error when applying the coordinate system data
Error: Invalid LatLng object: (NaN, NaN) at new D (leaflet.js:5:6566) at i.unproject (proj4leaflet.js:46:11) at i.pointToLatLng (leaflet.js:5:11723) at i.unproject (leaflet.js:5:36364) at i.layerPointToLatLng (leaflet.js:5:36468) at i.getCenter (leaflet.js:5:34446) at i._update (leaflet.js:5:107645) at i.redraw (leaflet.js:5:102125) at i.setParams (leaflet.js:5:114368) at WMS_REDRAW (const.js:42:39) EPSG data:
"EPSG:4216": { "data_code": "EPSG:4216", "name": "Bermuda 1957", "proj4": "+proj=longlat +ellps=clrk66 +towgs84=-292.295,248.758,429.447,-4.9971,-2.99,-6.6906,1.0289 +no_defs +type=crs", "center": [-64.75, 32.32], "bounds": [[-64.89, 32.21], [-64.61, 32.43]] } My code:
async function applyCrsToMap(data) { let newCrs, worldCopyJump; if (data.data_code === "EPSG:3857") { worldCopyJump = true; map.options.crs = L.CRS.EPSG3857; map.setMaxBounds(null); } else { map.options.crs = L.CRS.EPSG3857; proj4.defs(data.data_code, data.proj4); newCrs = new L.Proj.CRS(data.data_code, proj4.defs(data.data_code), { origin: [0, 0], resolutions: [ 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16 ], bounds: L.bounds(data.bounds[0], data.bounds[1]) }); worldCopyJump = false; let center4326 = proj4(data.proj4, 'EPSG:4326', data.center); let bounds4326 = [ proj4(data.proj4, 'EPSG:4326', data.bounds[0]), proj4(data.proj4, 'EPSG:4326', data.bounds[1]) ]; let latLngBounds4326 = L.latLngBounds( [bounds4326[0][1], bounds4326[0][0]], [bounds4326[1][1], bounds4326[1][0]] ); let extendedBounds = latLngBounds4326.pad(0.2); map.options.crs = newCrs; map.setMaxBounds(extendedBounds); map.setView([center4326[1], center4326[0]], 4); } map.dragging.disable(); delete map.dragging._draggable; map.options.worldCopyJump = worldCopyJump; map.dragging.enable(); map.invalidateSize(); map.eachLayer(function(layer) { map.removeLayer(layer); map.addLayer(layer); }); } I'm using leaflet. Why does this error occur? I get the coordinate system data here - https://epsg.io/4216
proj4.defs("EPSG:4219","+proj=longlat +ellps=bessel +towgs84=-384,664,-48,0,0,0,0 +no_defs +type=crs"); var crs = new L.Proj.CRS('EPSG:4219', proj4.defs('EPSG:4219'), { origin: [0, 0], resolutions: [ 4096, 2048, 1024, 512, 256, 128, 64, 32, 16 ], bounds: L.bounds([105.07, -3.3], [108.35, -1.44]) }); let map = L.map('map', { crs: crs, zoom: 2, minZoom: 2, maxZoom: 10, maxBoundsViscosity: 1.0, worldCopyJump: true, attributionControl:false, zoomControl: false, almostSamplingPeriod: 10, almostDistance: 25, });
proj4.defs("EPSG:4219","+proj=longlat +ellps=bessel +towgs84=-384,664,-48,0,0,0,0 +no_defs +type=crs"); var crs = new L.Proj.CRS('EPSG:4219', proj4.defs('EPSG:4219'), { origin: [0, 0], resolutions: [ 4096, 2048, 1024, 512, 256, 128, 64, 32, 16 ], bounds: L.bounds([105.07, -3.3], [108.35, -1.44]) });epsg.io/4219 I get same error