Loading src/PlanetaryMap.js→src/AstroMap.js +27 −10 Original line number Diff line number Diff line L.Map.AstroMap = L.Map.extend({ initialize: function(mapDiv, target) { options: { center: [0, 0], zoom: 1, maxZoom: 8, crs: L.CRS.EPSG4326, attributionControl: false }, initialize: function(mapDiv, target, options) { this.mapDiv = mapDiv; this.target = target; this.layerControl = null; this.layers = { geodesic: new L.LayerCollection(this.target, "cylindrical"), northPolar: new L.LayerCollection( Loading @@ -14,18 +21,28 @@ L.Map.AstroMap = L.Map.extend({ "south-polar stereographic" ) }; L.Map.prototype.initialize.call(this, this.mapDiv, { center: [0, 0], zoom: 1, maxZoom: 8, crs: L.CRS.EPSG4326, attributionControl: false }); L.setOptions(this, options); L.Map.prototype.initialize.call(this, this.mapDiv, this.options); this.loadLayerCollection("geodesic"); }, loadLayerCollection: function(name) { this.layers[name].addTo(this); }, changeProjection: function(projName, center) { var northStere = new L.Proj.CRS( "EPSG:32661", "+proj=stere +lat_0=90 +lon_0=0" + "+k=1 +x_0=0 +y_0=0 +a=3396190 +b=3376200 +units=m +no_defs", { resolutions: [8192, 4096, 2048, 1024, 512, 256, 128], origin: [0, 0] } ); this.options.crs = northStere; this._resetView(center, 1, true); this.loadLayerCollection(projName); } }); src/LayerCollection.js +8 −4 Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ L.LayerCollection = L.Class.extend({ this.baseLayers = {}; this.overlays = {}; this.defaultLayerIndex = 0; L.LayerCollection.layerControl = null; var layers = this.parseJSON(); this.createBaseLayers(layers["base"]); Loading Loading @@ -89,14 +90,17 @@ L.LayerCollection = L.Class.extend({ map.removeLayer(layer); }); if (map.layerControl) { map.layerControl.remove(); if (L.LayerCollection.layerControl) { L.LayerCollection.layerControl.remove(); } var defaultLayer = Object.keys(this.baseLayers)[this.defaultLayerIndex]; this.baseLayers[defaultLayer].addTo(map); map.layerControl = L.control.layers(this.baseLayers, this.overlays); map.layerControl.addTo(map); L.LayerCollection.layerControl = L.control.layers( this.baseLayers, this.overlays ); L.LayerCollection.layerControl.addTo(map); } }); src/Projection.js +1 −12 Original line number Diff line number Diff line Loading @@ -17,19 +17,8 @@ L.Control.Projection = L.Control.extend({ }, loadNorthPolar: function(e) { var northStere = new L.Proj.CRS( "EPSG:32661", "+proj=stere +lat_0=90 +lon_0=0" + "+k=1 +x_0=0 +y_0=0 +a=3396190 +b=3376200 +units=m +no_defs", { resolutions: [8192, 4096, 2048, 1024, 512, 256, 128], origin: [0, 0] } ); var center = [90, 0]; this._map.options.crs = northStere; this._map._resetView(center, 1, true); //we need this to redraw all layers (polygons, markers...) in the new projection. this._map.loadLayerCollection("northPolar"); this._map.changeProjection("northPolar", center); }, loadSouthPolar: function(e) { Loading src/index.js +2 −2 Original line number Diff line number Diff line import "./styles.css"; import * from 'leaflet'; import * from 'proj4leaflet'; import L from 'leaflet'; import L.Proj from 'proj4leaflet'; export * from './LayerCollection'; export * from './PlanetaryLayer'; Loading Loading
src/PlanetaryMap.js→src/AstroMap.js +27 −10 Original line number Diff line number Diff line L.Map.AstroMap = L.Map.extend({ initialize: function(mapDiv, target) { options: { center: [0, 0], zoom: 1, maxZoom: 8, crs: L.CRS.EPSG4326, attributionControl: false }, initialize: function(mapDiv, target, options) { this.mapDiv = mapDiv; this.target = target; this.layerControl = null; this.layers = { geodesic: new L.LayerCollection(this.target, "cylindrical"), northPolar: new L.LayerCollection( Loading @@ -14,18 +21,28 @@ L.Map.AstroMap = L.Map.extend({ "south-polar stereographic" ) }; L.Map.prototype.initialize.call(this, this.mapDiv, { center: [0, 0], zoom: 1, maxZoom: 8, crs: L.CRS.EPSG4326, attributionControl: false }); L.setOptions(this, options); L.Map.prototype.initialize.call(this, this.mapDiv, this.options); this.loadLayerCollection("geodesic"); }, loadLayerCollection: function(name) { this.layers[name].addTo(this); }, changeProjection: function(projName, center) { var northStere = new L.Proj.CRS( "EPSG:32661", "+proj=stere +lat_0=90 +lon_0=0" + "+k=1 +x_0=0 +y_0=0 +a=3396190 +b=3376200 +units=m +no_defs", { resolutions: [8192, 4096, 2048, 1024, 512, 256, 128], origin: [0, 0] } ); this.options.crs = northStere; this._resetView(center, 1, true); this.loadLayerCollection(projName); } });
src/LayerCollection.js +8 −4 Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ L.LayerCollection = L.Class.extend({ this.baseLayers = {}; this.overlays = {}; this.defaultLayerIndex = 0; L.LayerCollection.layerControl = null; var layers = this.parseJSON(); this.createBaseLayers(layers["base"]); Loading Loading @@ -89,14 +90,17 @@ L.LayerCollection = L.Class.extend({ map.removeLayer(layer); }); if (map.layerControl) { map.layerControl.remove(); if (L.LayerCollection.layerControl) { L.LayerCollection.layerControl.remove(); } var defaultLayer = Object.keys(this.baseLayers)[this.defaultLayerIndex]; this.baseLayers[defaultLayer].addTo(map); map.layerControl = L.control.layers(this.baseLayers, this.overlays); map.layerControl.addTo(map); L.LayerCollection.layerControl = L.control.layers( this.baseLayers, this.overlays ); L.LayerCollection.layerControl.addTo(map); } });
src/Projection.js +1 −12 Original line number Diff line number Diff line Loading @@ -17,19 +17,8 @@ L.Control.Projection = L.Control.extend({ }, loadNorthPolar: function(e) { var northStere = new L.Proj.CRS( "EPSG:32661", "+proj=stere +lat_0=90 +lon_0=0" + "+k=1 +x_0=0 +y_0=0 +a=3396190 +b=3376200 +units=m +no_defs", { resolutions: [8192, 4096, 2048, 1024, 512, 256, 128], origin: [0, 0] } ); var center = [90, 0]; this._map.options.crs = northStere; this._map._resetView(center, 1, true); //we need this to redraw all layers (polygons, markers...) in the new projection. this._map.loadLayerCollection("northPolar"); this._map.changeProjection("northPolar", center); }, loadSouthPolar: function(e) { Loading
src/index.js +2 −2 Original line number Diff line number Diff line import "./styles.css"; import * from 'leaflet'; import * from 'proj4leaflet'; import L from 'leaflet'; import L.Proj from 'proj4leaflet'; export * from './LayerCollection'; export * from './PlanetaryLayer'; Loading