@eeacms/volto-eea-map 0.1.26 → 0.1.27

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,14 @@ 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
8
+
9
+ #### :hammer_and_wrench: Others
10
+
11
+ - privacy policy inherit height of map [andreiggr - [`dee7281`](https://github.com/eea/volto-eea-map/commit/dee7281caf834d017af8b99da1455c956bc663fe)]
12
+ - set default legend, sources, privacy on [andreiggr - [`fb66ff8`](https://github.com/eea/volto-eea-map/commit/fb66ff8863d13b569955d7a774a9f1ab14729a29)]
13
+ - 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)]
7
15
  ### [0.1.26](https://github.com/eea/volto-eea-map/compare/0.1.25...0.1.26) - 4 October 2022
8
16
 
9
17
  #### :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.27",
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,39 @@ 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
+
187
210
  const map = new Map({
188
- basemap: base_layer || 'hybrid',
211
+ basemap: setBasemap(base_layer),
189
212
  layers,
190
213
  });
191
214
  const view = new MapView({
@@ -1,5 +1,7 @@
1
1
  import { base_layers } from '../../constants';
2
2
 
3
+ const customBaselayers = [['positron-composite', 'positron-composite']];
4
+
3
5
  const BaseLayerSchema = {
4
6
  title: 'Base Layer',
5
7
  fieldsets: [
@@ -12,7 +14,7 @@ const BaseLayerSchema = {
12
14
  properties: {
13
15
  base_layer: {
14
16
  title: 'Base Layer',
15
- choices: base_layers,
17
+ choices: [...customBaselayers, ...base_layers],
16
18
  },
17
19
  },
18
20
  required: [],
@@ -102,10 +104,12 @@ const GeneralSchema = ({ data = {} }) => {
102
104
  long: {
103
105
  title: 'Longitude',
104
106
  type: 'number',
107
+ description: `Will set the map center long coordinate. See: https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#center`,
105
108
  },
106
109
  lat: {
107
110
  title: 'Latitude',
108
111
  type: 'number',
112
+ description: `Will set the map center lat coordinate. See: https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#center`,
109
113
  },
110
114
 
111
115
  print_position: {