@eeacms/volto-eea-map 4.0.0 → 5.0.0

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.
Files changed (73) hide show
  1. package/CHANGELOG.md +36 -1
  2. package/package.json +6 -3
  3. package/src/Arcgis/Editor/Editor.jsx +130 -0
  4. package/src/Arcgis/Editor/EditorContext.jsx +2 -0
  5. package/src/Arcgis/Editor/Fold/Fold.jsx +56 -0
  6. package/src/Arcgis/Editor/Panels/Panel.jsx +8 -0
  7. package/src/Arcgis/Editor/Panels/SettingsGeneralPanel.jsx +217 -0
  8. package/src/Arcgis/Editor/Panels/SettingsLayersPanel.jsx +216 -0
  9. package/src/Arcgis/Editor/Panels/StructureBaseLayerPanel.jsx +60 -0
  10. package/src/Arcgis/Editor/Panels/StructureLayersPanel.jsx +394 -0
  11. package/src/Arcgis/Editor/Panels/StructureWidgetsPanel.jsx +181 -0
  12. package/src/Arcgis/Editor/Panels/index.js +6 -0
  13. package/src/Arcgis/Editor/SidebarGroup.jsx +62 -0
  14. package/src/Arcgis/Layer/Layer.jsx +247 -0
  15. package/src/Arcgis/Map/Map.jsx +287 -0
  16. package/src/Arcgis/Map/MapBuilder.jsx +111 -0
  17. package/src/Arcgis/Map/MapContext.jsx +3 -0
  18. package/src/Arcgis/Widget/Widget.jsx +170 -0
  19. package/src/Arcgis/helpers.js +140 -0
  20. package/src/Blocks/EmbedEEAMap/Edit.jsx +40 -0
  21. package/src/Blocks/EmbedEEAMap/View.jsx +122 -0
  22. package/src/Blocks/EmbedEEAMap/helpers.js +12 -0
  23. package/src/Blocks/EmbedEEAMap/schema.js +126 -0
  24. package/src/{components → Toolbar}/Share.jsx +1 -1
  25. package/src/{components/ExtraViews.jsx → Toolbar/Toolbar.jsx} +14 -16
  26. package/src/{components/visualization → Views}/VisualizationView.jsx +8 -9
  27. package/src/Widgets/ArcgisColorPickerWidget.jsx +95 -0
  28. package/src/Widgets/ArcgisRendererWidget/ArcgisRendererWidget.jsx +106 -0
  29. package/src/Widgets/ArcgisRendererWidget/RendererEditor/ClassBreaks.jsx +8 -0
  30. package/src/Widgets/ArcgisRendererWidget/RendererEditor/Dictionary.jsx +8 -0
  31. package/src/Widgets/ArcgisRendererWidget/RendererEditor/DotDensity.jsx +8 -0
  32. package/src/Widgets/ArcgisRendererWidget/RendererEditor/Heatmap.jsx +8 -0
  33. package/src/Widgets/ArcgisRendererWidget/RendererEditor/PieChart.jsx +8 -0
  34. package/src/Widgets/ArcgisRendererWidget/RendererEditor/Simple.jsx +109 -0
  35. package/src/Widgets/ArcgisRendererWidget/RendererEditor/UniqueValue.jsx +8 -0
  36. package/src/Widgets/ArcgisRendererWidget/RendererEditor/_Editor.jsx +29 -0
  37. package/src/Widgets/ArcgisRendererWidget/RendererEditor/_EditorModal.jsx +88 -0
  38. package/src/Widgets/ArcgisRendererWidget/RendererEditor/_defaults.js +30 -0
  39. package/src/Widgets/ArcgisSliderWidget.jsx +79 -0
  40. package/src/Widgets/ArcgisViewpointWidget.jsx +112 -0
  41. package/src/{components/visualization → Widgets}/VisualizationViewWidget.jsx +9 -10
  42. package/src/Widgets/VisualizationWidget.jsx +200 -0
  43. package/src/arcgis.js +48 -0
  44. package/src/constants.js +225 -7
  45. package/src/hocs/withArcgis.jsx +27 -0
  46. package/src/hooks/useChangedProps.jsx +24 -0
  47. package/src/hooks/useClass.jsx +17 -0
  48. package/src/hooks/useCopyToClipboard.jsx +25 -0
  49. package/src/index.js +16 -16
  50. package/src/jsoneditor.js +72 -0
  51. package/src/styles/editor.less +446 -0
  52. package/src/styles/map.less +3 -0
  53. package/src/components/Blocks/EmbedEEAMap/Edit.jsx +0 -161
  54. package/src/components/Blocks/EmbedEEAMap/Schema.js +0 -161
  55. package/src/components/Blocks/EmbedEEAMap/View.jsx +0 -79
  56. package/src/components/Blocks/EmbedEEAMap/helpers.js +0 -45
  57. package/src/components/LegendView.jsx +0 -150
  58. package/src/components/Webmap.jsx +0 -365
  59. package/src/components/index.js +0 -6
  60. package/src/components/visualization/VisualizationEditorWidget.jsx +0 -122
  61. package/src/components/visualization/panelsSchema.js +0 -229
  62. package/src/components/widgets/DataQueryWidget.jsx +0 -51
  63. package/src/components/widgets/LayerSelectWidget.jsx +0 -456
  64. package/src/components/widgets/LayersPanelWidget.jsx +0 -59
  65. package/src/components/widgets/SimpleColorPickerWidget.jsx +0 -121
  66. package/src/hocs/index.js +0 -3
  67. package/src/hocs/withDeviceSize.jsx +0 -45
  68. package/src/less/global.less +0 -253
  69. package/src/less/variables.less +0 -5
  70. package/src/utils.js +0 -151
  71. /package/src/{components → Toolbar}/FigureNote.jsx +0 -0
  72. /package/src/{components → Toolbar}/MoreInfoLink.jsx +0 -0
  73. /package/src/{components → Toolbar}/Sources.jsx +0 -0
