@eeacms/volto-eea-map 0.1.4 → 0.1.5

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/CHANGELOG.md CHANGED
@@ -4,8 +4,22 @@ All notable changes to this project will be documented in this file. Dates are d
4
4
 
5
5
  Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
6
6
 
7
+ #### [0.1.5](https://github.com/eea/volto-eea-map/compare/0.1.4...0.1.5)
8
+
9
+ - Center on extent only on map load [`b63f586`](https://github.com/eea/volto-eea-map/commit/b63f586e0df68faa755bb0d25e297530e36ef7c9)
10
+ - Configure proxy for all map subdomains [`0f19030`](https://github.com/eea/volto-eea-map/commit/0f19030569e1f77b1ff7657669e876519712840f)
11
+ - Prevent unnecessary rerenders of ma [`8752384`](https://github.com/eea/volto-eea-map/commit/8752384b3bbd7b564a25b3e4347c47692106f556)
12
+ - Prevent unnecessary rerenders of map [`00a3e64`](https://github.com/eea/volto-eea-map/commit/00a3e64585748a36ef476b2d75540bdd43778486)
13
+ - Clear print schema [`29ed979`](https://github.com/eea/volto-eea-map/commit/29ed9795812d6673f8fb91ac73e53e4e132ed55a)
14
+ - Move zoom & print in general tab [`06c4996`](https://github.com/eea/volto-eea-map/commit/06c499651217715e1793d2a75fb72668dc1de223)
15
+ - Clear [`9aa7bf1`](https://github.com/eea/volto-eea-map/commit/9aa7bf1591b22a2941ce0f269ef133d687affc15)
16
+ - Disable url for screenshot atm [`1ef18fc`](https://github.com/eea/volto-eea-map/commit/1ef18fc8b7516c88c743cffb10b5eb340161d58d)
17
+
7
18
  #### [0.1.4](https://github.com/eea/volto-eea-map/compare/0.1.3...0.1.4)
8
19
 
20
+ > 3 August 2022
21
+
22
+ - Map updates [`#4`](https://github.com/eea/volto-eea-map/pull/4)
9
23
  - Configure Privacy protection screenshot data [`49097c0`](https://github.com/eea/volto-eea-map/commit/49097c0b7aa8657e626d5a49dd0eed84f5e71e78)
10
24
  - Expandable Legend [`6edda2f`](https://github.com/eea/volto-eea-map/commit/6edda2fafd8a2a61f3f1f10c47a9ca5bb35a0355)
11
25
  - Catch for no data [`7cef4e6`](https://github.com/eea/volto-eea-map/commit/7cef4e641650ede23e37ca9116130db1ef0a18db)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-eea-map",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "@eeacms/volto-eea-map: Volto add-on",
5
5
  "main": "src/index.js",
6
6
  "author": "European Environment Agency: IDM2 A-Team",
@@ -16,7 +16,6 @@ const Edit = (props) => {
16
16
 
17
17
  const { map_data = {}, height } = data;
18
18
  if (__SERVER__) return '';
19
-
20
19
  return (
21
20
  <div>
22
21
  <PrivacyProtection data={data} {...props}>
@@ -15,15 +15,11 @@ const MODULES = [
15
15
  ];
16
16
 
17
17
  const Webmap = (props) => {
18
- const { data = {}, editMode, height } = props;
19
- const {
20
- base = {},
21
- layers = {},
22
- id,
23
- legend = {},
24
- print = {},
25
- zoom = {},
26
- } = data;
18
+ const { editMode, height } = props;
19
+
20
+ const data = React.useMemo(() => props.data || {}, [props.data]);
21
+
22
+ const { base = {}, layers = {}, id, legend = {}, general = {} } = data;
27
23
 
28
24
  const { base_layer = '' } = base;
29
25
 
@@ -39,6 +35,7 @@ const Webmap = (props) => {
39
35
 
40
36
  const mapRef = React.useRef();
41
37
  const [modules, setModules] = React.useState({});
38
+
42
39
  const modules_loaded = React.useRef(false);
43
40
 
44
41
  React.useEffect(() => {
@@ -122,30 +119,28 @@ const Webmap = (props) => {
122
119
  const view = new MapView({
123
120
  container: mapRef.current,
124
121
  map,
125
- center: zoom?.long && zoom?.lat ? [zoom.long, zoom.lat] : [0, 40],
126
- zoom: zoom?.zoom_level ? zoom?.zoom_level : 2,
122
+ center:
123
+ general?.long && general?.lat ? [general.long, general.lat] : [0, 40],
124
+ zoom: general?.zoom_level ? general?.zoom_level : 2,
127
125
  ui: {
128
126
  components: ['attribution'],
129
127
  },
130
128
  });
131
129
 
132
- if (layers && layers[0] && zoom && zoom.centerOnExtent) {
133
- view.whenLayerView(layers[0]).then(function (layerView) {
134
- layerView.watch('updating', function (val) {
135
- // view.goTo(response.extent);
136
-
137
- if (!val && layerView) {
138
- layerView.queryExtent().then(function (response) {
139
- ///go to the extent of all the graphics in the layer view
140
- if (response.extent) view.goTo(response.extent);
141
- });
142
- }
130
+ if (layers && layers[0] && general && general.centerOnExtent) {
131
+ const firstLayer = layers[0];
132
+ firstLayer
133
+ .when(() => {
134
+ return firstLayer.queryExtent();
135
+ })
136
+ .then((response) => {
137
+ view.goTo(response.extent);
143
138
  });
144
- });
145
139
  }
146
140
 
147
- if (zoom?.show_zoom) {
148
- const zoomPosition = zoom && zoom.position ? zoom.position : 'top-right';
141
+ if (general?.show_zoom) {
142
+ const zoomPosition =
143
+ general && general.zoom_position ? general.zoom_position : 'top-right';
149
144
  const zoomWidget = new Zoom({
150
145
  view: view,
151
146
  });
@@ -172,9 +167,11 @@ const Webmap = (props) => {
172
167
  view.ui.add(legendWidget, legendPosition);
173
168
  }
174
169
 
175
- if (print?.show_print) {
170
+ if (general?.show_print) {
176
171
  const printPosition =
177
- print && print.position ? print.position : 'top-right';
172
+ general && general.print_position
173
+ ? general.print_position
174
+ : 'top-right';
178
175
  const printWidget = new Expand({
179
176
  content: new Print({
180
177
  view: view,
@@ -209,4 +206,4 @@ const Webmap = (props) => {
209
206
  );
210
207
  };
211
208
 
212
- export default Webmap;
209
+ export default React.memo(Webmap);
@@ -9,7 +9,9 @@ import aheadSVG from '@plone/volto/icons/ahead.svg';
9
9
  import { fetchArcgisData } from '../../utils';
10
10
 
11
11
  const LayerSelectWidget = (props) => {
12
- const { onChange, value = {}, id } = props;
12
+ const { onChange, id } = props;
13
+
14
+ const value = React.useMemo(() => props.value || {}, [props.value]);
13
15
 
14
16
  const {
15
17
  available_layers,
@@ -3,7 +3,9 @@ import { Button } from 'semantic-ui-react';
3
3
  import LayerSelectWidget from './LayerSelectWidget';
4
4
 
5
5
  const LayersPanel = ({ data, onChange, block }) => {
6
- const { map_layers } = data || {};
6
+ const map_layers = React.useMemo(() => data.map_layers || [], [
7
+ data.map_layers,
8
+ ]);
7
9
 
8
10
  React.useEffect(() => {
9
11
  if (!data.map_layers) {
@@ -103,4 +103,4 @@ const LegendWidget = (props) => {
103
103
  );
104
104
  };
105
105
 
106
- export default LegendWidget;
106
+ export default React.memo(LegendWidget);
@@ -15,12 +15,12 @@ const MapEditorWidget = (props) => {
15
15
  onChange(id, intValue);
16
16
 
17
17
  //set map data for screenshot
18
- if (intValue.layers?.map_layers[0].map_layer?.map_service_url) {
19
- onChange(
20
- 'url',
21
- `${intValue.layers?.map_layers[0].map_layer?.map_service_url}?f=jsapi`,
22
- );
23
- }
18
+ // if (intValue.layers?.map_layers[0].map_layer?.map_service_url) {
19
+ // onChange(
20
+ // 'url',
21
+ // `${intValue.layers?.map_layers[0].map_layer?.map_service_url}?f=jsapi`,
22
+ // );
23
+ // }
24
24
  setOpen(false);
25
25
  };
26
26
 
@@ -56,45 +56,21 @@ const MapLayersSchema = {
56
56
  required: [],
57
57
  };
58
58
 
59
- const PrintSchema = {
60
- title: 'Print',
61
- fieldsets: [
62
- {
63
- id: 'default',
64
- title: 'Print',
65
- fields: ['show_print', 'position'],
66
- },
67
- ],
68
- properties: {
69
- show_print: {
70
- title: 'Show print',
71
- type: 'boolean',
72
- },
73
- position: {
74
- title: 'Print position',
75
- choices: ['bottom-right', 'bottom-left', 'top-right', 'top-left'].map(
76
- (n) => {
77
- return [n, n];
78
- },
79
- ),
80
- },
81
- },
82
- required: [],
83
- };
84
-
85
- const ZoomSchema = ({ data = {} }) => {
86
- const centerOnExtent = data?.map_data?.zoom?.centerOnExtent;
59
+ const GeneralSchema = ({ data = {} }) => {
60
+ const centerOnExtent = data?.map_data?.general?.centerOnExtent;
87
61
 
88
62
  return {
89
- title: 'Zoom',
63
+ title: 'General',
90
64
  fieldsets: [
91
65
  {
92
66
  id: 'default',
93
67
  title: 'Zoom',
94
68
  fields: [
69
+ 'show_print',
70
+ 'print_position',
95
71
  'show_zoom',
96
72
  'centerOnExtent',
97
- 'position',
73
+ 'zoom_position',
98
74
  ...(!centerOnExtent ? ['zoom_level', 'long', 'lat'] : []),
99
75
  ],
100
76
  },
@@ -107,9 +83,10 @@ const ZoomSchema = ({ data = {} }) => {
107
83
  centerOnExtent: {
108
84
  title: 'Center on extent',
109
85
  type: 'boolean',
110
- description: 'This will override latitude/longitude/zoom level',
86
+ description:
87
+ 'This will override latitude/longitude/zoom level and will lock zoom/moving the map.',
111
88
  },
112
- position: {
89
+ zoom_position: {
113
90
  title: 'Zoom position',
114
91
  choices: ['bottom-right', 'bottom-left', 'top-right', 'top-left'].map(
115
92
  (n) => {
@@ -129,13 +106,25 @@ const ZoomSchema = ({ data = {} }) => {
129
106
  title: 'Latitude',
130
107
  type: 'number',
131
108
  },
109
+ show_print: {
110
+ title: 'Show print',
111
+ type: 'boolean',
112
+ },
113
+ print_position: {
114
+ title: 'Print position',
115
+ choices: ['bottom-right', 'bottom-left', 'top-right', 'top-left'].map(
116
+ (n) => {
117
+ return [n, n];
118
+ },
119
+ ),
120
+ },
132
121
  },
133
122
  required: [],
134
123
  };
135
124
  };
136
125
 
137
126
  export default ({ data = {} }) => {
138
- const zoomSchema = ZoomSchema({ data });
127
+ const generalSchema = GeneralSchema({ data });
139
128
 
140
129
  return {
141
130
  title: 'Map Editor',
@@ -151,6 +140,10 @@ export default ({ data = {} }) => {
151
140
  title: 'Panels',
152
141
  widget: 'object_types_widget',
153
142
  schemas: [
143
+ {
144
+ id: 'general',
145
+ schema: generalSchema,
146
+ },
154
147
  {
155
148
  id: 'base',
156
149
  schema: BaseLayerSchema,
@@ -159,14 +152,6 @@ export default ({ data = {} }) => {
159
152
  id: 'layers',
160
153
  schema: MapLayersSchema,
161
154
  },
162
- {
163
- id: 'print',
164
- schema: PrintSchema,
165
- },
166
- {
167
- id: 'zoom',
168
- schema: zoomSchema,
169
- },
170
155
  ],
171
156
  },
172
157
  },
package/src/index.js CHANGED
@@ -5,6 +5,21 @@ import MapEditorWidget from './components/Blocks/EEAMap/components/widgets/MapEd
5
5
  import ObjectTypesWidget from './components/Blocks/EEAMap/components/widgets/ObjectTypesWidget';
6
6
 
7
7
  export default (config) => {
8
+ config.settings.allowed_cors_destinations = [
9
+ ...(config.settings.allowed_cors_destinations || []),
10
+ 'land.discomap.eea.europa.eu',
11
+ 'marine.discomap.eea.europa.eu',
12
+ 'climate.discomap.eea.europa.eu',
13
+ 'image.discomap.eea.europa.eu',
14
+ 'ldp.discomap.eea.europa.eu',
15
+ 'bio.discomap.eea.europa.eu',
16
+ 'air.discomap.eea.europa.eu',
17
+ 'maratlas.discomap.eea.europa.eu',
18
+ 'forest.discomap.eea.europa.eu',
19
+ 'water.discomap.eea.europa.eu',
20
+ 'noise.discomap.eea.europa.eu',
21
+ 'copernicus.discomap.eea.europa.eu',
22
+ ];
8
23
  config.blocks.blocksConfig.eea_map_block = {
9
24
  id: 'eea_map_block', // The name (id) of the block
10
25
  title: 'EEA Map', // The display name of the block