@eeacms/volto-cca-policy 0.1.71 → 0.1.73
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 +34 -0
- package/package.json +2 -2
- package/src/components/MigrationButtons.jsx +41 -0
- package/src/components/manage/Blocks/CountryMapHeatIndex/View.js +4 -3
- package/src/components/manage/Blocks/CountryMapHeatIndex/styles.less +133 -0
- package/src/components/manage/Blocks/CountryMapObservatory/{CountryMapObservatoryEdit.js → CountryMapObservatoryEdit.jsx} +1 -1
- package/src/components/manage/Blocks/CountryMapObservatory/CountryMapObservatoryOLView.jsx +230 -0
- package/src/components/manage/Blocks/CountryMapObservatory/index.js +1 -1
- package/src/components/manage/Blocks/CountryMapObservatory/styles.less +51 -0
- package/src/components/manage/Blocks/CountryMapProfile/View.js +3 -2
- package/src/components/manage/Blocks/CountryMapProfile/styles.less +234 -0
- package/src/components/manage/Blocks/RASTBlock/styles.less +21 -19
- package/src/components/manage/Blocks/withResponsiveContainer.js +3 -2
- package/src/index.js +20 -8
- package/theme/globals/site.overrides +0 -76
- package/src/components/manage/Blocks/CountryMapHeatIndex/styles.css +0 -131
- package/src/components/manage/Blocks/CountryMapObservatory/CountryMapObservatoryView.js +0 -93
- package/src/components/manage/Blocks/CountryMapObservatory/euro-countries-simplified.js +0 -46195
- package/src/components/manage/Blocks/CountryMapObservatory/flags.js +0 -57
- package/src/components/manage/Blocks/CountryMapObservatory/map-utils.js +0 -264
- package/src/components/manage/Blocks/CountryMapObservatory/styles.css +0 -49
- package/src/components/manage/Blocks/CountryMapProfile/styles.css +0 -232
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,40 @@ 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.73](https://github.com/eea/volto-cca-policy/compare/0.1.72...0.1.73) - 11 February 2024
|
|
8
|
+
|
|
9
|
+
#### :bug: Bug Fixes
|
|
10
|
+
|
|
11
|
+
- fix: observatory map tooltip [kreafox - [`4b9bb57`](https://github.com/eea/volto-cca-policy/commit/4b9bb571bb27593c6859cd35135ed50c80eede48)]
|
|
12
|
+
- fix: observatory map tooltip position [kreafox - [`782f92e`](https://github.com/eea/volto-cca-policy/commit/782f92e8f8280bb18dcd84ddba3ed764ac957454)]
|
|
13
|
+
|
|
14
|
+
#### :nail_care: Enhancements
|
|
15
|
+
|
|
16
|
+
- change: enable Country Flag block for CCA [kreafox - [`643aec6`](https://github.com/eea/volto-cca-policy/commit/643aec6744390ccf01bc8880d919a91e70cd8e28)]
|
|
17
|
+
|
|
18
|
+
#### :house: Internal changes
|
|
19
|
+
|
|
20
|
+
- style: Automated code fix [eea-jenkins - [`db773e4`](https://github.com/eea/volto-cca-policy/commit/db773e4ccfe0bd34d22d6504d2c7d1643e57105a)]
|
|
21
|
+
- style: Automated code fix [eea-jenkins - [`5fd949b`](https://github.com/eea/volto-cca-policy/commit/5fd949b2b01508df807c1991f17c002b27d9e784)]
|
|
22
|
+
- style: Automated code fix [eea-jenkins - [`20a4343`](https://github.com/eea/volto-cca-policy/commit/20a43437d84bee88c379673d215026432028aabe)]
|
|
23
|
+
|
|
24
|
+
#### :hammer_and_wrench: Others
|
|
25
|
+
|
|
26
|
+
- Disable interractions in edit mode [Tiberiu Ichim - [`058f54c`](https://github.com/eea/volto-cca-policy/commit/058f54c52451d17654a88300d05cea2bb24bb3e5)]
|
|
27
|
+
- Fix country map height [Tiberiu Ichim - [`603f785`](https://github.com/eea/volto-cca-policy/commit/603f7854842e4fe1c4ee1e615669d81a88dd1167)]
|
|
28
|
+
- Better position [Tiberiu Ichim - [`9fa0e21`](https://github.com/eea/volto-cca-policy/commit/9fa0e21aae7593bc3e26eb448ff8eeb6f025fd12)]
|
|
29
|
+
- Cursor shape [Tiberiu Ichim - [`fbdcff4`](https://github.com/eea/volto-cca-policy/commit/fbdcff4b8fc1bbbaba9d3fe784470b5faf45c34b)]
|
|
30
|
+
- Code cleanup [Tiberiu Ichim - [`61dab7c`](https://github.com/eea/volto-cca-policy/commit/61dab7c1a974511e7f7f2d0ce237e973677fe700)]
|
|
31
|
+
- Checkpoint [Tiberiu Ichim - [`7a163af`](https://github.com/eea/volto-cca-policy/commit/7a163af07f7c0dd7e7c0d83a90b01047912c14da)]
|
|
32
|
+
- Checkpoint [Tiberiu Ichim - [`18d9ddd`](https://github.com/eea/volto-cca-policy/commit/18d9ddd490129a70b912e3f22525abeedc86792a)]
|
|
33
|
+
- Checkpoint [Tiberiu Ichim - [`eb657da`](https://github.com/eea/volto-cca-policy/commit/eb657da7f6dd6e64671a99bb4f522e765a2f28f3)]
|
|
34
|
+
- Fix country map [Tiberiu Ichim - [`f657e70`](https://github.com/eea/volto-cca-policy/commit/f657e70fdba37bf9d34ee5acaaba672ad22de976)]
|
|
35
|
+
### [0.1.72](https://github.com/eea/volto-cca-policy/compare/0.1.71...0.1.72) - 9 February 2024
|
|
36
|
+
|
|
37
|
+
#### :bug: Bug Fixes
|
|
38
|
+
|
|
39
|
+
- fix: map full width layout by removing no longer needed CSS [kreafox - [`6f5f1aa`](https://github.com/eea/volto-cca-policy/commit/6f5f1aa5a92a93c07a4efcc63be7ea862692c6d1)]
|
|
40
|
+
|
|
7
41
|
### [0.1.71](https://github.com/eea/volto-cca-policy/compare/0.1.70...0.1.71) - 5 February 2024
|
|
8
42
|
|
|
9
43
|
#### :hammer_and_wrench: Others
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eeacms/volto-cca-policy",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.73",
|
|
4
4
|
"description": "@eeacms/volto-cca-policy: Volto add-on",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"author": "European Environment Agency: IDM2 A-Team",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"@eeacms/volto-widget-dataprovenance": "*",
|
|
39
39
|
"@eeacms/volto-widget-geolocation": "*",
|
|
40
40
|
"@eeacms/volto-widget-temporal-coverage": "*",
|
|
41
|
-
"d3": "
|
|
41
|
+
"d3": "4",
|
|
42
42
|
"d3-geo": "3"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Plug } from '@plone/volto/components/manage/Pluggable';
|
|
2
|
+
import { getBaseUrl } from '@plone/volto/helpers';
|
|
3
|
+
|
|
4
|
+
function MigrationButtons(props) {
|
|
5
|
+
const { content, token, pathname } = props;
|
|
6
|
+
const contentId = content?.['@id'] || '';
|
|
7
|
+
const show = !!token && contentId && contentId.indexOf('europa.eu') === -1;
|
|
8
|
+
const base = getBaseUrl(pathname);
|
|
9
|
+
|
|
10
|
+
const handleClickMigrate = () => {
|
|
11
|
+
window.open(`http://localhost:8080/cca/${base}/@@volto_migrate`, '_blank');
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const handleClickView = () => {
|
|
15
|
+
window.open(`https://climate-adapt.eea.europa.eu${base}`, '_blank');
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
return show ? (
|
|
19
|
+
<Plug pluggable="main.toolbar.top" id="cca-migration-helpers" order={0}>
|
|
20
|
+
<button
|
|
21
|
+
className={`circle-right-btn `}
|
|
22
|
+
id="toolbar-migration"
|
|
23
|
+
onClick={handleClickMigrate}
|
|
24
|
+
title="Migrate context"
|
|
25
|
+
>
|
|
26
|
+
M
|
|
27
|
+
</button>
|
|
28
|
+
|
|
29
|
+
<button
|
|
30
|
+
className={`circle-right-btn `}
|
|
31
|
+
id="toolbar-view"
|
|
32
|
+
onClick={handleClickView}
|
|
33
|
+
title="View original"
|
|
34
|
+
>
|
|
35
|
+
V
|
|
36
|
+
</button>
|
|
37
|
+
</Plug>
|
|
38
|
+
) : null;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export default MigrationButtons;
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import React, { useRef, useEffect } from 'react';
|
|
2
|
-
import flags from './flags.js';
|
|
3
|
-
import './styles.css';
|
|
4
2
|
import { injectLazyLibs } from '@plone/volto/helpers/Loadable/Loadable';
|
|
5
3
|
import { Grid } from 'semantic-ui-react';
|
|
6
4
|
import { compose } from 'redux';
|
|
@@ -12,6 +10,9 @@ import { getFocusCountriesFeature } from '@eeacms/volto-cca-policy/helpers/count
|
|
|
12
10
|
|
|
13
11
|
import Filter from './Filter';
|
|
14
12
|
|
|
13
|
+
import flags from './flags.js';
|
|
14
|
+
import './styles.less';
|
|
15
|
+
|
|
15
16
|
import { useCountriesMetadata } from './hooks';
|
|
16
17
|
|
|
17
18
|
const countries_metadata_url = '/en/@@countries-heat-index-json';
|
|
@@ -161,7 +162,7 @@ const CountryMapObservatoryView = (props) => {
|
|
|
161
162
|
export default compose(
|
|
162
163
|
clientOnly,
|
|
163
164
|
injectLazyLibs(['d3', 'd3Geo']),
|
|
164
|
-
withResponsiveContainer,
|
|
165
|
+
withResponsiveContainer('countryMapHeatIndex'),
|
|
165
166
|
withCountriesData,
|
|
166
167
|
)(CountryMapObservatoryView);
|
|
167
168
|
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
.countryMapHeatIndex {
|
|
2
|
+
&.sized-wrapper {
|
|
3
|
+
width: 100%;
|
|
4
|
+
height: 80vh;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
#country_map {
|
|
8
|
+
position: relative;
|
|
9
|
+
margin: 50px;
|
|
10
|
+
fill: #fff;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.tooltip {
|
|
14
|
+
position: absolute;
|
|
15
|
+
z-index: 10;
|
|
16
|
+
display: none;
|
|
17
|
+
padding: 3px;
|
|
18
|
+
background-color: #2a2a2a;
|
|
19
|
+
border-radius: 3px;
|
|
20
|
+
color: white;
|
|
21
|
+
font-size: 10px;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.graticule {
|
|
25
|
+
fill: none;
|
|
26
|
+
stroke: black;
|
|
27
|
+
stroke-dasharray: 10, 10;
|
|
28
|
+
stroke-width: 1;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.semi-graticule {
|
|
32
|
+
fill: none;
|
|
33
|
+
stroke: gray;
|
|
34
|
+
stroke-dasharray: 1, 1;
|
|
35
|
+
stroke-width: 0.6;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.country-outline path {
|
|
39
|
+
fill: #e9e9e9;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.country-outline path {
|
|
43
|
+
fill: #f5f5f5;
|
|
44
|
+
stroke: #d1d1d1;
|
|
45
|
+
stroke-width: 1;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.country-available path {
|
|
49
|
+
fill: #0170b7;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.legend {
|
|
53
|
+
.legend-text {
|
|
54
|
+
width: 16em;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.legend-el {
|
|
58
|
+
display: flex;
|
|
59
|
+
flex-direction: row;
|
|
60
|
+
padding: 0.8em 0;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.legend-box {
|
|
64
|
+
width: 31px;
|
|
65
|
+
height: 19px;
|
|
66
|
+
margin-right: 0.5em;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
span.country-national-hhap {
|
|
71
|
+
background: #0170b7;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
span.country-subnational-hhap {
|
|
75
|
+
background: #8baece;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
span.country-no-hhap {
|
|
79
|
+
background: #868686;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
span.country-none {
|
|
83
|
+
background-color: #bfbfbf !important;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.country-nationalhhap path {
|
|
87
|
+
cursor: pointer;
|
|
88
|
+
fill: #0170b7 !important;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.country-no-hhap path {
|
|
92
|
+
cursor: pointer;
|
|
93
|
+
fill: #868686 !important;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.country-subnationalhhap path {
|
|
97
|
+
cursor: pointer;
|
|
98
|
+
fill: #8baece !important;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.country-none path {
|
|
102
|
+
cursor: pointer;
|
|
103
|
+
fill: #bfbfbf !important;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.country-nodata path {
|
|
107
|
+
cursor: pointer;
|
|
108
|
+
fill: #efe7d4 !important;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
#map-tooltip {
|
|
112
|
+
position: absolute;
|
|
113
|
+
width: 400px;
|
|
114
|
+
padding: 1em;
|
|
115
|
+
border: 1px solid #c7c7c7;
|
|
116
|
+
background-color: #f7f7f7;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
#country-name a {
|
|
120
|
+
text-decoration: none;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
#country-name .tooltip-country-flag {
|
|
124
|
+
position: absolute;
|
|
125
|
+
top: 10px;
|
|
126
|
+
right: 1em;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
#tooltip-content {
|
|
130
|
+
padding-top: 1em;
|
|
131
|
+
border-top: 2px solid #005c96;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useHistory } from 'react-router-dom';
|
|
3
|
+
import { compose } from 'redux';
|
|
4
|
+
import { clientOnly } from '@eeacms/volto-cca-policy/helpers';
|
|
5
|
+
import withResponsiveContainer from '../withResponsiveContainer.js';
|
|
6
|
+
|
|
7
|
+
import { Map, Layer, Layers, Controls } from '@eeacms/volto-openlayers-map/api';
|
|
8
|
+
import { openlayers as ol } from '@eeacms/volto-openlayers-map';
|
|
9
|
+
import { useMapContext } from '@eeacms/volto-openlayers-map/api';
|
|
10
|
+
import { euCountryNames } from '@eeacms/volto-cca-policy/helpers/country_map/countryMap.js';
|
|
11
|
+
|
|
12
|
+
import './styles.less';
|
|
13
|
+
const url =
|
|
14
|
+
'https://raw.githubusercontent.com/eurostat/Nuts2json/master/pub/v2/2021/4326/20M/cntrg.json';
|
|
15
|
+
|
|
16
|
+
let highlight = null; // easy global
|
|
17
|
+
|
|
18
|
+
const tooltipStyle = {
|
|
19
|
+
position: 'relative',
|
|
20
|
+
zIndex: 2,
|
|
21
|
+
display: 'inline-block',
|
|
22
|
+
visibility: 'hidden',
|
|
23
|
+
top: '0px',
|
|
24
|
+
left: '0px',
|
|
25
|
+
backgroundColor: 'black',
|
|
26
|
+
color: 'white',
|
|
27
|
+
padding: '0.3em',
|
|
28
|
+
cursor: 'pointer',
|
|
29
|
+
fontSize: '10px',
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const Interactions = ({ overlaySource, tooltipRef, baseUrl }) => {
|
|
33
|
+
const history = useHistory();
|
|
34
|
+
const map = useMapContext().map;
|
|
35
|
+
React.useEffect(() => {
|
|
36
|
+
if (!map) return;
|
|
37
|
+
map.on('pointermove', function (evt) {
|
|
38
|
+
if (evt.dragging) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const pixel = map.getEventPixel(evt.originalEvent);
|
|
42
|
+
const feature = map.forEachFeatureAtPixel(pixel, function (feature) {
|
|
43
|
+
return feature;
|
|
44
|
+
});
|
|
45
|
+
if (feature !== highlight) {
|
|
46
|
+
if (highlight) {
|
|
47
|
+
try {
|
|
48
|
+
map.getTargetElement().style.cursor = '';
|
|
49
|
+
overlaySource.removeFeature(highlight);
|
|
50
|
+
} catch {}
|
|
51
|
+
}
|
|
52
|
+
if (feature && euCountryNames.includes(feature.get('na'))) {
|
|
53
|
+
overlaySource.addFeature(feature);
|
|
54
|
+
map.getTargetElement().style.cursor = 'pointer';
|
|
55
|
+
const node = tooltipRef.current;
|
|
56
|
+
if (node) {
|
|
57
|
+
node.innerHTML = feature.get('na');
|
|
58
|
+
node.style.visibility = 'visible';
|
|
59
|
+
node.style.left = `${Math.floor(evt.originalEvent.layerX)}px`;
|
|
60
|
+
node.style.top = `${Math.floor(evt.originalEvent.layerY)}px`;
|
|
61
|
+
}
|
|
62
|
+
highlight = feature;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
map.on('click', function (evt) {
|
|
67
|
+
if (evt.dragging) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
const pixel = map.getEventPixel(evt.originalEvent);
|
|
71
|
+
const feature = map.forEachFeatureAtPixel(pixel, function (feature) {
|
|
72
|
+
return feature;
|
|
73
|
+
});
|
|
74
|
+
if (feature) {
|
|
75
|
+
const country = feature.get('na');
|
|
76
|
+
history.push(`${baseUrl}/${country.toLowerCase()}`);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
}, [map, overlaySource, tooltipRef, baseUrl, history]);
|
|
80
|
+
return null;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const CountryMapObservatoryView = (props) => {
|
|
84
|
+
const [tileWMSSources, setTileWMSSources] = React.useState();
|
|
85
|
+
const [rectsSource, setRectsSource] = React.useState();
|
|
86
|
+
const [overlaySource, setOverlaySource] = React.useState();
|
|
87
|
+
const [euCountriesSource, setEuCountriessource] = React.useState();
|
|
88
|
+
|
|
89
|
+
React.useEffect(() => {
|
|
90
|
+
setOverlaySource(new ol.source.Vector());
|
|
91
|
+
const euSource = new ol.source.Vector();
|
|
92
|
+
setEuCountriessource(euSource);
|
|
93
|
+
const vs = new ol.source.Vector({
|
|
94
|
+
url,
|
|
95
|
+
format: new ol.format.GeoJSON(),
|
|
96
|
+
});
|
|
97
|
+
vs.on('addfeature', function (evt) {
|
|
98
|
+
const { feature } = evt;
|
|
99
|
+
const img = new Image();
|
|
100
|
+
img.onload = function () {
|
|
101
|
+
feature.set('flag', img);
|
|
102
|
+
};
|
|
103
|
+
img.src =
|
|
104
|
+
'https://flagcdn.com/w320/' + feature.get('id').toLowerCase() + '.png';
|
|
105
|
+
});
|
|
106
|
+
vs.on('featuresloadend', (ev) => {
|
|
107
|
+
const filtered = ev.features.filter((f) =>
|
|
108
|
+
euCountryNames.includes(f.get('na')),
|
|
109
|
+
);
|
|
110
|
+
euSource.addFeatures(filtered);
|
|
111
|
+
});
|
|
112
|
+
setRectsSource(vs);
|
|
113
|
+
|
|
114
|
+
setTileWMSSources([
|
|
115
|
+
new ol.source.TileWMS({
|
|
116
|
+
url: 'https://gisco-services.ec.europa.eu/maps/service',
|
|
117
|
+
params: {
|
|
118
|
+
// LAYERS: 'OSMBlossomComposite', OSMCartoComposite, OSMPositronComposite
|
|
119
|
+
LAYERS: 'OSMPositronComposite',
|
|
120
|
+
TILED: true,
|
|
121
|
+
},
|
|
122
|
+
serverType: 'geoserver',
|
|
123
|
+
transition: 0,
|
|
124
|
+
}),
|
|
125
|
+
]);
|
|
126
|
+
}, []);
|
|
127
|
+
|
|
128
|
+
const fill = new ol.style.Fill();
|
|
129
|
+
const stroke = new ol.style.Stroke({
|
|
130
|
+
// color: 'rgba(255,255,255,0.8)',
|
|
131
|
+
color: '#A0A0A0',
|
|
132
|
+
width: 2,
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
const overlayStyle = new ol.style.Style({
|
|
136
|
+
stroke: new ol.style.Stroke({
|
|
137
|
+
color: '#A0A0A0',
|
|
138
|
+
width: 2,
|
|
139
|
+
}),
|
|
140
|
+
fill: new ol.style.Fill({
|
|
141
|
+
color: 'rgb(1, 112, 183, 0.8)',
|
|
142
|
+
}),
|
|
143
|
+
renderer: function (pixelCoordinates, state) {
|
|
144
|
+
const context = state.context;
|
|
145
|
+
const geometry = state.geometry.clone();
|
|
146
|
+
geometry.setCoordinates(pixelCoordinates);
|
|
147
|
+
const extent = geometry.getExtent();
|
|
148
|
+
const width = ol.extent.getWidth(extent);
|
|
149
|
+
const height = ol.extent.getHeight(extent);
|
|
150
|
+
const flag = state.feature.get('flag');
|
|
151
|
+
if (!flag || height < 1 || width < 1) {
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// Stitch out country shape from the blue canvas
|
|
156
|
+
context.save();
|
|
157
|
+
const renderContext = ol.render.toContext(context, {
|
|
158
|
+
pixelRatio: 1,
|
|
159
|
+
});
|
|
160
|
+
renderContext.setFillStrokeStyle(fill, stroke);
|
|
161
|
+
renderContext.drawGeometry(geometry);
|
|
162
|
+
context.clip();
|
|
163
|
+
|
|
164
|
+
// Fill transparent country with the flag image
|
|
165
|
+
const bottomLeft = ol.extent.getBottomLeft(extent);
|
|
166
|
+
const left = bottomLeft[0];
|
|
167
|
+
const bottom = bottomLeft[1];
|
|
168
|
+
context.drawImage(flag, left, bottom, width, height);
|
|
169
|
+
context.restore();
|
|
170
|
+
},
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
const emptyStyle = new ol.style.Style({
|
|
174
|
+
stroke: new ol.style.Stroke({
|
|
175
|
+
color: 'rgb(1, 1, 1, 0)',
|
|
176
|
+
width: 1,
|
|
177
|
+
}),
|
|
178
|
+
fill: new ol.style.Fill({
|
|
179
|
+
color: 'rgb(1, 1, 1, 0)',
|
|
180
|
+
}),
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
const eucountriesStyle = new ol.style.Style({
|
|
184
|
+
stroke: new ol.style.Stroke({
|
|
185
|
+
color: '#A0A0A0',
|
|
186
|
+
width: 1,
|
|
187
|
+
}),
|
|
188
|
+
fill: new ol.style.Fill({
|
|
189
|
+
color: 'rgb(1, 112, 183, 0.3)',
|
|
190
|
+
}),
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
const tooltipRef = React.useRef();
|
|
194
|
+
|
|
195
|
+
return rectsSource ? (
|
|
196
|
+
<Map
|
|
197
|
+
view={{
|
|
198
|
+
center: ol.proj.fromLonLat([10, 52]),
|
|
199
|
+
showFullExtent: true,
|
|
200
|
+
zoom: 3.8,
|
|
201
|
+
}}
|
|
202
|
+
pixelRatio={1}
|
|
203
|
+
>
|
|
204
|
+
<div ref={tooltipRef} style={tooltipStyle} className="map-tooltip"></div>
|
|
205
|
+
<Controls attribution={false} />
|
|
206
|
+
<Layers>
|
|
207
|
+
{props.mode !== 'edit' && (
|
|
208
|
+
<Interactions
|
|
209
|
+
overlaySource={overlaySource}
|
|
210
|
+
tooltipRef={tooltipRef}
|
|
211
|
+
baseUrl={props.path || props.location?.pathname || ''}
|
|
212
|
+
/>
|
|
213
|
+
)}
|
|
214
|
+
<Layer.Vector source={overlaySource} zIndex={3} style={overlayStyle} />
|
|
215
|
+
<Layer.Vector
|
|
216
|
+
source={euCountriesSource}
|
|
217
|
+
zIndex={2}
|
|
218
|
+
style={eucountriesStyle}
|
|
219
|
+
/>
|
|
220
|
+
<Layer.Vector source={rectsSource} zIndex={1} style={emptyStyle} />
|
|
221
|
+
<Layer.Tile source={tileWMSSources[0]} zIndex={0} />
|
|
222
|
+
</Layers>
|
|
223
|
+
</Map>
|
|
224
|
+
) : null;
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
export default compose(
|
|
228
|
+
clientOnly,
|
|
229
|
+
withResponsiveContainer('countryMapObservatory'),
|
|
230
|
+
)(CountryMapObservatoryView);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import worldSVG from '@plone/volto/icons/world.svg';
|
|
2
2
|
import CountryMapObservatoryEdit from './CountryMapObservatoryEdit';
|
|
3
|
-
import CountryMapObservatoryView from './
|
|
3
|
+
import CountryMapObservatoryView from './CountryMapObservatoryOLView';
|
|
4
4
|
import { blockAvailableInMission } from '@eeacms/volto-cca-policy/utils';
|
|
5
5
|
|
|
6
6
|
export default function installCountryMapObservatoryBlock(config) {
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
.countryMapObservatory {
|
|
2
|
+
&.sized-wrapper {
|
|
3
|
+
width: 100%;
|
|
4
|
+
height: 500px;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
#country_map {
|
|
8
|
+
position: relative;
|
|
9
|
+
// margin: 50px;
|
|
10
|
+
fill: #fff;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.tooltip {
|
|
14
|
+
position: absolute;
|
|
15
|
+
z-index: 10;
|
|
16
|
+
display: none;
|
|
17
|
+
padding: 3px;
|
|
18
|
+
background-color: #2a2a2a;
|
|
19
|
+
border-radius: 3px;
|
|
20
|
+
color: white;
|
|
21
|
+
font-size: 10px;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.graticule {
|
|
25
|
+
fill: none;
|
|
26
|
+
stroke: black;
|
|
27
|
+
stroke-dasharray: 10, 10;
|
|
28
|
+
stroke-width: 1;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.semi-graticule {
|
|
32
|
+
fill: none;
|
|
33
|
+
stroke: gray;
|
|
34
|
+
stroke-dasharray: 1, 1;
|
|
35
|
+
stroke-width: 0.6;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.country-outline path {
|
|
39
|
+
fill: #e9e9e9;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.country-outline path {
|
|
43
|
+
fill: #f5f5f5;
|
|
44
|
+
stroke: #d1d1d1;
|
|
45
|
+
stroke-width: 1;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.country-available path {
|
|
49
|
+
fill: #0170b7;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React, { useRef, useEffect } from 'react';
|
|
2
|
-
import './styles.css';
|
|
3
2
|
import { injectLazyLibs } from '@plone/volto/helpers/Loadable/Loadable';
|
|
4
3
|
import { Grid } from 'semantic-ui-react';
|
|
5
4
|
import { compose } from 'redux';
|
|
@@ -13,6 +12,8 @@ import {
|
|
|
13
12
|
withCountriesData,
|
|
14
13
|
} from '@eeacms/volto-cca-policy/helpers/country_map/countryMap.js';
|
|
15
14
|
|
|
15
|
+
import './styles.less';
|
|
16
|
+
|
|
16
17
|
import Filter from './Filter';
|
|
17
18
|
|
|
18
19
|
import { useCountriesMetadata } from './hooks';
|
|
@@ -115,6 +116,6 @@ const CountryMapObservatoryView = (props) => {
|
|
|
115
116
|
export default compose(
|
|
116
117
|
clientOnly,
|
|
117
118
|
injectLazyLibs(['d3', 'd3Geo']),
|
|
118
|
-
withResponsiveContainer,
|
|
119
|
+
withResponsiveContainer('countryMapProfile'),
|
|
119
120
|
withCountriesData,
|
|
120
121
|
)(CountryMapObservatoryView);
|