@@ -1,161 +0,0 @@
1
- const ProtectionSchema = () => ({
2
- title: 'Data Protection',
3
-
4
- fieldsets: [
5
- {
6
- id: 'default',
7
- title: 'Default',
8
- fields: [
9
- 'privacy_statement',
10
- 'privacy_cookie_key',
11
- 'enabled',
12
- 'background_image',
13
- ],
14
- },
15
- ],
16
-
17
- properties: {
18
- privacy_statement: {
19
- title: 'Privacy statement',
20
- description: 'Defined in template. Change only if necessary',
21
- widget: 'slate_richtext',
22
- className: 'slate-Widget',
23
- defaultValue: [
24
- {
25
- children: [
26
- {
27
- text: 'This map is hosted by a third party, Environmental Systems Research Institute. By showing the external content you accept the terms and conditions of ',
28
- },
29
- {
30
- type: 'a',
31
- url: 'https://www.esri.com',
32
- children: [
33
- {
34
- text: 'esri.com',
35
- },
36
- ],
37
- },
38
- {
39
- text: '. This includes their cookie policies, which we have no control over.',
40
- },
41
- ],
42
- },
43
- ],
44
- },
45
- privacy_cookie_key: {
46
- title: 'Privacy cookie key',
47
- description: 'Use default for Esri maps, otherwise change',
48
- defaultValue: 'esri-maps',
49
- },
50
- enabled: {
51
- title: 'Data protection disclaimer enabled',
52
- description: 'Enable/disable the privacy protection',
53
- type: 'boolean',
54
- },
55
- background_image: {
56
- title: 'Static map preview image',
57
- widget: 'file',
58
- required: true,
59
- },
60
- },
61
-
62
- required: ['background_image'],
63
- });
64
-
65
- export const Schema = (props) => {
66
- return {
67
- title: 'Embed Map layers (ArcGis)',
68
- fieldsets: [
69
- {
70
- id: 'default',
71
- title: 'Default',
72
- fields: [
73
- 'vis_url',
74
- 'description',
75
- 'height',
76
- 'enable_queries',
77
- ...(props.data.enable_queries ? ['data_query_params'] : []),
78
- ],
79
- },
80
- {
81
- id: 'toolbar',
82
- title: 'Toolbar',
83
- fields: [
84
- 'show_legend',
85
- 'show_viewer',
86
- 'show_note',
87
- 'show_more_info',
88
- 'show_share',
89
- ],
90
- },
91
- {
92
- fields: ['dataprotection'],
93
- title: 'Data Protection',
94
- },
95
- ],
96
- properties: {
97
- vis_url: {
98
- widget: 'internal_url',
99
- title: 'Visualization',
100
- },
101
- height: {
102
- title: 'Height',
103
- description:
104
- 'Map block height in px. Default is 500px. Change only if necessary',
105
- type: 'number',
106
- },
107
- description: {
108
- title: 'Description',
109
- widget: 'slate',
110
- },
111
- show_note: {
112
- title: 'Show note',
113
- type: 'boolean',
114
- defaultValue: true,
115
- },
116
- show_sources: {
117
- title: 'Show sources',
118
- description: 'Will show sources set in this page Data provenance',
119
- type: 'boolean',
120
- defaultValue: true,
121
- },
122
- show_more_info: {
123
- title: 'Show more info',
124
- type: 'boolean',
125
- defaultValue: true,
126
- },
127
- show_share: {
128
- title: 'Show share button',
129
- type: 'boolean',
130
- defaultValue: true,
131
- },
132
- show_legend: {
133
- title: 'Show legend',
134
- type: 'boolean',
135
- },
136
- show_viewer: {
137
- title: 'Show API link',
138
- description: 'Open the map on ArcGIS js service',
139
- type: 'boolean',
140
- },
141
- enable_queries: {
142
- title: 'Enable queries',
143
- description:
144
- 'Will import Criteria from content-type and try to query map layer fields.',
145
- type: 'boolean',
146
- },
147
- data_query_params: {
148
- title: 'Query parameters',
149
- description:
150
- 'When using page level parameters to filter the map, please map those to the corresponding field name from the ArcGIS service',
151
- widget: 'data_query_widget',
152
- },
153
- dataprotection: {
154
- widget: 'object',
155
- schema: ProtectionSchema(),
156
- default: { enabled: true },
157
- },
158
- },
159
- required: [],
160
- };
161
- };
@@ -1,79 +0,0 @@
1
- import React, { useMemo } from 'react';
2
- import { PrivacyProtection } from '@eeacms/volto-embed';
3
- import Webmap from '@eeacms/volto-eea-map/components/Webmap';
4
- import ExtraViews from '@eeacms/volto-eea-map/components/ExtraViews';
5
- import { applyQueriesToMapLayers } from '@eeacms/volto-eea-map/utils';
6
-
7
- import { getMapVisualizationData } from './helpers';
8
-
9
- const View = (props) => {
10
- const { data } = props;
11
- const {
12
- data_query_params,
13
- enable_queries,
14
- show_legend = true,
15
- show_note = true,
16
- show_more_info = true,
17
- show_share = true,
18
- dataprotection = { enabled: true },
19
- height = '',
20
- } = data;
21
-
22
- const map_visualization_data = useMemo(
23
- () => getMapVisualizationData(props),
24
- [props],
25
- );
26
-
27
- const [mapData, setMapData] = React.useState('');
28
-
29
- React.useEffect(() => {
30
- const updatedMapData = applyQueriesToMapLayers(
31
- map_visualization_data,
32
- data_query_params,
33
- enable_queries,
34
- );
35
- setMapData(updatedMapData);
36
- }, [map_visualization_data, data_query_params, enable_queries]);
37
-
38
- const mapUrl = map_visualization_data?.layers?.map_layers[0]?.map_layer
39
- ?.map_service_url
40
- ? `${map_visualization_data.layers.map_layers[0].map_layer.map_service_url}?f=jsapi`
41
- : '';
42
-
43
- if (map_visualization_data?.error) {
44
- return (
45
- <p dangerouslySetInnerHTML={{ __html: map_visualization_data.error }} />
46
- );
47
- }
48
-
49
- return (
50
- <PrivacyProtection
51
- className="embed-map-visualization"
52
- {...props}
53
- data={mapUrl ? { ...data, url: mapUrl } : data}
54
- >
55
- {!!mapData && (
56
- <>
57
- <Webmap data={mapData} height={height} />
58
- <ExtraViews
59
- data={{
60
- ...data,
61
- show_legend,
62
- show_note,
63
- show_sources: true,
64
- show_more_info,
65
- show_share,
66
- dataprotection,
67
- map_visualization_data,
68
- }}
69
- />
70
- </>
71
- )}
72
- {!mapData && (
73
- <p>No map view to show. Set visualization in block configuration.</p>
74
- )}
75
- </PrivacyProtection>
76
- );
77
- };
78
-
79
- export default View;
@@ -1,45 +0,0 @@
1
- import { pickMetadata } from '@eeacms/volto-embed/helpers';
2
- // import { updateBlockQueryFromPageQuery } from '@eeacms/volto-eea-map/utils';
3
-
4
- const deepUpdateDataQueryParams = (
5
- block,
6
- data,
7
- effectiveQueryParams,
8
- onChangeBlock,
9
- ) => {
10
- const updatedQueryParams =
11
- effectiveQueryParams &&
12
- effectiveQueryParams.length > 0 &&
13
- effectiveQueryParams.map((param) => {
14
- // Find the matching query in the block's current data_query_params
15
- const existingParam =
16
- data?.data_query_params &&
17
- data.data_query_params.find((p) => p.i === param.i);
18
-
19
- // If found, merge it with the effective query parameter, preserving the alias
20
- return existingParam ? { ...param, alias: existingParam.alias } : param;
21
- });
22
-
23
- // Update the block data if there are changes
24
- if (
25
- JSON.stringify(data.data_query_params) !==
26
- JSON.stringify(updatedQueryParams)
27
- ) {
28
- onChangeBlock(block, {
29
- ...data,
30
- data_query_params: updatedQueryParams,
31
- });
32
- }
33
- };
34
-
35
- function getMapVisualizationData({ mapContent, data }) {
36
- const content = mapContent || {};
37
- const map_visualization_data =
38
- content.map_visualization_data || data?.map_visualization_data || {};
39
- return {
40
- ...pickMetadata(content),
41
- ...map_visualization_data,
42
- };
43
- }
44
-
45
- export { deepUpdateDataQueryParams, getMapVisualizationData };
@@ -1,150 +0,0 @@
1
- import React from 'react';
2
- import { Button, Grid } from 'semantic-ui-react';
3
- import cx from 'classnames';
4
- import { fetchArcGISData, setLegendColumns } from '../utils';
5
- import { serializeNodes } from '@plone/volto-slate/editor/render';
6
-
7
- import { withDeviceSize } from '@eeacms/volto-eea-map/hocs';
8
-
9
- import codeSVG from '@eeacms/volto-eea-map/static/code-line.svg';
10
-
11
- const LayerLegend = ({ data, show_viewer }) => {
12
- const [legendRows, setLegendRows] = React.useState([]);
13
-
14
- const map_service_url =
15
- data && data.map_service_url ? data.map_service_url : '';
16
-
17
- const layer = data && data.layer ? data.layer : {};
18
- const { id, name } = layer || {};
19
-
20
- const fetchLegend = async (url, activeLayerID) => {
21
- let legendData = await fetchArcGISData(url);
22
-
23
- const { layers = [] } = legendData;
24
- const selectedLayer = layers.filter((l, i) => l.layerId === activeLayerID);
25
- setLegendRows(selectedLayer[0].legend);
26
- };
27
-
28
- React.useEffect(() => {
29
- if (data?.map_service_url && id !== undefined) {
30
- fetchLegend(`${data.map_service_url}/legend`, id);
31
- }
32
- // eslint-disable-next-line react-hooks/exhaustive-deps
33
- }, [id, data]);
34
-
35
- return (
36
- <Grid.Column>
37
- <div
38
- style={{
39
- display: 'flex',
40
- alignItems: 'center',
41
- justifyContent: 'space-between',
42
- }}
43
- >
44
- <h5 style={{ marginBottom: '0.5rem' }}>{name}</h5>
45
- {show_viewer && map_service_url && (
46
- <a
47
- target="_blank"
48
- rel="noreferrer"
49
- title="Open ArcGIS Service location"
50
- href={
51
- `https://www.arcgis.com/home/webmap/viewer.html?url=` +
52
- `${map_service_url}&source=sd`
53
- }
54
- >
55
- <Button size="tiny" className="extra-view-external-button">
56
- <Button.Content>
57
- <img
58
- className="extra-view-external-icon"
59
- src={codeSVG}
60
- alt=""
61
- />
62
- </Button.Content>
63
- </Button>
64
- </a>
65
- )}
66
- </div>
67
- {data?.description && serializeNodes(data.description)}
68
- <div style={{ display: 'flex', flexDirection: 'column' }}>
69
- {legendRows.length > 0 &&
70
- legendRows.map((item, i) => {
71
- return (
72
- <span key={i} style={{ display: 'flex', alignItems: 'center' }}>
73
- <img
74
- alt="alt"
75
- className="layer-legend-item-color"
76
- src={`data:image/png;base64,${item.imageData}`}
77
- />
78
- <span style={{ fontSize: '13px', marginLeft: '5px' }}>
79
- {item.label}
80
- </span>
81
- </span>
82
- );
83
- })}
84
- </div>
85
- </Grid.Column>
86
- );
87
- };
88
-
89
- const LegendView = (props) => {
90
- const data = React.useMemo(() => props.data, [props.data]);
91
- const { device = '', show_viewer = false } = props;
92
-
93
- const [expand, setExpand] = React.useState(true);
94
-
95
- const { layers = {} } = data;
96
-
97
- const visible_layers =
98
- layers && layers.map_layers && layers.map_layers.length
99
- ? layers.map_layers.filter((l) => !l?.map_layer?.hide)
100
- : '';
101
-
102
- const map_layers =
103
- visible_layers && visible_layers.length > 0 && visible_layers.length > 3
104
- ? visible_layers.slice(0, 3)
105
- : visible_layers;
106
-
107
- const legendColumns =
108
- map_layers && setLegendColumns(map_layers.length, device);
109
-
110
- return (
111
- <div className={cx('legend-toolbar', { open: expand })}>
112
- <button
113
- className={cx('trigger-button', { open: expand })}
114
- onClick={() => setExpand(!expand)}
115
- >
116
- Legend
117
- <i
118
- className={cx({
119
- 'ri-arrow-right-s-line': !expand,
120
- 'ri-arrow-down-s-line': expand,
121
- })}
122
- />
123
- </button>
124
- {expand && (
125
- <Grid className="legend-container" columns={legendColumns}>
126
- <Grid.Row divided>
127
- {(!map_layers || map_layers.length === 0) && (
128
- <Grid.Column>
129
- <p>
130
- No layer found for legend. Please add a map layer from editor.
131
- </p>
132
- </Grid.Column>
133
- )}
134
- {map_layers &&
135
- map_layers.length > 0 &&
136
- map_layers?.map((l, i) => (
137
- <LayerLegend
138
- key={i}
139
- data={l.map_layer}
140
- show_viewer={show_viewer}
141
- />
142
- ))}
143
- </Grid.Row>
144
- </Grid>
145
- )}
146
- </div>
147
- );
148
- };
149
-
150
- export default withDeviceSize(React.memo(LegendView));