Loading .babelrc +20 −0 Original line number Diff line number Diff line { "presets": ["airbnb"], "plugins": [ [ "babel-plugin-import", { "libraryName": "@material-ui/core", "libraryDirectory": "esm", "camel2DashComponentName": false }, "core" ], [ "babel-plugin-import", { "libraryName": "@material-ui/icons", "libraryDirectory": "esm", "camel2DashComponentName": false }, "icons" ] ], "env": { "production": { "presets": ["minify"] Loading src/components/container/MapContainer.jsx 0 → 100644 +1 −0 Original line number Diff line number Diff line import React from "react"; src/index.html 0 → 100644 +14 −0 Original line number Diff line number Diff line <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="minimum-scale=1, initial-scale=1, width=device-width" /> <title>CartoCosmos</title> </head> <body> <div id="console"></div> <div id="map"></div> </body> src/index.jsx 0 → 100644 +9 −0 Original line number Diff line number Diff line import React from "react"; import ReactDOM from "react-dom"; import "leaflet"; import "./styles.css"; import ConsoleContainer from "./components/container/ConsoleContainer.jsx"; import "./js/AstroMap"; ReactDOM.render(<ConsoleContainer />, document.getElementById("console")); //ReactDOM.render(<MapContainer />, document.getElementById("map")); src/js/AstroMap.js 0 → 100644 +79 −0 Original line number Diff line number Diff line import * as L from "leaflet"; /* * @class AstroMap * @aka L.Map.AstroMap * @inherits L.Map * * The central class that creates an interactive map in the HTML. * Works with all target bodies supported by the USGS by loading the body's * base layers and overlays in a LayerCollection. Allows users to change * the projection of the map. * * @example * * ```js * // initialize the map on the "map" div with the target Mars * L.Map.AstroMap("map", "Mars", {}); * ``` */ L.Map.AstroMap = L.Map.extend({ options: { center: [0, 0], zoom: 1, maxZoom: 8, crs: L.CRS.EPSG4326, attributionControl: false }, // @method initialize(mapDiv: String, target: String, options?: Zoom/pan options) // Initializes the map by loading the LayerCollection for each supported projection // and setting the default options. initialize: function(mapDiv, target, options) { this.mapDiv = mapDiv; this.target = target; this.AstroProj = new AstroProj(); this.layers = { geodesic: new L.LayerCollection(this.target, "cylindrical"), northPolar: new L.LayerCollection( this.target, "north-polar stereographic" ), southPolar: new L.LayerCollection( this.target, "south-polar stereographic" ) }; L.setOptions(this, options); L.Map.prototype.initialize.call(this, this.mapDiv, this.options); this.loadLayerCollection("geodesic"); }, // @method loadLayerCollection(name: String) // Adds the LayerCollection with the requrested projection name. loadLayerCollection: function(name) { this.layers[name].addTo(this); }, // @method changeProjection(name: String, center: List) // Changes the projection of the map and resets the center and view. changeProjection: function(name, center) { let newCRS = null; if (name == "geodesic") { newCRS = L.CRS.EPSG4326; } else { proj = this.AstroProj.getStringAndCode(this.target, name); newCRS = new L.Proj.CRS(proj["code"], proj["string"], { resolutions: [8192, 4096, 2048, 1024, 512, 256, 128], origin: [0, 0] }); } this.options.crs = newCRS; this._resetView(center, 1, true); this.loadLayerCollection(name); } }); // exports.L.map.astroMap = function(mapDiv, target, options) { // return new L.map.astroMap(mapDiv, target, options); // }; Loading
.babelrc +20 −0 Original line number Diff line number Diff line { "presets": ["airbnb"], "plugins": [ [ "babel-plugin-import", { "libraryName": "@material-ui/core", "libraryDirectory": "esm", "camel2DashComponentName": false }, "core" ], [ "babel-plugin-import", { "libraryName": "@material-ui/icons", "libraryDirectory": "esm", "camel2DashComponentName": false }, "icons" ] ], "env": { "production": { "presets": ["minify"] Loading
src/components/container/MapContainer.jsx 0 → 100644 +1 −0 Original line number Diff line number Diff line import React from "react";
src/index.html 0 → 100644 +14 −0 Original line number Diff line number Diff line <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="minimum-scale=1, initial-scale=1, width=device-width" /> <title>CartoCosmos</title> </head> <body> <div id="console"></div> <div id="map"></div> </body>
src/index.jsx 0 → 100644 +9 −0 Original line number Diff line number Diff line import React from "react"; import ReactDOM from "react-dom"; import "leaflet"; import "./styles.css"; import ConsoleContainer from "./components/container/ConsoleContainer.jsx"; import "./js/AstroMap"; ReactDOM.render(<ConsoleContainer />, document.getElementById("console")); //ReactDOM.render(<MapContainer />, document.getElementById("map"));
src/js/AstroMap.js 0 → 100644 +79 −0 Original line number Diff line number Diff line import * as L from "leaflet"; /* * @class AstroMap * @aka L.Map.AstroMap * @inherits L.Map * * The central class that creates an interactive map in the HTML. * Works with all target bodies supported by the USGS by loading the body's * base layers and overlays in a LayerCollection. Allows users to change * the projection of the map. * * @example * * ```js * // initialize the map on the "map" div with the target Mars * L.Map.AstroMap("map", "Mars", {}); * ``` */ L.Map.AstroMap = L.Map.extend({ options: { center: [0, 0], zoom: 1, maxZoom: 8, crs: L.CRS.EPSG4326, attributionControl: false }, // @method initialize(mapDiv: String, target: String, options?: Zoom/pan options) // Initializes the map by loading the LayerCollection for each supported projection // and setting the default options. initialize: function(mapDiv, target, options) { this.mapDiv = mapDiv; this.target = target; this.AstroProj = new AstroProj(); this.layers = { geodesic: new L.LayerCollection(this.target, "cylindrical"), northPolar: new L.LayerCollection( this.target, "north-polar stereographic" ), southPolar: new L.LayerCollection( this.target, "south-polar stereographic" ) }; L.setOptions(this, options); L.Map.prototype.initialize.call(this, this.mapDiv, this.options); this.loadLayerCollection("geodesic"); }, // @method loadLayerCollection(name: String) // Adds the LayerCollection with the requrested projection name. loadLayerCollection: function(name) { this.layers[name].addTo(this); }, // @method changeProjection(name: String, center: List) // Changes the projection of the map and resets the center and view. changeProjection: function(name, center) { let newCRS = null; if (name == "geodesic") { newCRS = L.CRS.EPSG4326; } else { proj = this.AstroProj.getStringAndCode(this.target, name); newCRS = new L.Proj.CRS(proj["code"], proj["string"], { resolutions: [8192, 4096, 2048, 1024, 512, 256, 128], origin: [0, 0] }); } this.options.crs = newCRS; this._resetView(center, 1, true); this.loadLayerCollection(name); } }); // exports.L.map.astroMap = function(mapDiv, target, options) { // return new L.map.astroMap(mapDiv, target, options); // };