react-spatial 1.2.2 → 1.2.3-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LayerService.js +128 -184
- package/LayerService.js.map +7 -1
- package/components/BaseLayerSwitcher/BaseLayerSwitcher.js +163 -221
- package/components/BaseLayerSwitcher/BaseLayerSwitcher.js.map +7 -1
- package/components/BaseLayerSwitcher/index.js +1 -3
- package/components/BaseLayerSwitcher/index.js.map +7 -1
- package/components/BasicMap/BasicMap.js +147 -285
- package/components/BasicMap/BasicMap.js.map +7 -1
- package/components/BasicMap/index.js +1 -3
- package/components/BasicMap/index.js.map +7 -1
- package/components/CanvasSaveButton/CanvasSaveButton.js +165 -419
- package/components/CanvasSaveButton/CanvasSaveButton.js.map +7 -1
- package/components/CanvasSaveButton/index.js +1 -3
- package/components/CanvasSaveButton/index.js.map +7 -1
- package/components/Copyright/Copyright.js +29 -70
- package/components/Copyright/Copyright.js.map +7 -1
- package/components/Copyright/index.js +1 -3
- package/components/Copyright/index.js.map +7 -1
- package/components/FeatureExportButton/FeatureExportButton.js +40 -106
- package/components/FeatureExportButton/FeatureExportButton.js.map +7 -1
- package/components/FeatureExportButton/index.js +1 -3
- package/components/FeatureExportButton/index.js.map +7 -1
- package/components/FilterButton/FilterButton.js +41 -106
- package/components/FilterButton/FilterButton.js.map +7 -1
- package/components/FilterButton/index.js +1 -3
- package/components/FilterButton/index.js.map +7 -1
- package/components/FitExtent/FitExtent.js +17 -50
- package/components/FitExtent/FitExtent.js.map +7 -1
- package/components/FitExtent/index.js +1 -3
- package/components/FitExtent/index.js.map +7 -1
- package/components/FollowButton/FollowButton.js +41 -111
- package/components/FollowButton/FollowButton.js.map +7 -1
- package/components/FollowButton/index.js +1 -3
- package/components/FollowButton/index.js.map +7 -1
- package/components/Geolocation/Geolocation.js +104 -213
- package/components/Geolocation/Geolocation.js.map +7 -1
- package/components/Geolocation/index.js +1 -3
- package/components/Geolocation/index.js.map +7 -1
- package/components/LayerTree/LayerTree.js +204 -410
- package/components/LayerTree/LayerTree.js.map +7 -1
- package/components/LayerTree/index.js +1 -3
- package/components/LayerTree/index.js.map +7 -1
- package/components/MousePosition/MousePosition.js +61 -130
- package/components/MousePosition/MousePosition.js.map +7 -1
- package/components/MousePosition/index.js +1 -3
- package/components/MousePosition/index.js.map +7 -1
- package/components/NorthArrow/NorthArrow.js +22 -62
- package/components/NorthArrow/NorthArrow.js.map +7 -1
- package/components/NorthArrow/index.js +1 -3
- package/components/NorthArrow/index.js.map +7 -1
- package/components/Overlay/Overlay.js +83 -130
- package/components/Overlay/Overlay.js.map +7 -1
- package/components/Overlay/index.js +1 -3
- package/components/Overlay/index.js.map +7 -1
- package/components/Permalink/Permalink.js +150 -244
- package/components/Permalink/Permalink.js.map +7 -1
- package/components/Permalink/index.js +1 -3
- package/components/Permalink/index.js.map +7 -1
- package/components/Popup/Popup.js +106 -233
- package/components/Popup/Popup.js.map +7 -1
- package/components/Popup/index.js +1 -3
- package/components/Popup/index.js.map +7 -1
- package/components/ResizeHandler/ResizeHandler.js +58 -113
- package/components/ResizeHandler/ResizeHandler.js.map +7 -1
- package/components/ResizeHandler/index.js +1 -3
- package/components/ResizeHandler/index.js.map +7 -1
- package/components/RouteSchedule/RouteSchedule.js +150 -283
- package/components/RouteSchedule/RouteSchedule.js.map +7 -1
- package/components/RouteSchedule/index.js +1 -3
- package/components/RouteSchedule/index.js.map +7 -1
- package/components/ScaleLine/ScaleLine.js +21 -45
- package/components/ScaleLine/ScaleLine.js.map +7 -1
- package/components/ScaleLine/index.js +1 -3
- package/components/ScaleLine/index.js.map +7 -1
- package/components/Search/Search.js +122 -186
- package/components/Search/Search.js.map +7 -1
- package/components/Search/SearchService.js +45 -69
- package/components/Search/SearchService.js.map +7 -1
- package/components/Search/engines/Engine.js +18 -25
- package/components/Search/engines/Engine.js.map +7 -1
- package/components/Search/engines/StopFinder.js +21 -38
- package/components/Search/engines/StopFinder.js.map +7 -1
- package/components/Search/index.js +3 -6
- package/components/Search/index.js.map +7 -1
- package/components/StopsFinder/StopsFinder.js +123 -174
- package/components/StopsFinder/StopsFinder.js.map +7 -1
- package/components/StopsFinder/StopsFinderOption.js +37 -54
- package/components/StopsFinder/StopsFinderOption.js.map +7 -1
- package/components/StopsFinder/index.js +1 -3
- package/components/StopsFinder/index.js.map +7 -1
- package/components/TrackerControl/TrackerControl.js +73 -128
- package/components/TrackerControl/TrackerControl.js.map +7 -1
- package/components/TrackerControl/index.js +1 -3
- package/components/TrackerControl/index.js.map +7 -1
- package/components/Zoom/Zoom.js +69 -112
- package/components/Zoom/Zoom.js.map +7 -1
- package/components/Zoom/index.js +1 -3
- package/components/Zoom/index.js.map +7 -1
- package/package.json +10 -5
- package/propTypes.js +17 -23
- package/propTypes.js.map +7 -1
- package/setupTests.js +2 -4
- package/setupTests.js.map +7 -1
- package/themes/README.md +26 -0
- package/themes/default/components.scss +0 -1
- package/themes/default/examples.scss +0 -1
- package/utils/GlobalsForOle.js +63 -64
- package/utils/GlobalsForOle.js.map +7 -1
- package/utils/KML.js +178 -364
- package/utils/KML.js.map +7 -1
- package/utils/KMLFormat.js +37 -73
- package/utils/KMLFormat.js.map +7 -1
- package/utils/Styles.js +24 -32
- package/utils/Styles.js.map +7 -1
- package/utils/getPolygonPattern.js +11 -44
- package/utils/getPolygonPattern.js.map +7 -1
- package/utils/timeUtils.js +16 -35
- package/utils/timeUtils.js.map +7 -1
- package/LayerService.test.js +0 -160
- package/LayerService.test.js.map +0 -1
- package/Projections.js +0 -16
- package/Projections.js.map +0 -1
- package/components/BaseLayerSwitcher/BaseLayerSwitcher.test.js +0 -88
- package/components/BaseLayerSwitcher/BaseLayerSwitcher.test.js.map +0 -1
- package/components/BaseLayerToggler/BaseLayerToggler.js +0 -490
- package/components/BaseLayerToggler/BaseLayerToggler.js.map +0 -1
- package/components/BaseLayerToggler/BaseLayerToggler.md.scss +0 -9
- package/components/BaseLayerToggler/BaseLayerToggler.scss +0 -49
- package/components/BaseLayerToggler/BaseLayerToggler.test.js +0 -127
- package/components/BaseLayerToggler/BaseLayerToggler.test.js.map +0 -1
- package/components/BaseLayerToggler/index.js +0 -3
- package/components/BaseLayerToggler/index.js.map +0 -1
- package/components/BasicMap/BasicMap.test.js +0 -288
- package/components/BasicMap/BasicMap.test.js.map +0 -1
- package/components/CanvasSaveButton/CanvasSaveButton.test.js +0 -173
- package/components/CanvasSaveButton/CanvasSaveButton.test.js.map +0 -1
- package/components/Copyright/Copyright.test.js +0 -133
- package/components/Copyright/Copyright.test.js.map +0 -1
- package/components/FeatureExportButton/FeatureExportButton.test.js +0 -407
- package/components/FeatureExportButton/FeatureExportButton.test.js.map +0 -1
- package/components/FilterButton/FilterButton.test.js +0 -48
- package/components/FilterButton/FilterButton.test.js.map +0 -1
- package/components/FitExtent/FitExtent.test.js +0 -44
- package/components/FitExtent/FitExtent.test.js.map +0 -1
- package/components/FollowButton/FollowButton.test.js +0 -57
- package/components/FollowButton/FollowButton.test.js.map +0 -1
- package/components/Geolocation/Geolocation.test.js +0 -263
- package/components/Geolocation/Geolocation.test.js.map +0 -1
- package/components/LayerTree/LayerTree.test.js +0 -323
- package/components/LayerTree/LayerTree.test.js.map +0 -1
- package/components/MousePosition/MousePosition.test.js +0 -125
- package/components/MousePosition/MousePosition.test.js.map +0 -1
- package/components/NorthArrow/NorthArrow.test.js +0 -106
- package/components/NorthArrow/NorthArrow.test.js.map +0 -1
- package/components/Overlay/Overlay.test.js +0 -145
- package/components/Overlay/Overlay.test.js.map +0 -1
- package/components/Permalink/Permalink.test.js +0 -267
- package/components/Permalink/Permalink.test.js.map +0 -1
- package/components/Popup/Popup.test.js +0 -291
- package/components/Popup/Popup.test.js.map +0 -1
- package/components/ResizeHandler/ResizeHandler.test.js +0 -410
- package/components/ResizeHandler/ResizeHandler.test.js.map +0 -1
- package/components/RouteSchedule/RouteSchedule.test.js +0 -102
- package/components/RouteSchedule/RouteSchedule.test.js.map +0 -1
- package/components/ScaleLine/ScaleLine.test.js +0 -32
- package/components/ScaleLine/ScaleLine.test.js.map +0 -1
- package/components/Search/Search.test.js +0 -15
- package/components/Search/Search.test.js.map +0 -1
- package/components/StopsFinder/StopsFinder.test.js +0 -19
- package/components/StopsFinder/StopsFinder.test.js.map +0 -1
- package/components/TrackerControl/TrackerControl.test.js +0 -17
- package/components/TrackerControl/TrackerControl.test.js.map +0 -1
- package/components/Zoom/Zoom.test.js +0 -150
- package/components/Zoom/Zoom.test.js.map +0 -1
- package/styleguidist/ComponentsList.js +0 -52
- package/styleguidist/ComponentsList.js.map +0 -1
- package/styleguidist/StyleGuide.js +0 -253
- package/styleguidist/StyleGuide.js.map +0 -1
- package/utils/KML.test.js +0 -163
- package/utils/KML.test.js.map +0 -1
- package/utils/KMLFormat.test.js +0 -22
- package/utils/KMLFormat.test.js.map +0 -1
- package/utils/getPolygonPattern.test.js +0 -66
- package/utils/getPolygonPattern.test.js.map +0 -1
- package/utils/timeUtils.test.js +0 -32
- package/utils/timeUtils.test.js.map +0 -1
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{"version":3,"file":"LayerTree.js","sources":["../../../src/components/LayerTree/LayerTree.js"],"sourcesContent":["import React, { Component } from 'react';\nimport PropTypes from 'prop-types';\n\nconst propTypes = {\n /**\n * Layers provider.\n */\n layerService: PropTypes.object,\n\n /**\n * CSS class to apply on the container.\n */\n className: PropTypes.string,\n\n /**\n * Padding left to apply on each level.\n */\n padding: PropTypes.number,\n\n /**\n * Determine if the item is hidden in the tree or not.\n *\n * @param {object} item The item to hide or not.\n *\n * @return {bool} true if the item is not displayed in the tree\n */\n isItemHidden: PropTypes.func,\n\n /**\n * Determine the className used by the div containing the parent and its children.\n */\n getParentClassName: PropTypes.func,\n\n /**\n * Custom function to render an item in the tree.\n *\n * @param {object} item The item to render.\n *\n * @return {node} A jsx node.\n */\n renderItem: PropTypes.func,\n\n /**\n * Custom function to render only the content of an item in the tree.\n *\n * @param {object} item The item to render.\n *\n * @return {node} A jsx node.\n */\n renderItemContent: PropTypes.func,\n\n /**\n * Custom function to render custom content before the list of children of an item.\n *\n * @param {object} item The item to render.\n *\n * @return {node} A jsx node.\n */\n renderBeforeItem: PropTypes.func,\n\n /**\n * Custom function to render custom content after the list of children of an item.\n *\n * @param {object} item The item to render.\n *\n * @return {node} A jsx node.\n */\n renderAfterItem: PropTypes.func,\n\n /**\n * Custom function to render the label.\n *\n * @param {string} item The label to render.\n * @param {LayerTree} comp The LayerTree component.\n *\n * @return {node} A jsx node.\n */\n renderLabel: PropTypes.func,\n\n /**\n * Object holding title for the layer tree's buttons.\n */\n titles: PropTypes.shape({\n /**\n * aria-label on checkbox to show layer.\n */\n layerShow: PropTypes.string,\n /**\n * aria-label on checkbox to hide layer.\n */\n layerHide: PropTypes.string,\n /**\n * title on button to show sublayers.\n */\n subLayerShow: PropTypes.string,\n /**\n * title on button to show sublayers.\n */\n subLayerHide: PropTypes.string,\n }),\n\n /**\n * Boolean determining whether children collapse/expand when their parent is toggled\n * @param {...(boolean|function)} expandChildren Boolean or function returning a boolean.\n * @return {boolean} True or false\n */\n expandChildren: PropTypes.oneOfType([PropTypes.bool, PropTypes.func]),\n\n /**\n * Translation function.\n * @param {function} Translation function returning the translated string.\n */\n t: PropTypes.func,\n};\n\nconst defaultProps = {\n layerService: undefined,\n className: 'rs-layer-tree',\n padding: 30,\n isItemHidden: () => {\n return false;\n },\n getParentClassName: () => {\n return undefined;\n },\n renderItem: null,\n renderItemContent: null,\n renderBeforeItem: null,\n renderAfterItem: null,\n renderLabel: (layer, layerComp) => {\n const { t } = layerComp.props;\n return t(layer.name);\n },\n titles: {\n layerShow: 'Show layer',\n layerHide: 'Hide layer',\n subLayerShow: 'Show sublayer',\n subLayerHide: 'Hide sublayer',\n },\n t: (s) => {\n return s;\n },\n expandChildren: false,\n};\n\n/**\n * The LayerTree component renders an interface for toggling\n * [mobility-toolbox-js layers](https://mobility-toolbox-js.geops.io/api/identifiers%20html#ol-layers)\n * and their corresponding child layers.\n */\n\nclass LayerTree extends Component {\n constructor(props) {\n super(props);\n const { layerService, isItemHidden } = this.props;\n const initialExpandedLayers =\n layerService && layerService.getLayers()\n ? this.getExpandedLayers(\n layerService.getLayers().filter((l) => {\n return (\n !isItemHidden(l) &&\n l.getVisibleChildren().filter((c) => {\n return !isItemHidden(c);\n }).length\n );\n }),\n )\n : [];\n\n this.state = {\n layers: layerService ? layerService.getLayers() : [],\n expandedLayers: initialExpandedLayers,\n };\n this.updateLayers = this.updateLayers.bind(this);\n this.olKeys = [];\n }\n\n componentDidMount() {\n this.updateLayerService();\n }\n\n componentDidUpdate(prevProps) {\n const { layerService } = this.props;\n\n if (layerService !== prevProps.layerService) {\n this.updateLayerService();\n }\n }\n\n componentWillUnmount() {\n const { layerService } = this.props;\n layerService.un('change:visible', this.updateLayers);\n }\n\n onInputClick(layer, toggle = false) {\n if (toggle) {\n this.onToggle(layer);\n } else {\n layer.setVisible(!layer.visible);\n }\n }\n\n onToggle(layer) {\n const { expandedLayers } = this.state;\n const pos = expandedLayers.indexOf(layer);\n if (pos > -1) {\n expandedLayers.splice(pos, 1);\n } else {\n expandedLayers.push(...this.getExpandedLayers([layer]));\n }\n\n this.setState({ expandedLayers });\n }\n\n /**\n * Get the always expanded ancestors (isAlwaysExpanded=true) of the given layers\n * together with the (given) initially expanded layers\n *\n * @param {Layer} layers Initially expanded layers\n * @return {Array.<Layer>} Initially expanded layers and all its always expanded ancestors\n */\n getExpandedLayers(layers) {\n const { isItemHidden } = this.props;\n const children = layers.flatMap((l) => {\n return l.children.filter((c) => {\n return !isItemHidden(c) && c.get('isAlwaysExpanded');\n });\n });\n\n if (!children.length) {\n return layers;\n }\n return [...layers, this.getExpandedLayers(children)].flat();\n }\n\n updateLayerService() {\n const { layerService } = this.props;\n if (layerService) {\n layerService.un('change:visible', this.updateLayers);\n this.updateLayers();\n layerService.on('change:visible', this.updateLayers);\n }\n }\n\n updateLayers() {\n const { layerService, expandChildren } = this.props;\n const layers = layerService.getLayers();\n if (\n typeof expandChildren === 'function'\n ? expandChildren(layers)\n : expandChildren\n ) {\n this.setState({\n expandedLayers: layers.flatMap((l) => {\n return this.expandLayer(l);\n }),\n });\n }\n this.setState({\n layers,\n });\n }\n\n expandLayer(layer, expLayers = []) {\n const { isItemHidden } = this.props;\n if (layer.visible && !isItemHidden(layer)) {\n const children = layer.children\n .filter((c) => {\n return !isItemHidden(c) && !c.get('isAlwaysExpanded');\n })\n .flatMap((c) => {\n return this.expandLayer(c, expLayers);\n });\n return [...expLayers, ...children, layer];\n }\n return expLayers;\n }\n\n renderInput(layer) {\n const { titles, isItemHidden } = this.props;\n let tabIndex = 0;\n\n if (\n !layer.children.filter((c) => {\n return !isItemHidden(c);\n }).length\n ) {\n // We forbid focus on keypress event for first level layers and layers without children.\n tabIndex = -1;\n }\n\n const inputType = layer.get('radioGroup') ? 'radio' : 'checkbox';\n return (\n // eslint-disable-next-line jsx-a11y/label-has-associated-control,jsx-a11y/no-noninteractive-element-interactions\n <label\n className={`rs-layer-tree-input rs-layer-tree-input-${inputType} rs-${inputType}`}\n tabIndex={tabIndex}\n title={layer.visible ? titles.layerHide : titles.layerShow}\n aria-label={layer.visible ? titles.layerHide : titles.layerShow}\n onKeyPress={(e) => {\n if (e.which === 13) {\n this.onInputClick(layer);\n }\n }}\n >\n <input\n type={inputType}\n tabIndex={-1}\n checked={layer.visible}\n readOnly\n onClick={() => {\n return this.onInputClick(layer);\n }}\n />\n <span />\n </label>\n );\n }\n\n renderArrow(layer) {\n const { isItemHidden } = this.props;\n const { expandedLayers } = this.state;\n\n if (\n !layer.children.filter((c) => {\n return !isItemHidden(c);\n }).length ||\n layer.get('isAlwaysExpanded')\n ) {\n return null;\n }\n\n return (\n <div\n className={`rs-layer-tree-arrow rs-layer-tree-arrow-${\n !expandedLayers.includes(layer) ? 'collapsed' : 'expanded'\n }`}\n />\n );\n }\n\n // Render a button which expands/collapse the layer if there is children\n // or simulate a click on the input otherwise.\n renderToggleButton(layer) {\n const { t, titles, isItemHidden, renderLabel } = this.props;\n const { expandedLayers } = this.state;\n const onInputClick = () => {\n this.onInputClick(\n layer,\n layer.children.filter((c) => {\n return !isItemHidden(c);\n }).length && !layer.get('isAlwaysExpanded'),\n );\n };\n const title = `${t(layer.name)} ${\n !expandedLayers.includes(layer)\n ? titles.subLayerShow\n : titles.subLayerHide\n }`;\n return (\n <div\n role=\"button\"\n tabIndex={0}\n className=\"rs-layer-tree-toggle\"\n title={title}\n aria-expanded={expandedLayers.includes(layer)}\n aria-label={title}\n onClick={onInputClick}\n onKeyPress={onInputClick}\n >\n <div>{renderLabel(layer, this)}</div>\n {this.renderArrow(layer)}\n </div>\n );\n }\n\n renderItemContent(layer) {\n return (\n <>\n {this.renderInput(layer)}\n {this.renderToggleButton(layer)}\n </>\n );\n }\n\n renderItem(layer, level) {\n const { isItemHidden } = this.props;\n const {\n renderItem,\n renderItemContent,\n renderBeforeItem,\n renderAfterItem,\n padding,\n getParentClassName,\n } = this.props;\n const { expandedLayers } = this.state;\n\n const children = expandedLayers.includes(layer)\n ? [\n ...layer.children.filter((c) => {\n return !isItemHidden(c);\n }),\n ]\n : [];\n\n if (renderItem) {\n return renderItem(layer, this.onInputClick, this.onToggle);\n }\n\n return (\n <div className={getParentClassName()} key={layer.key}>\n <div\n className={`rs-layer-tree-item ${layer.visible ? 'rs-visible' : ''}`}\n style={{\n paddingLeft: `${padding * level}px`,\n }}\n >\n {renderItemContent\n ? renderItemContent(layer, this)\n : this.renderItemContent(layer)}\n </div>\n {renderBeforeItem && renderBeforeItem(layer, level, this)}\n {[...children].reverse().map((child) => {\n return this.renderItem(child, level + 1);\n })}\n {renderAfterItem && renderAfterItem(layer, level, this)}\n </div>\n );\n }\n\n renderTree() {\n const { isItemHidden } = this.props;\n const { layers } = this.state;\n\n if (!layers) {\n return null;\n }\n\n return (\n <>\n {layers\n .filter((l) => {\n return !isItemHidden(l);\n })\n .reverse()\n .map((l) => {\n return this.renderItem(l, 0);\n })}\n </>\n );\n }\n\n render() {\n const { className } = this.props;\n return <div className={className}>{this.renderTree()}</div>;\n }\n}\n\nLayerTree.propTypes = propTypes;\nLayerTree.defaultProps = defaultProps;\n\nexport default LayerTree;\n"],"names":["const","super","this","let"],"mappings":"AAAA,OAAO,KAAK,IAAI,SAAS,QAAQ,OAAO,CAAC;AACzC,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC;AACAA,GAAK,CAAC,SAAS,GAAG;AAClB;AACA;AACA;AACA,EAAE,YAAY,EAAE,SAAS,CAAC,MAAM;AAChC;AACA;AACA;AACA;AACA,EAAE,SAAS,EAAE,SAAS,CAAC,MAAM;AAC7B;AACA;AACA;AACA;AACA,EAAE,OAAO,EAAE,SAAS,CAAC,MAAM;AAC3B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE,YAAY,EAAE,SAAS,CAAC,IAAI;AAC9B;AACA;AACA;AACA;AACA,EAAE,kBAAkB,EAAE,SAAS,CAAC,IAAI;AACpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE,UAAU,EAAE,SAAS,CAAC,IAAI;AAC5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE,iBAAiB,EAAE,SAAS,CAAC,IAAI;AACnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE,gBAAgB,EAAE,SAAS,CAAC,IAAI;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE,eAAe,EAAE,SAAS,CAAC,IAAI;AACjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE,WAAW,EAAE,SAAS,CAAC,IAAI;AAC7B;AACA;AACA;AACA;AACA,EAAE,MAAM,EAAE,SAAS,CAAC,KAAK,CAAC;AAC1B;AACA;AACA;AACA,IAAI,SAAS,EAAE,SAAS,CAAC,MAAM;AAC/B;AACA;AACA;AACA,IAAI,SAAS,EAAE,SAAS,CAAC,MAAM;AAC/B;AACA;AACA;AACA,IAAI,YAAY,EAAE,SAAS,CAAC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"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/LayerTree/LayerTree.js"],
|
|
4
|
+
"sourcesContent": ["import React, { Component } from 'react';\nimport PropTypes from 'prop-types';\nimport { Layer, getLayersAsFlatArray } from 'mobility-toolbox-js/ol';\nimport { unByKey } from 'ol/Observable';\n\nconst propTypes = {\n /**\n * Layers provider.\n */\n layers: PropTypes.arrayOf(Layer),\n\n /**\n * CSS class to apply on the container.\n */\n className: PropTypes.string,\n\n /**\n * Padding left to apply on each level.\n */\n padding: PropTypes.number,\n\n /**\n * Determine if the item is hidden in the tree or not.\n *\n * @param {object} item The item to hide or not.\n *\n * @return {bool} true if the item is not displayed in the tree\n */\n isItemHidden: PropTypes.func,\n\n /**\n * Determine the className used by the div containing the parent and its children.\n */\n getParentClassName: PropTypes.func,\n\n /**\n * Custom function to render an item in the tree.\n *\n * @param {object} item The item to render.\n *\n * @return {node} A jsx node.\n */\n renderItem: PropTypes.func,\n\n /**\n * Custom function to render only the content of an item in the tree.\n *\n * @param {object} item The item to render.\n *\n * @return {node} A jsx node.\n */\n renderItemContent: PropTypes.func,\n\n /**\n * Custom function to render custom content before the list of children of an item.\n *\n * @param {object} item The item to render.\n *\n * @return {node} A jsx node.\n */\n renderBeforeItem: PropTypes.func,\n\n /**\n * Custom function to render custom content after the list of children of an item.\n *\n * @param {object} item The item to render.\n *\n * @return {node} A jsx node.\n */\n renderAfterItem: PropTypes.func,\n\n /**\n * Custom function to render the label.\n *\n * @param {string} item The label to render.\n * @param {LayerTree} comp The LayerTree component.\n *\n * @return {node} A jsx node.\n */\n renderLabel: PropTypes.func,\n\n /**\n * Object holding title for the layer tree's buttons.\n */\n titles: PropTypes.shape({\n /**\n * aria-label on checkbox to show layer.\n */\n layerShow: PropTypes.string,\n /**\n * aria-label on checkbox to hide layer.\n */\n layerHide: PropTypes.string,\n /**\n * title on button to show sublayers.\n */\n subLayerShow: PropTypes.string,\n /**\n * title on button to show sublayers.\n */\n subLayerHide: PropTypes.string,\n }),\n\n /**\n * Boolean determining whether children collapse/expand when their parent is toggled\n * @param {...(boolean|function)} expandChildren Boolean or function returning a boolean.\n * @return {boolean} True or false\n */\n expandChildren: PropTypes.oneOfType([PropTypes.bool, PropTypes.func]),\n\n /**\n * Translation function.\n * @param {function} Translation function returning the translated string.\n */\n t: PropTypes.func,\n};\n\nconst defaultProps = {\n layers: [],\n className: 'rs-layer-tree',\n padding: 30,\n isItemHidden: () => {\n return false;\n },\n getParentClassName: () => {\n return undefined;\n },\n renderItem: null,\n renderItemContent: null,\n renderBeforeItem: null,\n renderAfterItem: null,\n renderLabel: (layer, layerComp) => {\n const { t } = layerComp.props;\n return t(layer.name);\n },\n titles: {\n layerShow: 'Show layer',\n layerHide: 'Hide layer',\n subLayerShow: 'Show sublayer',\n subLayerHide: 'Hide sublayer',\n },\n t: (s) => {\n return s;\n },\n expandChildren: false,\n};\n\n/**\n * The LayerTree component renders an interface for toggling\n * [mobility-toolbox-js layers](https://mobility-toolbox-js.geops.io/api/identifiers%20html#ol-layers)\n * and their corresponding child layers.\n */\n\nclass LayerTree extends Component {\n constructor(props) {\n super(props);\n\n const { layers, isItemHidden } = this.props;\n const initialExpandedLayers = layers\n ? this.getExpandedLayers(\n layers.filter((l) => {\n return (\n !isItemHidden(l) &&\n (l.children || [])\n .filter((child) => {\n return child.visible;\n })\n .filter((c) => {\n return !isItemHidden(c);\n }).length\n );\n }),\n )\n : [];\n\n this.state = {\n rootLayer: new Layer(),\n expandedLayers: initialExpandedLayers,\n revision: 0,\n };\n // this.updateLayers = this.updateLayers.bind(this);\n this.olKeys = [];\n }\n\n componentDidMount() {\n this.updateLayers();\n }\n\n componentDidUpdate(prevProps) {\n const { layers } = this.props;\n\n if (layers !== prevProps.layers) {\n this.updateLayers();\n }\n }\n\n componentWillUnmount() {\n unByKey(this.olKeys);\n this.olKeys = [];\n }\n\n onInputClick(layer, toggle = false) {\n if (toggle) {\n this.onToggle(layer);\n } else if (layer.setVisible) {\n layer.setVisible(!layer.visible);\n } else {\n // eslint-disable-next-line no-param-reassign\n layer.visible = !layer.visible;\n }\n }\n\n onToggle(layer) {\n const { expandedLayers } = this.state;\n const pos = expandedLayers.indexOf(layer);\n if (pos > -1) {\n expandedLayers.splice(pos, 1);\n } else {\n expandedLayers.push(...this.getExpandedLayers([layer]));\n }\n this.setState({ expandedLayers });\n }\n\n /**\n * Get the always expanded ancestors (isAlwaysExpanded=true) of the given layers\n * together with the (given) initially expanded layers\n *\n * @param {Layer} layers Initially expanded layers\n * @return {Array.<Layer>} Initially expanded layers and all its always expanded ancestors\n */\n getExpandedLayers(layers) {\n const { isItemHidden } = this.props;\n const children = layers.flatMap((l) => {\n return l.children.filter((c) => {\n return !isItemHidden(c) && c.get('isAlwaysExpanded');\n });\n });\n\n if (!children.length) {\n return layers;\n }\n return [...layers, this.getExpandedLayers(children)].flat();\n }\n\n updateLayers() {\n const { layers, expandChildren } = this.props;\n\n // Update the root layer\n let rootLayer = new Layer();\n if (Array.isArray(layers)) {\n if (layers.length === 1) {\n [rootLayer] = layers;\n }\n rootLayer = new Layer({ children: layers });\n } else {\n rootLayer = layers;\n }\n\n getLayersAsFlatArray(rootLayer).forEach((layer) => {\n this.olKeys.push(\n layer.on('propertychange', (evt) => {\n const { revision } = this.state;\n this.setState({ revision: revision + 1 });\n }),\n );\n });\n\n const state = { rootLayer };\n if (\n typeof expandChildren === 'function'\n ? expandChildren(layers)\n : expandChildren\n ) {\n state.expandedLayers = rootLayer.children.flatMap((l) => {\n return this.expandLayer(l);\n });\n }\n\n this.setState(state);\n }\n\n expandLayer(layer, expLayers = []) {\n const { isItemHidden } = this.props;\n if (layer.visible && !isItemHidden(layer)) {\n const children = layer.children\n .filter((c) => {\n return !isItemHidden(c) && !c.get('isAlwaysExpanded');\n })\n .flatMap((c) => {\n return this.expandLayer(c, expLayers);\n });\n return [...expLayers, ...children, layer];\n }\n return expLayers;\n }\n\n renderInput(layer) {\n const { titles, isItemHidden } = this.props;\n let tabIndex = 0;\n\n if (\n !(layer.children || []).filter((c) => {\n return !isItemHidden(c);\n }).length\n ) {\n // We forbid focus on keypress event for first level layers and layers without children.\n tabIndex = -1;\n }\n\n const inputType = layer.get('group') ? 'radio' : 'checkbox';\n return (\n // eslint-disable-next-line jsx-a11y/label-has-associated-control,jsx-a11y/no-noninteractive-element-interactions\n <label\n className={`rs-layer-tree-input rs-layer-tree-input-${inputType} rs-${inputType}`}\n tabIndex={tabIndex}\n title={layer.visible ? titles.layerHide : titles.layerShow}\n aria-label={layer.visible ? titles.layerHide : titles.layerShow}\n onKeyPress={(e) => {\n if (e.which === 13) {\n this.onInputClick(layer);\n }\n }}\n >\n <input\n type={inputType}\n tabIndex={-1}\n checked={layer.visible}\n readOnly\n onClick={() => {\n return this.onInputClick(layer);\n }}\n />\n <span />\n </label>\n );\n }\n\n renderArrow(layer) {\n const { isItemHidden } = this.props;\n const { expandedLayers } = this.state;\n\n if (\n !(layer.children || []).filter((c) => {\n return !isItemHidden(c);\n }).length ||\n layer.get('isAlwaysExpanded')\n ) {\n return null;\n }\n\n return (\n <div\n className={`rs-layer-tree-arrow rs-layer-tree-arrow-${\n !expandedLayers.includes(layer) ? 'collapsed' : 'expanded'\n }`}\n />\n );\n }\n\n // Render a button which expands/collapse the layer if there is children\n // or simulate a click on the input otherwise.\n renderToggleButton(layer) {\n const { t, titles, isItemHidden, renderLabel } = this.props;\n const { expandedLayers } = this.state;\n\n const onInputClick = () => {\n this.onInputClick(\n layer,\n (layer.children || []).filter((c) => {\n return !isItemHidden(c);\n }).length && !layer.get('isAlwaysExpanded'),\n );\n };\n const title = `${t(layer.name)} ${\n expandedLayers.includes(layer) ? titles.subLayerHide : titles.subLayerShow\n }`;\n\n return (\n <div\n role=\"button\"\n tabIndex={0}\n className=\"rs-layer-tree-toggle\"\n title={title}\n aria-expanded={expandedLayers.includes(layer)}\n aria-label={title}\n onClick={onInputClick}\n onKeyPress={onInputClick}\n >\n <div>{renderLabel(layer, this)}</div>\n {this.renderArrow(layer)}\n </div>\n );\n }\n\n renderItemContent(layer) {\n return (\n <>\n {this.renderInput(layer)}\n {this.renderToggleButton(layer)}\n </>\n );\n }\n\n renderItem(layer, level) {\n const { isItemHidden } = this.props;\n const { expandedLayers } = this.state;\n const {\n renderItem,\n renderItemContent,\n renderBeforeItem,\n renderAfterItem,\n padding,\n getParentClassName,\n } = this.props;\n\n const children = expandedLayers.includes(layer)\n ? [\n ...(layer.children || []).filter((c) => {\n return !isItemHidden(c);\n }),\n ]\n : [];\n\n if (renderItem) {\n return renderItem(layer, this.onInputClick, this.onToggle);\n }\n\n return (\n <div className={getParentClassName()} key={layer.key}>\n <div\n className={`rs-layer-tree-item ${layer.visible ? 'rs-visible' : ''}`}\n style={{\n paddingLeft: `${padding * level}px`,\n }}\n >\n {renderItemContent\n ? renderItemContent(layer, this)\n : this.renderItemContent(layer)}\n </div>\n {renderBeforeItem && renderBeforeItem(layer, level, this)}\n {[...children].reverse().map((child) => {\n return this.renderItem(child, level + 1);\n })}\n {renderAfterItem && renderAfterItem(layer, level, this)}\n </div>\n );\n }\n\n renderTree() {\n const { isItemHidden } = this.props;\n const { rootLayer } = this.state;\n\n if (!rootLayer?.children?.length) {\n return null;\n }\n\n return (\n <>\n {rootLayer.children\n .filter((l) => {\n return !isItemHidden(l);\n })\n .reverse()\n .map((l) => {\n return this.renderItem(l, 0);\n })}\n </>\n );\n }\n\n render() {\n const { className } = this.props;\n return <div className={className}>{this.renderTree()}</div>;\n }\n}\n\nLayerTree.propTypes = propTypes;\nLayerTree.defaultProps = defaultProps;\n\nexport default LayerTree;\n"],
|
|
5
|
+
"mappings": "AAAA,OAAO,SAAS,iBAAiB;AACjC,OAAO,eAAe;AACtB,SAAS,OAAO,4BAA4B;AAC5C,SAAS,eAAe;AAExB,MAAM,YAAY;AAAA,EAIhB,QAAQ,UAAU,QAAQ,KAAK;AAAA,EAK/B,WAAW,UAAU;AAAA,EAKrB,SAAS,UAAU;AAAA,EASnB,cAAc,UAAU;AAAA,EAKxB,oBAA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A,IAC3D;AAEA,WACE,oCAAC;AAAA,MAAI,WAAW,mBAAmB;AAAA,MAAG,KAAK,MAAM;AAAA,OAC/C,oCAAC;AAAA,MACC,WAAW,sBAAsB,MAAM,UAAU,eAAe;AAAA,MAChE,OAAO;AAAA,QACL,aAAa,GAAG,UAAU;AAAA,MAC5B;AAAA,OAEC,oBACG,kBAAkB,OAAO,IAAI,IAC7B,KAAK,kBAAkB,KAAK,CAClC,GACC,oBAAoB,iBAAiB,OAAO,OAAO,IAAI,GACvD,CAAC,GAAG,QAAQ,EAAE,QAAQ,EAAE,IAAI,CAAC,UAAU;AACtC,aAAO,KAAK,WAAW,OAAO,QAAQ,CAAC;AAAA,IACzC,CAAC,GACA,mBAAmB,gBAAgB,OAAO,OAAO,IAAI,CACxD;AAAA,EAEJ;AAAA,EAEA,aAAa;AACX,UAAM,EAAE,aAAa,IAAI,KAAK;AAC9B,UAAM,EAAE,UAAU,IAAI,KAAK;AAE3B,QAAI,CAAC,WAAW,UAAU,QAAQ;AAChC,aAAO;AAAA,IACT;AAEA,WACE,0DACG,UAAU,SACR,OAAO,CAAC,MAAM;AACb,aAAO,CAAC,aAAa,CAAC;AAAA,IACxB,CAAC,EACA,QAAQ,EACR,IAAI,CAAC,MAAM;AACV,aAAO,KAAK,WAAW,GAAG,CAAC;AAAA,IAC7B,CAAC,CACL;AAAA,EAEJ;AAAA,EAEA,SAAS;AACP,UAAM,EAAE,UAAU,IAAI,KAAK;AAC3B,WAAO,oCAAC;AAAA,MAAI;AAAA,OAAuB,KAAK,WAAW,CAAE;AAAA,EACvD;AACF;AAEA,UAAU,YAAY;AACtB,UAAU,eAAe;AAEzB,eAAe;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/LayerTree/index.js"],
|
|
4
|
+
"sourcesContent": ["export { default } from './LayerTree';\n"],
|
|
5
|
+
"mappings": "AAAA,wBAAwB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,146 +1,83 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var propTypes = {
|
|
9
|
-
/**
|
|
10
|
-
* An [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html).
|
|
11
|
-
*/
|
|
1
|
+
import React, { useState, useRef, useEffect, useCallback } from "react";
|
|
2
|
+
import PropTypes from "prop-types";
|
|
3
|
+
import OLMap from "ol/Map";
|
|
4
|
+
import { createStringXY } from "ol/coordinate";
|
|
5
|
+
import OLMousePosition from "ol/control/MousePosition";
|
|
6
|
+
const propTypes = {
|
|
12
7
|
map: PropTypes.instanceOf(OLMap).isRequired,
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* List of projections to display.
|
|
16
|
-
*/
|
|
17
8
|
projections: PropTypes.arrayOf(
|
|
18
9
|
PropTypes.shape({
|
|
19
|
-
/**
|
|
20
|
-
* The label to display in the select box.
|
|
21
|
-
*/
|
|
22
10
|
label: PropTypes.string.isRequired,
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* The value used to create the options´s projection of the MousePosition control.
|
|
26
|
-
* See [doc](https://openlayers.org/en/latest/apidoc/module-ol_control_MousePosition.html).
|
|
27
|
-
*/
|
|
28
11
|
value: PropTypes.string.isRequired,
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* A function following the [CoordinateFormat](https://openlayers.org/en/latest/apidoc/module-ol_coordinate.html#~CoordinateFormat).
|
|
32
|
-
*/
|
|
33
|
-
format: PropTypes.func,
|
|
12
|
+
format: PropTypes.func
|
|
34
13
|
})
|
|
35
14
|
),
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* The initially selected projection
|
|
39
|
-
*/
|
|
40
15
|
projectionValue: PropTypes.shape({
|
|
41
|
-
/**
|
|
42
|
-
* The label to display in the select box.
|
|
43
|
-
*/
|
|
44
16
|
label: PropTypes.string.isRequired,
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* The value used to create the options´s projection of the MousePosition control.
|
|
48
|
-
* See [doc](https://openlayers.org/en/latest/apidoc/module-ol_control_MousePosition.html).
|
|
49
|
-
*/
|
|
50
17
|
value: PropTypes.string.isRequired,
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* A function following the [CoordinateFormat](https://openlayers.org/en/latest/apidoc/module-ol_coordinate.html#~CoordinateFormat).
|
|
54
|
-
*/
|
|
55
|
-
format: PropTypes.func,
|
|
18
|
+
format: PropTypes.func
|
|
56
19
|
}),
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Function triggered on projection's change event.
|
|
60
|
-
* @param {Event} event The change event object.
|
|
61
|
-
* @param {Object} projection The selected projection object.
|
|
62
|
-
*/
|
|
63
|
-
onChange: PropTypes.func,
|
|
20
|
+
onChange: PropTypes.func
|
|
64
21
|
};
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
22
|
+
const defaultProps = {
|
|
23
|
+
onChange: () => {
|
|
24
|
+
},
|
|
68
25
|
projections: [
|
|
69
26
|
{
|
|
70
|
-
label:
|
|
71
|
-
value:
|
|
27
|
+
label: "EPSG:4326",
|
|
28
|
+
value: "EPSG:4326"
|
|
72
29
|
},
|
|
73
30
|
{
|
|
74
|
-
label:
|
|
75
|
-
value:
|
|
76
|
-
}
|
|
77
|
-
|
|
31
|
+
label: "EPSG:3857",
|
|
32
|
+
value: "EPSG:3857"
|
|
33
|
+
}
|
|
34
|
+
],
|
|
35
|
+
projectionValue: null
|
|
78
36
|
};
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
var other = rest;
|
|
91
|
-
|
|
92
|
-
var ref$2 = useState(
|
|
93
|
-
projections &&
|
|
94
|
-
((projectionValue &&
|
|
95
|
-
projections.find(function (p) {
|
|
96
|
-
return p.value === projectionValue.value;
|
|
97
|
-
})) ||
|
|
98
|
-
projections[0])
|
|
37
|
+
function MousePosition({
|
|
38
|
+
map,
|
|
39
|
+
projections,
|
|
40
|
+
projectionValue,
|
|
41
|
+
onChange,
|
|
42
|
+
...other
|
|
43
|
+
}) {
|
|
44
|
+
const [projection, setProjection] = useState(
|
|
45
|
+
projections && (projectionValue && projections.find((p) => {
|
|
46
|
+
return p.value === projectionValue.value;
|
|
47
|
+
}) || projections[0])
|
|
99
48
|
);
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
var setControl = ref$3[1];
|
|
105
|
-
var ref = useRef();
|
|
106
|
-
|
|
107
|
-
useEffect(function () {
|
|
108
|
-
var mousePosition = new OLMousePosition({
|
|
49
|
+
const [control, setControl] = useState();
|
|
50
|
+
const ref = useRef();
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
const mousePosition = new OLMousePosition({
|
|
109
53
|
target: ref.current,
|
|
110
|
-
undefinedHTML:
|
|
111
|
-
className:
|
|
54
|
+
undefinedHTML: " ",
|
|
55
|
+
className: ""
|
|
112
56
|
});
|
|
113
57
|
map.addControl(mousePosition);
|
|
114
58
|
setControl(mousePosition);
|
|
115
|
-
|
|
116
|
-
return function () {
|
|
59
|
+
return () => {
|
|
117
60
|
map.removeControl(mousePosition);
|
|
118
61
|
};
|
|
119
62
|
}, [map]);
|
|
120
|
-
|
|
121
|
-
useEffect(function () {
|
|
63
|
+
useEffect(() => {
|
|
122
64
|
if (!projection || !control) {
|
|
123
65
|
return;
|
|
124
66
|
}
|
|
125
67
|
control.setProjection(projection.value);
|
|
126
68
|
control.setCoordinateFormat(projection.format || createStringXY(4));
|
|
127
69
|
}, [projection, control]);
|
|
128
|
-
|
|
129
|
-
useEffect(function () {
|
|
70
|
+
useEffect(() => {
|
|
130
71
|
if (projections) {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
return p.value === projectionValue.value;
|
|
135
|
-
})) ||
|
|
136
|
-
projections[0];
|
|
72
|
+
const proj = projectionValue && projections.find((p) => {
|
|
73
|
+
return p.value === projectionValue.value;
|
|
74
|
+
}) || projections[0];
|
|
137
75
|
setProjection(proj);
|
|
138
76
|
}
|
|
139
77
|
}, [projections, projectionValue]);
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
var newProj = projections.find(function (opt) {
|
|
78
|
+
const onChangeCb = useCallback(
|
|
79
|
+
(evt) => {
|
|
80
|
+
const newProj = projections.find((opt) => {
|
|
144
81
|
return evt.target.value === opt.value;
|
|
145
82
|
});
|
|
146
83
|
setProjection(newProj);
|
|
@@ -148,32 +85,26 @@ function MousePosition(ref$1) {
|
|
|
148
85
|
},
|
|
149
86
|
[onChange, projections]
|
|
150
87
|
);
|
|
151
|
-
|
|
152
88
|
if (!projection || !projections || !projections.length) {
|
|
153
89
|
return null;
|
|
154
90
|
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
);
|
|
91
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
92
|
+
className: "rs-mouse-position",
|
|
93
|
+
...other
|
|
94
|
+
}, /* @__PURE__ */ React.createElement("select", {
|
|
95
|
+
className: "rs-select",
|
|
96
|
+
value: projection.value,
|
|
97
|
+
onChange: onChangeCb
|
|
98
|
+
}, projections.map((option) => {
|
|
99
|
+
return /* @__PURE__ */ React.createElement("option", {
|
|
100
|
+
key: option.value,
|
|
101
|
+
value: option.value
|
|
102
|
+
}, option.label);
|
|
103
|
+
})), /* @__PURE__ */ React.createElement("span", {
|
|
104
|
+
ref,
|
|
105
|
+
className: "rs-coordinates"
|
|
106
|
+
}));
|
|
172
107
|
}
|
|
173
|
-
|
|
174
108
|
MousePosition.propTypes = propTypes;
|
|
175
109
|
MousePosition.defaultProps = defaultProps;
|
|
176
|
-
|
|
177
110
|
export default React.memo(MousePosition);
|
|
178
|
-
|
|
179
|
-
//# sourceMappingURL=MousePosition.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/MousePosition/MousePosition.js"],
|
|
4
|
+
"sourcesContent": ["import React, { useState, useRef, useEffect, useCallback } from 'react';\nimport PropTypes from 'prop-types';\nimport OLMap from 'ol/Map';\nimport { createStringXY } from 'ol/coordinate';\nimport OLMousePosition from 'ol/control/MousePosition';\n\nconst propTypes = {\n /**\n * An [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html).\n */\n map: PropTypes.instanceOf(OLMap).isRequired,\n\n /**\n * List of projections to display.\n */\n projections: PropTypes.arrayOf(\n PropTypes.shape({\n /**\n * The label to display in the select box.\n */\n label: PropTypes.string.isRequired,\n\n /**\n * The value used to create the options\u00B4s projection of the MousePosition control.\n * See [doc](https://openlayers.org/en/latest/apidoc/module-ol_control_MousePosition.html).\n */\n value: PropTypes.string.isRequired,\n\n /**\n * A function following the [CoordinateFormat](https://openlayers.org/en/latest/apidoc/module-ol_coordinate.html#~CoordinateFormat).\n */\n format: PropTypes.func,\n }),\n ),\n\n /**\n * The initially selected projection\n */\n projectionValue: PropTypes.shape({\n /**\n * The label to display in the select box.\n */\n label: PropTypes.string.isRequired,\n\n /**\n * The value used to create the options\u00B4s projection of the MousePosition control.\n * See [doc](https://openlayers.org/en/latest/apidoc/module-ol_control_MousePosition.html).\n */\n value: PropTypes.string.isRequired,\n\n /**\n * A function following the [CoordinateFormat](https://openlayers.org/en/latest/apidoc/module-ol_coordinate.html#~CoordinateFormat).\n */\n format: PropTypes.func,\n }),\n\n /**\n * Function triggered on projection's change event.\n * @param {Event} event The change event object.\n * @param {Object} projection The selected projection object.\n */\n onChange: PropTypes.func,\n};\n\nconst defaultProps = {\n onChange: () => {},\n projections: [\n {\n label: 'EPSG:4326',\n value: 'EPSG:4326',\n },\n {\n label: 'EPSG:3857',\n value: 'EPSG:3857',\n },\n ],\n projectionValue: null,\n};\n\n/**\n * The MousePosition component renders a select box with map projection options\n * and the cursor position in coordinates using the selected projection.\n */\nfunction MousePosition({\n map,\n projections,\n projectionValue,\n onChange,\n ...other\n}) {\n const [projection, setProjection] = useState(\n projections &&\n ((projectionValue &&\n projections.find((p) => {\n return p.value === projectionValue.value;\n })) ||\n projections[0]),\n );\n const [control, setControl] = useState();\n const ref = useRef();\n\n useEffect(() => {\n const mousePosition = new OLMousePosition({\n target: ref.current,\n undefinedHTML: ' ',\n className: '',\n });\n map.addControl(mousePosition);\n setControl(mousePosition);\n\n return () => {\n map.removeControl(mousePosition);\n };\n }, [map]);\n\n useEffect(() => {\n if (!projection || !control) {\n return;\n }\n control.setProjection(projection.value);\n control.setCoordinateFormat(projection.format || createStringXY(4));\n }, [projection, control]);\n\n useEffect(() => {\n if (projections) {\n const proj =\n (projectionValue &&\n projections.find((p) => {\n return p.value === projectionValue.value;\n })) ||\n projections[0];\n setProjection(proj);\n }\n }, [projections, projectionValue]);\n\n const onChangeCb = useCallback(\n (evt) => {\n const newProj = projections.find((opt) => {\n return evt.target.value === opt.value;\n });\n setProjection(newProj);\n onChange(evt, newProj);\n },\n [onChange, projections],\n );\n\n if (!projection || !projections || !projections.length) {\n return null;\n }\n\n return (\n // eslint-disable-next-line react/jsx-props-no-spreading\n <div className=\"rs-mouse-position\" {...other}>\n <select\n className=\"rs-select\"\n value={projection.value}\n onChange={onChangeCb}\n >\n {projections.map((option) => {\n return (\n <option key={option.value} value={option.value}>\n {option.label}\n </option>\n );\n })}\n </select>\n <span ref={ref} className=\"rs-coordinates\" />\n </div>\n );\n}\n\nMousePosition.propTypes = propTyp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YAAY;AAC1B,cAAc,eAAe;AAE7B,eAAe,MAAM,KAAK,aAAa;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/MousePosition/index.js"],
|
|
4
|
+
"sourcesContent": ["export { default } from './MousePosition';\n"],
|
|
5
|
+
"mappings": "AAAA,wBAAwB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,83 +1,43 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var propTypes = {
|
|
11
|
-
/**
|
|
12
|
-
* An [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html).
|
|
13
|
-
*/
|
|
1
|
+
import React, { useEffect, useState } from "react";
|
|
2
|
+
import PropTypes from "prop-types";
|
|
3
|
+
import OLMap from "ol/Map";
|
|
4
|
+
import { unByKey } from "ol/Observable";
|
|
5
|
+
import degrees from "radians-degrees";
|
|
6
|
+
import NorthArrowSimple from "../../images/northArrow.svg";
|
|
7
|
+
import NorthArrowCircle from "../../images/northArrowCircle.svg";
|
|
8
|
+
const propTypes = {
|
|
14
9
|
map: PropTypes.instanceOf(OLMap).isRequired,
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Rotation of the north arrow in degrees.
|
|
18
|
-
*/
|
|
19
10
|
rotationOffset: PropTypes.number,
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Display circle around the north arrow. Not used if pass children.
|
|
23
|
-
*/
|
|
24
11
|
circled: PropTypes.bool,
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Children content of the north arrow.
|
|
28
|
-
*/
|
|
29
|
-
children: PropTypes.node,
|
|
12
|
+
children: PropTypes.node
|
|
30
13
|
};
|
|
31
|
-
|
|
32
|
-
var defaultProps = {
|
|
14
|
+
const defaultProps = {
|
|
33
15
|
rotationOffset: 0,
|
|
34
16
|
circled: false,
|
|
35
|
-
children: null
|
|
17
|
+
children: null
|
|
36
18
|
};
|
|
37
|
-
|
|
38
|
-
var getRotation = function (map, rotationOffset) {
|
|
19
|
+
const getRotation = (map, rotationOffset) => {
|
|
39
20
|
return degrees(map.getView().getRotation()) + rotationOffset;
|
|
40
21
|
};
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
* [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html).
|
|
45
|
-
*/
|
|
46
|
-
function NorthArrow(ref) {
|
|
47
|
-
var map = ref.map;
|
|
48
|
-
var rotationOffset = ref.rotationOffset;
|
|
49
|
-
var circled = ref.circled;
|
|
50
|
-
var children = ref.children;
|
|
51
|
-
var rest = objectWithoutProperties( ref, ["map", "rotationOffset", "circled", "children"] );
|
|
52
|
-
var other = rest;
|
|
53
|
-
|
|
54
|
-
var ref$1 = useState(rotationOffset);
|
|
55
|
-
var rotation = ref$1[0];
|
|
56
|
-
var setRotation = ref$1[1];
|
|
57
|
-
|
|
58
|
-
useEffect(function () {
|
|
22
|
+
function NorthArrow({ map, rotationOffset, circled, children, ...other }) {
|
|
23
|
+
const [rotation, setRotation] = useState(rotationOffset);
|
|
24
|
+
useEffect(() => {
|
|
59
25
|
if (!map) {
|
|
60
26
|
return null;
|
|
61
27
|
}
|
|
62
|
-
|
|
28
|
+
const key = map.on("postrender", () => {
|
|
63
29
|
setRotation(getRotation(map, rotationOffset));
|
|
64
30
|
});
|
|
65
|
-
return
|
|
31
|
+
return () => {
|
|
66
32
|
unByKey(key);
|
|
67
33
|
};
|
|
68
34
|
}, [map, rotationOffset]);
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
)
|
|
75
|
-
);
|
|
35
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
36
|
+
className: "rs-north-arrow",
|
|
37
|
+
...other,
|
|
38
|
+
style: { transform: `rotate(${rotation}deg)` }
|
|
39
|
+
}, children || (circled ? /* @__PURE__ */ React.createElement(NorthArrowCircle, null) : /* @__PURE__ */ React.createElement(NorthArrowSimple, null)));
|
|
76
40
|
}
|
|
77
|
-
|
|
78
41
|
NorthArrow.propTypes = propTypes;
|
|
79
42
|
NorthArrow.defaultProps = defaultProps;
|
|
80
|
-
|
|
81
43
|
export default React.memo(NorthArrow);
|
|
82
|
-
|
|
83
|
-
//# sourceMappingURL=NorthArrow.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/NorthArrow/NorthArrow.js"],
|
|
4
|
+
"sourcesContent": ["import React, { useEffect, useState } from 'react';\nimport PropTypes from 'prop-types';\nimport OLMap from 'ol/Map';\nimport { unByKey } from 'ol/Observable';\nimport degrees from 'radians-degrees';\nimport NorthArrowSimple from '../../images/northArrow.svg';\nimport NorthArrowCircle from '../../images/northArrowCircle.svg';\n\nconst propTypes = {\n /**\n * An [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html).\n */\n map: PropTypes.instanceOf(OLMap).isRequired,\n\n /**\n * Rotation of the north arrow in degrees.\n */\n rotationOffset: PropTypes.number,\n\n /**\n * Display circle around the north arrow. Not used if pass children.\n */\n circled: PropTypes.bool,\n\n /**\n * Children content of the north arrow.\n */\n children: PropTypes.node,\n};\n\nconst defaultProps = {\n rotationOffset: 0,\n circled: false,\n children: null,\n};\n\nconst getRotation = (map, rotationOffset) => {\n return degrees(map.getView().getRotation()) + rotationOffset;\n};\n\n/**\n * This NorthArrow component inserts an arrow pointing north into an\n * [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html).\n */\nfunction NorthArrow({ map, rotationOffset, circled, children, ...other }) {\n const [rotation, setRotation] = useState(rotationOffset);\n\n useEffect(() => {\n if (!map) {\n return null;\n }\n const key = map.on('postrender', () => {\n setRotation(getRotation(map, rotationOffset));\n });\n return () => {\n unByKey(key);\n };\n }, [map, rotationOffset]);\n\n return (\n <div\n className=\"rs-north-arrow\"\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...other}\n style={{ transform: `rotate(${rotation}deg)` }}\n >\n {children || (circled ? <NorthArrowCircle /> : <NorthArrowSimple />)}\n </div>\n );\n}\n\nNorthArrow.propTypes = propTypes;\nNorthArrow.defaultProps = defaultProps;\n\nexport default React.memo(NorthArrow);\n"],
|
|
5
|
+
"mappings": "AAAA,OAAO,SAAS,WAAW,gBAAgB;AAC3C,OAAO,eAAe;AACtB,OAAO,WAAW;AAClB,SAAS,eAAe;AACxB,OAAO,aAAa;AACpB,OAAO,sBAAsB;AAC7B,OAAO,sBAAsB;AAE7B,MAAM,YAAY;AAAA,EAIhB,KAAK,UAAU,WAAW,KAAK,EAAE;AAAA,EAKjC,gBAAgB,UAAU;AAAA,EAK1B,SAAS,UAAU;AAAA,EAKnB,UAAU,UAAU;AACtB;AAEA,MAAM,eAAe;AAAA,EACnB,gBAAgB;AAAA,EAChB,SAAS;AAAA,EACT,UAAU;AACZ;AAEA,MAAM,cAAc,CAAC,KAAK,mBAAmB;AAC3C,SAAO,QAAQ,IAAI,QAAQ,EAAE,YAAY,CAAC,IAAI;AAChD;AAMA,SAAS,WAAW,EAAE,KAAK,gBAAgB,SAAS,aAAa,MAAM,GAAG;AACxE,QAAM,CAAC,UAAU,WAAW,IAAI,SAAS,cAAc;AAEvD,YAAU,MAAM;AACd,QAAI,CAAC,KAAK;AACR,aAAO;AAAA,IACT;AACA,UAAM,MAAM,IAAI,GAAG,cAAc,MAAM;AACrC,kBAAY,YAAY,KAAK,cAAc,CAAC;AAAA,IAC9C,CAAC;AACD,WAAO,MAAM;AACX,cAAQ,GAAG;AAAA,IACb;AAAA,EACF,GAAG,CAAC,KAAK,cAAc,CAAC;AAExB,SACE,oCAAC;AAAA,IACC,WAAU;AAAA,IAET,GAAG;AAAA,IACJ,OAAO,EAAE,WAAW,UAAU,eAAe;AAAA,KAE5C,aAAa,UAAU,oCAAC,sBAAiB,IAAK,oCAAC,sBAAiB,EACnE;AAEJ;AAEA,WAAW,YAAY;AACvB,WAAW,eAAe;AAE1B,eAAe,MAAM,KAAK,UAAU;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/NorthArrow/index.js"],
|
|
4
|
+
"sourcesContent": ["export { default } from './NorthArrow';\n"],
|
|
5
|
+
"mappings": "AAAA,wBAAwB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|