Skip to content

Commit

Permalink
feat: export map control types (#74)
Browse files Browse the repository at this point in the history
* Export map control types
  • Loading branch information
turban authored Jan 22, 2020
1 parent 679afa3 commit 71e597a
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 25 deletions.
12 changes: 2 additions & 10 deletions src/Map.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import L from 'leaflet'
import './utils/L.Map.Sync'
import layerTypes from './layerTypes'
import fitBounds from './controls/FitBounds'
import search from './controls/Search'
import measure from './controls/Measure'
import layerTypes from './layers/layerTypes'
import controlTypes from './controls/controlTypes'
import {
toLatLng,
toLatLngBounds,
Expand All @@ -18,11 +16,6 @@ export class Map extends L.Evented {
controls: [],
worldCopyJump: true,
maxZoom: 18,
controlTypes: {
fitBounds,
search,
measure,
},
}

constructor(el, opts) {
Expand Down Expand Up @@ -120,7 +113,6 @@ export class Map extends L.Evented {

addControl(control) {
const { position, type } = control
const { controlTypes } = this.options

if (position) {
control.position = position.replace(/-/, '')
Expand Down
12 changes: 12 additions & 0 deletions src/controls/controlTypes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import L from 'leaflet'
import fitBounds from './FitBounds'
import search from './Search'
import measure from './Measure'

export default {
fitBounds,
search,
measure,
zoom: L.control.zoom,
scale: L.control.scale,
}
8 changes: 6 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import Map from "./Map";
import types from './layerTypes';
import supportedLayers from './layers/layerTypes';
import supportedControls from './controls/controlTypes';
import "../scss/gis-api.scss";

// When this file was included in EarthEngine.js it caused error when running tests
// This file is never loaded by test scripts
import "script-loader!@google/earthengine/build/ee_api_js";

// Export supported layer types as an array
export const layerTypes = Object.keys(types);
export const layerTypes = Object.keys(supportedLayers);

// Export supported control types as an array
export const controlTypes = Object.keys(supportedControls);

export default Map;
2 changes: 1 addition & 1 deletion src/layers/LayerGroup.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import L from "leaflet";
import layerMixin from "./layerMixin";
import layerTypes from "../layerTypes";
import layerTypes from "./layerTypes";
import { getBoundsFromLayers, toLngLatBounds } from "../utils/geometry";

export const LayerGroup = L.LayerGroup.extend({
Expand Down
24 changes: 12 additions & 12 deletions src/layerTypes.js → src/layers/layerTypes.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import tileLayer from './layers/TileLayer'
import wmsLayer from './layers/WmsLayer'
import googleLayer from './layers/GoogleLayer'
import geoJson from './layers/GeoJsonGroup'
import boundary from './layers/Boundary'
import events from './layers/Events'
import markers from './layers/Markers'
import choropleth from './layers/Choropleth'
import clientCluster from './layers/ClientCluster'
import serverCluster from './layers/ServerCluster'
import earthEngine from './layers/EarthEngine'
import group from './layers/LayerGroup'
import tileLayer from './TileLayer'
import wmsLayer from './WmsLayer'
import googleLayer from './GoogleLayer'
import geoJson from './GeoJsonGroup'
import boundary from './Boundary'
import events from './Events'
import markers from './Markers'
import choropleth from './Choropleth'
import clientCluster from './ClientCluster'
import serverCluster from './ServerCluster'
import earthEngine from './EarthEngine'
import group from './LayerGroup'

export default {
tileLayer, // CartoDB basemap
Expand Down

0 comments on commit 71e597a

Please sign in to comment.