@eeacms/volto-eea-map 0.1.26 → 0.1.28

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,6 +4,19 @@ 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.28](https://github.com/eea/volto-eea-map/compare/0.1.27...0.1.28) - 7 October 2022
8
+
9
+ #### :hammer_and_wrench: Others
10
+
11
+ - Clear [andreiggr - [`cef77e6`](https://github.com/eea/volto-eea-map/commit/cef77e6bf85f919c4968d5001f342c7d6c0e63f5)]
12
+ - Custom base import [andreiggr - [`ac15d5a`](https://github.com/eea/volto-eea-map/commit/ac15d5aa8edb3dc33b317f47fc11424e74035ce8)]
13
+ ### [0.1.27](https://github.com/eea/volto-eea-map/compare/0.1.26...0.1.27) - 7 October 2022
14
+
15
+ #### :hammer_and_wrench: Others
16
+
17
+ - privacy policy inherit height of map [andreiggr - [`dee7281`](https://github.com/eea/volto-eea-map/commit/dee7281caf834d017af8b99da1455c956bc663fe)]
18
+ - set default legend, sources, privacy on [andreiggr - [`fb66ff8`](https://github.com/eea/volto-eea-map/commit/fb66ff8863d13b569955d7a774a9f1ab14729a29)]
19
+ - clear console [andreiggr - [`e1d2841`](https://github.com/eea/volto-eea-map/commit/e1d28419dea2586c98b4df1c9e6dc1d6a4b987b6)]
7
20
  ### [0.1.26](https://github.com/eea/volto-eea-map/compare/0.1.25...0.1.26) - 4 October 2022
8
21
 
9
22
  #### :hammer_and_wrench: Others
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-eea-map",
3
- "version": "0.1.26",
3
+ "version": "0.1.28",
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",
@@ -17,6 +17,29 @@ const Edit = (props) => {
17
17
  const { block, data, onChangeBlock, selected, id } = props;
18
18
  const schema = React.useMemo(() => Schema(props), [props]);
19
19
 
20
+ React.useEffect(() => {
21
+ if (!Object.hasOwn(data, 'show_legend')) {
22
+ onChangeBlock(block, {
23
+ ...data,
24
+ show_legend: true,
25
+ });
26
+ }
27
+ if (!Object.hasOwn(data, 'show_sources')) {
28
+ onChangeBlock(block, {
29
+ ...data,
30
+ show_sources: true,
31
+ });
32
+ }
33
+ if (!Object.hasOwn(data, 'dataprotection')) {
34
+ onChangeBlock(block, {
35
+ ...data,
36
+ dataprotection: { enabled: true },
37
+ });
38
+ }
39
+
40
+ // eslint-disable-next-line react-hooks/exhaustive-deps
41
+ }, [data]);
42
+
20
43
  React.useEffect(() => {
21
44
  props.getContent(data.vis_url, null, id);
22
45
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -90,6 +90,8 @@ export const Schema = (props) => {
90
90
  },
91
91
  height: {
92
92
  title: 'Height',
93
+ description:
94
+ 'Map block height in px. Default is 500px. Change only if necessary',
93
95
  type: 'number',
94
96
  },
95
97
  description: {
@@ -75,7 +75,7 @@ const View = (props) => {
75
75
 
76
76
  return (
77
77
  <div>
78
- <PrivacyProtection data={data} {...props}>
78
+ <PrivacyProtection data={data} height={height} {...props}>
79
79
  {mapData && (
80
80
  <div>
81
81
  <Webmap data={mapData} height={height} />
@@ -52,6 +52,7 @@ const ExtraViews = ({ data }) => {
52
52
  show_sources,
53
53
  data_provenance = {},
54
54
  } = data;
55
+
55
56
  return (
56
57
  <div className="extra-eea-map-content">
57
58
  {show_legend && map_data && (
@@ -10,6 +10,8 @@ const MODULES = [
10
10
  'esri/layers/FeatureLayer',
11
11
  'esri/layers/MapImageLayer',
12
12
  'esri/layers/GroupLayer',
13
+ 'esri/layers/WebTileLayer',
14
+ 'esri/Basemap',
13
15
  'esri/widgets/Legend',
14
16
  'esri/widgets/Expand',
15
17
  'esri/widgets/Print',
@@ -17,7 +19,7 @@ const MODULES = [
17
19
  'esri/widgets/ScaleBar',
18
20
  ];
19
21
 
20
- //TODO: set group layers sublayers, for direct group import. Maybe also
22
+ //TODO: set group layers sublayers, for direct group import.
21
23
  // const setGroupLayers = async (ids, data, modules) => {
22
24
  // const { map_service_url, sublayerDatalayer, fullLayer, query = '' } =
23
25
  // data || {};
@@ -97,6 +99,8 @@ const Webmap = (props) => {
97
99
  FeatureLayer,
98
100
  MapImageLayer,
99
101
  GroupLayer,
102
+ WebTileLayer,
103
+ Basemap,
100
104
  Legend,
101
105
  Expand,
102
106
  Print,
@@ -109,6 +113,8 @@ const Webmap = (props) => {
109
113
  FeatureLayer,
110
114
  MapImageLayer,
111
115
  GroupLayer,
116
+ WebTileLayer,
117
+ Basemap,
112
118
  Legend,
113
119
  Expand,
114
120
  Print,
@@ -128,6 +134,8 @@ const Webmap = (props) => {
128
134
  FeatureLayer,
129
135
  MapImageLayer,
130
136
  GroupLayer,
137
+ WebTileLayer,
138
+ Basemap,
131
139
  Legend,
132
140
  Expand,
133
141
  Print,
@@ -168,24 +176,56 @@ const Webmap = (props) => {
168
176
  maxScale: layer?.maxScale,
169
177
  });
170
178
  break;
171
- //// case 'Group Layer':
172
- // mapLayer = new GroupLayer({ title: layer.title });
173
- // // mapLayer.addMany(
174
- // // setGroupLayers(
175
- // // layer.sublayersIds,
176
- // // { map_service_url, layer, fullLayer, query },
177
- // // modules,
178
- // // ),
179
- // // );
180
- break;
181
179
  default:
182
180
  break;
183
181
  }
184
182
  return mapLayer;
185
183
  })
186
184
  : [];
185
+
186
+ const mapBaseLayer = new WebTileLayer({
187
+ urlTemplate:
188
+ 'https://gisco-services.ec.europa.eu/maps/tiles/OSMPositronComposite/EPSG3857/{level}/{col}/{row}.png',
189
+ });
190
+
191
+ // Create a Basemap with the WebTileLayer.
192
+ const positronCompositeBasemap = new Basemap({
193
+ baseLayers: [mapBaseLayer],
194
+ title: 'Positron Composite',
195
+ id: 'positron-composite',
196
+ thumbnailUrl:
197
+ 'https://gisco-services.ec.europa.eu/maps/tiles/OSMPositronComposite/EPSG3857/0/0/0.png',
198
+ });
199
+
200
+ const setBasemap = (basemap) => {
201
+ if (basemap === 'positron-composite') {
202
+ return positronCompositeBasemap;
203
+ }
204
+ if (!basemap) {
205
+ return 'hybrid';
206
+ }
207
+ return basemap;
208
+ };
209
+
210
+ const setCustomBasemap = (urlTemplate) => {
211
+ const mapBaseLayer = new WebTileLayer({
212
+ urlTemplate,
213
+ });
214
+
215
+ // Create a Basemap with the WebTileLayer.
216
+ const customBase = new Basemap({
217
+ baseLayers: [mapBaseLayer],
218
+ title: 'Custom Base Layer',
219
+ id: 'custom-base',
220
+ });
221
+ return customBase;
222
+ };
223
+
187
224
  const map = new Map({
188
- basemap: base_layer || 'hybrid',
225
+ basemap:
226
+ data?.base?.use_custom_base && data?.base?.custom_base_layer
227
+ ? setCustomBasemap(data?.base?.custom_base_layer)
228
+ : setBasemap(base_layer),
189
229
  layers,
190
230
  });
191
231
  const view = new MapView({
@@ -1,21 +1,40 @@
1
1
  import { base_layers } from '../../constants';
2
2
 
3
- const BaseLayerSchema = {
4
- title: 'Base Layer',
5
- fieldsets: [
6
- {
7
- id: 'base',
8
- title: 'Base Layer',
9
- fields: ['base_layer'],
10
- },
11
- ],
12
- properties: {
13
- base_layer: {
14
- title: 'Base Layer',
15
- choices: base_layers,
3
+ const customBaselayers = [['positron-composite', 'positron-composite']];
4
+
5
+ const BaseLayerSchema = ({ data = {} }) => {
6
+ const useCustomBase = data?.map_data?.base?.use_custom_base;
7
+ return {
8
+ title: 'Base Layer',
9
+ fieldsets: [
10
+ {
11
+ id: 'base',
12
+ title: 'Base Layer',
13
+ fields: [
14
+ 'use_custom_base',
15
+ ...(useCustomBase ? ['custom_base_layer'] : ['base_layer']),
16
+ ],
17
+ },
18
+ ],
19
+ properties: {
20
+ use_custom_base: {
21
+ title: 'Use custom Base Layer',
22
+ description:
23
+ 'Switch between default base layers and defining your custom service base layer',
24
+ type: 'boolean',
25
+ },
26
+ base_layer: {
27
+ title: 'Base Layer',
28
+ choices: [...customBaselayers, ...base_layers],
29
+ },
30
+ custom_base_layer: {
31
+ title: 'Base Layer',
32
+ description:
33
+ 'Add an URL Template to import your own base layer from an external service',
34
+ },
16
35
  },
17
- },
18
- required: [],
36
+ required: [],
37
+ };
19
38
  };
20
39
 
21
40
  const LayerSchema = {
@@ -102,10 +121,12 @@ const GeneralSchema = ({ data = {} }) => {
102
121
  long: {
103
122
  title: 'Longitude',
104
123
  type: 'number',
124
+ description: `Will set the map center long coordinate. See: https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#center`,
105
125
  },
106
126
  lat: {
107
127
  title: 'Latitude',
108
128
  type: 'number',
129
+ description: `Will set the map center lat coordinate. See: https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#center`,
109
130
  },
110
131
 
111
132
  print_position: {
@@ -123,6 +144,7 @@ const GeneralSchema = ({ data = {} }) => {
123
144
 
124
145
  export default ({ data = {} }) => {
125
146
  const generalSchema = GeneralSchema({ data });
147
+ const baseLayerSchema = BaseLayerSchema({ data });
126
148
 
127
149
  return {
128
150
  title: 'Map Editor',
@@ -144,7 +166,7 @@ export default ({ data = {} }) => {
144
166
  },
145
167
  {
146
168
  id: 'base',
147
- schema: BaseLayerSchema,
169
+ schema: baseLayerSchema,
148
170
  },
149
171
  {
150
172
  id: 'layers',