@eeacms/volto-eea-map 0.1.27 → 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,14 +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.27](https://github.com/eea/volto-eea-map/compare/0.1.26...0.1.27) - 6 October 2022
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
8
14
 
9
15
  #### :hammer_and_wrench: Others
10
16
 
11
17
  - privacy policy inherit height of map [andreiggr - [`dee7281`](https://github.com/eea/volto-eea-map/commit/dee7281caf834d017af8b99da1455c956bc663fe)]
12
18
  - set default legend, sources, privacy on [andreiggr - [`fb66ff8`](https://github.com/eea/volto-eea-map/commit/fb66ff8863d13b569955d7a774a9f1ab14729a29)]
13
19
  - clear console [andreiggr - [`e1d2841`](https://github.com/eea/volto-eea-map/commit/e1d28419dea2586c98b4df1c9e6dc1d6a4b987b6)]
14
- - use a custom basemap [andreiggr - [`b11fc62`](https://github.com/eea/volto-eea-map/commit/b11fc62a54730c0fb2229448c438f39f51db494d)]
15
20
  ### [0.1.26](https://github.com/eea/volto-eea-map/compare/0.1.25...0.1.26) - 4 October 2022
16
21
 
17
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.27",
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",
@@ -207,8 +207,25 @@ const Webmap = (props) => {
207
207
  return basemap;
208
208
  };
209
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
+
210
224
  const map = new Map({
211
- basemap: setBasemap(base_layer),
225
+ basemap:
226
+ data?.base?.use_custom_base && data?.base?.custom_base_layer
227
+ ? setCustomBasemap(data?.base?.custom_base_layer)
228
+ : setBasemap(base_layer),
212
229
  layers,
213
230
  });
214
231
  const view = new MapView({
@@ -2,22 +2,39 @@ import { base_layers } from '../../constants';
2
2
 
3
3
  const customBaselayers = [['positron-composite', 'positron-composite']];
4
4
 
5
- const BaseLayerSchema = {
6
- title: 'Base Layer',
7
- fieldsets: [
8
- {
9
- id: 'base',
10
- title: 'Base Layer',
11
- fields: ['base_layer'],
12
- },
13
- ],
14
- properties: {
15
- base_layer: {
16
- title: 'Base Layer',
17
- choices: [...customBaselayers, ...base_layers],
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
+ },
18
35
  },
19
- },
20
- required: [],
36
+ required: [],
37
+ };
21
38
  };
22
39
 
23
40
  const LayerSchema = {
@@ -127,6 +144,7 @@ const GeneralSchema = ({ data = {} }) => {
127
144
 
128
145
  export default ({ data = {} }) => {
129
146
  const generalSchema = GeneralSchema({ data });
147
+ const baseLayerSchema = BaseLayerSchema({ data });
130
148
 
131
149
  return {
132
150
  title: 'Map Editor',
@@ -148,7 +166,7 @@ export default ({ data = {} }) => {
148
166
  },
149
167
  {
150
168
  id: 'base',
151
- schema: BaseLayerSchema,
169
+ schema: baseLayerSchema,
152
170
  },
153
171
  {
154
172
  id: 'layers',