@eeacms/volto-cca-policy 0.1.88 → 0.1.90

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.
Files changed (37) hide show
  1. package/CHANGELOG.md +47 -0
  2. package/package.json +4 -3
  3. package/src/components/manage/Blocks/CollectionStatistics/schema.js +1 -1
  4. package/src/components/manage/Blocks/CountryMapHeatIndex/Filter.jsx +23 -14
  5. package/src/components/manage/Blocks/CountryMapHeatIndex/Interactions.jsx +124 -0
  6. package/src/components/manage/Blocks/CountryMapHeatIndex/View.js +153 -132
  7. package/src/components/manage/Blocks/CountryMapHeatIndex/mapstyle.js +84 -0
  8. package/src/components/manage/Blocks/CountryMapHeatIndex/styles.less +30 -2
  9. package/src/components/manage/Blocks/CountryMapObservatory/CountryMapObservatoryOLView.jsx +6 -27
  10. package/src/components/manage/Blocks/CountryMapProfile/Filter.jsx +10 -1
  11. package/src/components/manage/Blocks/CountryMapProfile/Interactions.jsx +20 -90
  12. package/src/components/manage/Blocks/CountryMapProfile/OLView.jsx +12 -40
  13. package/src/components/manage/Blocks/CountryMapProfile/styles.less +5 -0
  14. package/src/components/manage/Blocks/Listing/OrganisationCardsListingView.jsx +1 -1
  15. package/src/components/theme/Views/AdaptationOptionView.jsx +87 -69
  16. package/src/components/theme/Views/C3SIndicatorView.jsx +40 -24
  17. package/src/components/theme/Views/CaseStudyView.jsx +85 -64
  18. package/src/components/theme/Views/GuidanceView.jsx +63 -36
  19. package/src/components/theme/Views/IndicatorView.jsx +86 -38
  20. package/src/components/theme/Views/InformationPortalView.jsx +52 -30
  21. package/src/components/theme/Views/OrganisationView.jsx +70 -55
  22. package/src/components/theme/Views/ProjectView.jsx +52 -37
  23. package/src/components/theme/Views/PublicationReportView.jsx +45 -24
  24. package/src/components/theme/Views/ToolView.jsx +39 -20
  25. package/src/components/theme/Views/VideoView.jsx +94 -80
  26. package/src/helpers/ContentMetadata.jsx +39 -354
  27. package/src/helpers/Utils.jsx +3 -0
  28. package/src/helpers/country_map/countryMap.js +109 -34
  29. package/src/helpers/index.js +1 -0
  30. package/src/index.js +25 -5
  31. package/theme/globals/mission.less +5 -0
  32. package/theme/globals/observatory.less +7 -0
  33. package/theme/globals/site.overrides +0 -9
  34. package/theme/globals/views.less +52 -47
  35. package/src/components/manage/Blocks/CountryMapHeatIndex/map-utils.js +0 -542
  36. package/src/components/manage/Blocks/CountryMapProfile/hocs.jsx +0 -28
  37. /package/src/{components/manage/Blocks/CountryMapObservatory → helpers/country_map}/hocs.jsx +0 -0
package/CHANGELOG.md CHANGED
@@ -4,6 +4,53 @@ 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.90](https://github.com/eea/volto-cca-policy/compare/0.1.89...0.1.90) - 5 March 2024
8
+
9
+ #### :hammer_and_wrench: Others
10
+
11
+ - Fix default [Tiberiu Ichim - [`03849ee`](https://github.com/eea/volto-cca-policy/commit/03849ee821516ef131e863378ae6e12e4b6a41cd)]
12
+ ### [0.1.89](https://github.com/eea/volto-cca-policy/compare/0.1.88...0.1.89) - 5 March 2024
13
+
14
+ #### :bug: Bug Fixes
15
+
16
+ - fix: warning messages [kreafox - [`95644f3`](https://github.com/eea/volto-cca-policy/commit/95644f36fe848f52bea700b5a5d0bc3844b7be12)]
17
+ - fix(tests): more cleanup [kreafox - [`93d75db`](https://github.com/eea/volto-cca-policy/commit/93d75dbd30a12e7107dfa3894e69cae7328cfaea)]
18
+ - fix(test): duplicated code issue [kreafox - [`41d511a`](https://github.com/eea/volto-cca-policy/commit/41d511a36905385092c8eb810566732cf4dd31b8)]
19
+ - fix(test): cleanup [kreafox - [`cba73a4`](https://github.com/eea/volto-cca-policy/commit/cba73a483cb2fca461fdb90f7a80258818534ddb)]
20
+ - fix(views): don't show image on db items [kreafox - [`c533e74`](https://github.com/eea/volto-cca-policy/commit/c533e74d705b79e1d36f84d4bf268040a8f21174)]
21
+ - fix: add volto-datablocks to addons [kreafox - [`a4c39fe`](https://github.com/eea/volto-cca-policy/commit/a4c39fe782e4cd717eee19128befb5fc19ecba05)]
22
+
23
+ #### :nail_care: Enhancements
24
+
25
+ - change(views): update db items view layout [kreafox - [`278937f`](https://github.com/eea/volto-cca-policy/commit/278937f28626addb4c4a86ba58fddd237ace296d)]
26
+
27
+ #### :house: Internal changes
28
+
29
+ - style: gallery improvements [kreafox - [`e85af09`](https://github.com/eea/volto-cca-policy/commit/e85af09b2aa52abfc07086b0720df469820d3d55)]
30
+ - style: Automated code fix [eea-jenkins - [`ee38bed`](https://github.com/eea/volto-cca-policy/commit/ee38bedc3da9f40ae66ec62d162d4967008cf909)]
31
+ - style(subsite): CSS fixes [kreafox - [`f6ebc71`](https://github.com/eea/volto-cca-policy/commit/f6ebc711d76cdaf34643ca6ccc80a04046dda892)]
32
+
33
+ #### :hammer_and_wrench: Others
34
+
35
+ - add d3-array to dependencies [kreafox - [`3d234f3`](https://github.com/eea/volto-cca-policy/commit/3d234f304beefe3118a284ae251fade8e1173e34)]
36
+ - Remove unneded import [Tiberiu Ichim - [`8f12b73`](https://github.com/eea/volto-cca-policy/commit/8f12b7358b91015071c0e01578625c8305160eca)]
37
+ - Remove dependency on d3 [Tiberiu Ichim - [`084d437`](https://github.com/eea/volto-cca-policy/commit/084d437e096a8ef0c16083a153d6110f9c16946b)]
38
+ - Remove unneded code [Tiberiu Ichim - [`fbc31b2`](https://github.com/eea/volto-cca-policy/commit/fbc31b2451d3aba0e911be91e90d22ab66be19d3)]
39
+ - Refs #266329 - IndicatorView: render map_graphs - fix null case. [GhitaB - [`5323df0`](https://github.com/eea/volto-cca-policy/commit/5323df0914a3427fe69d5fbf739e2ce20ab881b1)]
40
+ - Refs #266329 - IndicatorView: render map_graphs as iframe (flourish). [GhitaB - [`eda69ea`](https://github.com/eea/volto-cca-policy/commit/eda69eaadbd0c6d7f6815ddb4076c0b166f764ad)]
41
+ - Add volto-datablocks as dependency [Tiberiu Ichim - [`7353625`](https://github.com/eea/volto-cca-policy/commit/7353625729f1c42cde75084d3d58e817cf239537)]
42
+ - country map ol duplicated lines [Tripon Eugen - [`ec68c9c`](https://github.com/eea/volto-cca-policy/commit/ec68c9cbf5bff501312dcbbb2ddaebc4a9efccbb)]
43
+ - country map ol duplicated lines [Tripon Eugen - [`60bee59`](https://github.com/eea/volto-cca-policy/commit/60bee5915254e0453535847d32b54087440bfd60)]
44
+ - country map ol eslint [Tripon Eugen - [`00fb638`](https://github.com/eea/volto-cca-policy/commit/00fb63898eae057aa0898ea2291270335fccca0d)]
45
+ - country map ol duplicated lines [Tripon Eugen - [`de83ae3`](https://github.com/eea/volto-cca-policy/commit/de83ae3f777b5560514c81920c693bb2ede6d0fb)]
46
+ - country map ol duplicated lines [Tripon Eugen - [`1b6f1fd`](https://github.com/eea/volto-cca-policy/commit/1b6f1fd2d6f2b270b94ed8965ac924f75294d722)]
47
+ - country map ol duplicated lines [Tripon Eugen - [`ce47840`](https://github.com/eea/volto-cca-policy/commit/ce47840a8359fa222ef5b5d2cd59edf1faa78af0)]
48
+ - country map ol popup hide [Tripon Eugen - [`39e4800`](https://github.com/eea/volto-cca-policy/commit/39e4800df2adc2cc0753be1dd66bce093c1a2c77)]
49
+ - country map ol withVisibility, popup hide [Tripon Eugen - [`565d55e`](https://github.com/eea/volto-cca-policy/commit/565d55eb11936a86366f7bfd2939239ade86ce70)]
50
+ - country map profile filter title [Tripon Eugen - [`2a4b1cf`](https://github.com/eea/volto-cca-policy/commit/2a4b1cfda934b398e4407f52e5f0de2664c181ec)]
51
+ - country map heat index eslint [Tripon Eugen - [`1fd7829`](https://github.com/eea/volto-cca-policy/commit/1fd782943ee8564bddc13bea9df47af425045bde)]
52
+ - country map heat index eslint [Tripon Eugen - [`b229b69`](https://github.com/eea/volto-cca-policy/commit/b229b690413c4573110bab1063ac3171945b22ca)]
53
+ - country map heat index ol [Tripon Eugen - [`30a3ec1`](https://github.com/eea/volto-cca-policy/commit/30a3ec15e2ca4eee9ba4170eada8e2660d1a9ea6)]
7
54
  ### [0.1.88](https://github.com/eea/volto-cca-policy/compare/0.1.87...0.1.88) - 1 March 2024
8
55
 
9
56
  #### :bug: Bug Fixes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-cca-policy",
3
- "version": "0.1.88",
3
+ "version": "0.1.90",
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",
@@ -23,6 +23,7 @@
23
23
  "@eeacms/volto-widget-dataprovenance",
24
24
  "@eeacms/volto-accordion-block",
25
25
  "@eeacms/volto-slate-label",
26
+ "@eeacms/volto-datablocks",
26
27
  "@eeacms/volto-eea-design-system",
27
28
  "@eeacms/volto-eea-website-theme",
28
29
  "@eeacms/volto-globalsearch"
@@ -30,6 +31,7 @@
30
31
  "dependencies": {
31
32
  "@eeacms/volto-accordion-block": "*",
32
33
  "@eeacms/volto-block-style": "*",
34
+ "@eeacms/volto-datablocks": "*",
33
35
  "@eeacms/volto-eea-design-system": "*",
34
36
  "@eeacms/volto-eea-website-theme": "*",
35
37
  "@eeacms/volto-globalsearch": "*",
@@ -39,9 +41,8 @@
39
41
  "@eeacms/volto-widget-dataprovenance": "*",
40
42
  "@eeacms/volto-widget-geolocation": "*",
41
43
  "@eeacms/volto-widget-temporal-coverage": "*",
42
- "d3": "4",
43
- "d3-geo": "3",
44
44
  "query-string": "7.1.0",
45
+ "d3-array": "^2.12.1",
45
46
  "react-visibility-sensor": "5.1.1"
46
47
  },
47
48
  "devDependencies": {
@@ -51,7 +51,7 @@ const Schema = () => {
51
51
  ['SearchBlock', 'Volto Search block'],
52
52
  ['EEASemanticSearch', 'EEA Semantic Search'],
53
53
  ],
54
- default: 'ListingBlock',
54
+ default: 'SearchBlock',
55
55
  },
56
56
  showLabel: {
57
57
  type: 'boolean',
@@ -1,29 +1,38 @@
1
+ import React from 'react';
2
+ import { Radio } from 'semantic-ui-react';
3
+
4
+ function hidePopup() {
5
+ const collections = document.getElementsByClassName('map-tooltip');
6
+ for (let i = 0; i < collections.length; i++) {
7
+ collections[i].style.visibility = 'hidden';
8
+ }
9
+ }
10
+
1
11
  export default function Filter(props) {
2
12
  const { thematicMapMode, setThematicMapMode } = props;
3
13
  return (
4
14
  <>
5
- <h2>Choose thematic map:</h2>
15
+ <p className="title">Choose thematic map:</p>
6
16
  <div id="sections-selector">
7
- <input
8
- type="radio"
17
+ <Radio
18
+ label="Heat health action plans (HHAP)"
9
19
  name="country-map-section"
10
20
  value="hhap"
11
- checked="checked"
12
- onChange={(e) => {
13
- setThematicMapMode(e.target.value);
21
+ checked={thematicMapMode === 'hhap'}
22
+ onChange={(_e, { value }) => {
23
+ setThematicMapMode(value);
24
+ hidePopup();
14
25
  }}
15
26
  />
16
- Heat health action plans (HHAP)
17
- <br />
18
- <input
19
- type="radio"
27
+ <Radio
28
+ label="Heat health warning systems (HHWS)"
20
29
  name="country-map-section"
21
30
  value="hhws"
22
- onChange={(e) => {
23
- setThematicMapMode(e.target.value);
31
+ checked={thematicMapMode === 'hhws'}
32
+ onChange={(_e, { value }) => {
33
+ setThematicMapMode(value);
24
34
  }}
25
35
  />
26
- Heat health warning systems (HHWS)
27
36
  </div>
28
37
 
29
38
  {thematicMapMode === 'hhap' && (
@@ -41,7 +50,7 @@ export default function Filter(props) {
41
50
  <p className="legend-text">No HHAP</p>
42
51
  </div>
43
52
  <div className="legend-el">
44
- <span className="country-national-hhap legend-box"></span>
53
+ <span className="country-none legend-box"></span>
45
54
  <p className="legend-text">No information</p>
46
55
  </div>
47
56
  </div>
@@ -0,0 +1,124 @@
1
+ import React from 'react';
2
+
3
+ import {
4
+ euCountryNames,
5
+ setTooltipVisibility,
6
+ getClosestFeatureToCoordinate,
7
+ } from '@eeacms/volto-cca-policy/helpers/country_map/countryMap';
8
+ import { useMapContext } from '@eeacms/volto-openlayers-map/api';
9
+
10
+ export const Interactions = ({
11
+ tooltipRef,
12
+ // onFeatureClick,
13
+ countries_metadata,
14
+ // baseUrl,
15
+ highlight,
16
+ setStateHighlight,
17
+ euCountryFeatures,
18
+ thematicMapMode,
19
+ }) => {
20
+ const map = useMapContext().map;
21
+
22
+ React.useEffect(() => {
23
+ if (!map) return;
24
+
25
+ map.on('pointermove', function (evt) {
26
+ if (evt.dragging) {
27
+ return;
28
+ }
29
+
30
+ const feature = getClosestFeatureToCoordinate(
31
+ evt.coordinate,
32
+ euCountryFeatures.current,
33
+ );
34
+
35
+ highlight.current = feature && feature.get('na');
36
+ setStateHighlight(highlight.current);
37
+
38
+ // const domEvt = evt.originalEvent;
39
+ // const pixel = map.getEventPixel(evt.originalEvent);
40
+ // const feature = map.forEachFeatureAtPixel(pixel, function (feature) {
41
+ // return feature;
42
+ // });
43
+ // console.log('current feature', feature.get('na'));
44
+ // console.log('FEATURE:', feature?.get('na') || 'NA');
45
+ // console.log('HIGHLIGHT:', highlight?.get('na') || 'NA');
46
+ // if (feature && euCountryNames.includes(feature.get('na'))) {
47
+ // console.log('FEATURE IS EUROPE COUNTRY');
48
+ // }
49
+ // if (feature !== highlight) {
50
+ // if (highlight) {
51
+ // try {
52
+ // map.getTargetElement().style.cursor = '';
53
+ // // overlaySource.removeFeature(highlight);
54
+ // } catch {}
55
+ // }
56
+ // if (feature && euCountryNames.includes(feature.get('na'))) {
57
+ // // overlaySource.addFeature(feature);
58
+ // map.getTargetElement().style.cursor = 'pointer';
59
+ // const node = tooltipRef.current;
60
+ // setTooltipVisibility(node, feature.get('na'), domEvt, true);
61
+ // highlight.current = feature.get('na');
62
+ // }
63
+ // } else {
64
+ // // setTooltipVisibility(tooltipRef.current, null, domEvt, false);
65
+ // }
66
+ });
67
+
68
+ map.on('click', function (evt) {
69
+ if (evt.dragging) {
70
+ return;
71
+ }
72
+ const domEvt = evt.originalEvent;
73
+ // const pixel = map.getEventPixel(evt.originalEvent);
74
+
75
+ const feature = getClosestFeatureToCoordinate(
76
+ evt.coordinate,
77
+ euCountryFeatures.current,
78
+ );
79
+ let countryName = feature.get('na');
80
+ if (
81
+ Object.hasOwn(countries_metadata, countryName) &&
82
+ thematicMapMode === 'hhws' &&
83
+ euCountryNames.includes(countryName) &&
84
+ countries_metadata[countryName].hhws === 'HWWS exists'
85
+ ) {
86
+ let metadata = countries_metadata[countryName];
87
+ if (metadata === undefined) {
88
+ return;
89
+ }
90
+ let tooltipContent = '<strong>Heat index of HHWS:</strong> ';
91
+ map.getTargetElement().style.cursor = 'pointer';
92
+ const node = tooltipRef.current;
93
+ let tooltipContentDiv =
94
+ `<div id="country-name">
95
+ <h3>` +
96
+ countryName +
97
+ `</h3>
98
+ </div><div class="tooltip-content"><span>` +
99
+ tooltipContent +
100
+ countries_metadata[countryName].heat_index_description +
101
+ `</span><br/><br/><span><a href="` +
102
+ countries_metadata[countryName].website +
103
+ `">HHWS website</a></span></div>`;
104
+ setTooltipVisibility(
105
+ node,
106
+ '<div class="country-tooltip">' + tooltipContentDiv + '</div>',
107
+ domEvt,
108
+ true,
109
+ );
110
+ } else {
111
+ const collections = document.getElementsByClassName('map-tooltip');
112
+ for (let i = 0; i < collections.length; i++) {
113
+ collections[i].style.visibility = 'hidden';
114
+ }
115
+ }
116
+
117
+ // if (feature) {
118
+ // onFeatureClick(feature);
119
+ // }
120
+ });
121
+ });
122
+ // }, [map, tooltipRef, onFeatureClick]);
123
+ return null;
124
+ };
@@ -1,153 +1,179 @@
1
- import React, { useRef, useEffect } from 'react';
2
- import { injectLazyLibs } from '@plone/volto/helpers/Loadable/Loadable';
3
- import { Grid } from 'semantic-ui-react';
1
+ import React from 'react';
4
2
  import { compose } from 'redux';
5
3
  import { clientOnly } from '@eeacms/volto-cca-policy/helpers';
6
- import withResponsiveContainer from './../withResponsiveContainer.js';
7
- import { addAppURL } from '@plone/volto/helpers';
8
- import { getFocusCountryNames, renderCountriesBox } from './map-utils.js';
9
- import { getFocusCountriesFeature } from '@eeacms/volto-cca-policy/helpers/country_map/countryMap.js';
4
+
5
+ import { Map, Layer, Layers, Controls } from '@eeacms/volto-openlayers-map/api';
6
+ import { openlayers as ol } from '@eeacms/volto-openlayers-map';
7
+ import {
8
+ euCountryNames as euCountryNamesRaw,
9
+ tooltipStyle,
10
+ getImageUrl,
11
+ adjustEuCountryNames,
12
+ } from '@eeacms/volto-cca-policy/helpers/country_map/countryMap';
13
+ import { withGeoJsonData } from '@eeacms/volto-cca-policy/helpers/country_map/hocs';
14
+
15
+ import withResponsiveContainer from '../withResponsiveContainer';
16
+ import withVisibilitySensor from '../withVisibilitySensor';
17
+ import { makeStyles } from './mapstyle';
18
+ import { Interactions } from './Interactions';
10
19
 
11
20
  import Filter from './Filter';
21
+ import { Grid } from 'semantic-ui-react';
22
+ import { useCountriesMetadata } from './hooks';
23
+ import { addAppURL } from '@plone/volto/helpers';
12
24
 
13
- import flags from './flags.js';
14
25
  import './styles.less';
15
26
 
16
- import { useCountriesMetadata } from './hooks';
27
+ // const url =
28
+ // 'https://raw.githubusercontent.com/eurostat/Nuts2json/master/pub/v2/2021/4326/20M/cntrg.json';
17
29
 
18
- const countries_metadata_url = '/en/@@countries-heat-index-json';
19
-
20
- const withCountriesData = (WrappedComponent) => {
21
- function WithCountriesDataWrapped(props) {
22
- let [cpath, setCpath] = React.useState();
23
-
24
- useEffect(() => {
25
- if (!cpath) {
26
- import('./euro-countries-simplified.js').then((mod) => {
27
- const _cpath = mod.default;
28
- _cpath.features = _cpath.features.map(function (c) {
29
- //console.log(c);
30
- var name = c.properties.SHRT_ENGL;
31
- if (!name) {
32
- // console.log('No flag for', c.properties);
33
- return c;
34
- } else if (name === 'Czechia') {
35
- name = 'Czech Republic';
36
- }
37
- var cname = name.replace(' ', '_');
38
- flags.forEach(function (f) {
39
- if (f.indexOf(cname) > -1) {
40
- c.url = f;
41
- //console.log(c.url);
42
- }
43
- });
44
- return c;
45
- });
46
-
47
- setCpath(_cpath);
48
- });
49
- }
50
- }, [cpath]);
30
+ const View = (props) => {
31
+ const { geofeatures, projection } = props;
51
32
 
52
- return cpath ? <WrappedComponent {...props} cpath={cpath} /> : null;
53
- }
54
- return WithCountriesDataWrapped;
55
- };
33
+ const highlight = React.useRef();
34
+ const [stateHighlight, setStateHighlight] = React.useState();
56
35
 
57
- const CountryMapObservatoryView = (props) => {
58
- const svgRef = useRef(null);
59
- const { d3, d3Geo, size, cpath } = props;
60
- const { height, width } = size;
36
+ // eslint-disable-next-line react-hooks/exhaustive-deps
37
+ const styles = React.useMemo(() => makeStyles(highlight), [stateHighlight]);
38
+ const tooltipRef = React.useRef();
39
+ const [tileWMSSources, setTileWMSSources] = React.useState();
40
+ const [euCountriesSource, setEuCountriessource] = React.useState();
61
41
  const [thematicMapMode, setThematicMapMode] = React.useState('hhap');
62
-
42
+ const countries_metadata_url = '/en/@@countries-heat-index-json?langflag=1';
63
43
  const countries_metadata = useCountriesMetadata(
64
44
  addAppURL(countries_metadata_url),
65
45
  );
46
+ const euCountryNames = adjustEuCountryNames(euCountryNamesRaw);
47
+
48
+ const euCountryFeatures = React.useRef();
49
+
50
+ React.useEffect(() => {
51
+ const features = new ol.format.GeoJSON().readFeatures(geofeatures);
52
+ const filtered = features.filter((f) =>
53
+ euCountryNames.includes(f.get('na')),
54
+ );
55
+ //Update name for Bosnia and Herzegovina
56
+ for (let i in features) {
57
+ if (features[i].get('na').includes('Bosnia and Herzegovina')) {
58
+ features[i].set('na', 'Bosnia-Herzegovina');
59
+ break;
60
+ }
61
+ }
66
62
 
67
- useEffect(() => {
68
- // D3 Code
69
-
70
- // Dimensions
71
- //const parentDiv = document.getElementById('page-document');
72
- let dimensions = {
73
- //width: parentDiv.offsetWidth,
74
- width,
75
- height,
76
- margins: 50,
77
- };
78
-
79
- dimensions.containerWidth = dimensions.width - dimensions.margins * 2;
80
- dimensions.containerHeight = dimensions.height - dimensions.margins * 2;
81
-
82
- //const d3 = loadable.lib(() => import('d3'));
83
- // SELECTIONS
84
- const svg = d3
85
- .select(svgRef.current)
86
- .attr('id', 'country_map')
87
- //.classed("line-chart", true)
88
- .attr('width', dimensions.width)
89
- .attr('height', dimensions.height);
90
- //console.log('SVG x-y', svg.getBBox());
91
- /*
92
- const container = svg
93
- .append('g')
94
- .classed('container', true)
95
- .attr(
96
- 'transform',
97
- `translate(${dimensions.margins}, ${dimensions.margins})`,
98
- );
99
- */
100
-
101
- //console.log('cpath', cpath);
102
- //console.log(fpath);
103
- //console.log('Flags',flags);
104
- //console.log('filtered', getFocusCountriesFeature(cpath));
105
-
106
- window.countrySettings = cpath.features;
107
-
108
- var opts = {
109
- world: cpath.features,
110
- countries_metadata: countries_metadata,
111
- thematic_map_mode: thematicMapMode,
112
- svg: svg,
113
- coordinates: {
114
- x: 0,
115
- y: 0,
116
- width: dimensions.containerWidth,
117
- height: dimensions.containerHeight,
118
- },
119
- focusCountries: {
120
- names: getFocusCountryNames(),
121
- feature: getFocusCountriesFeature(cpath),
122
- },
123
- zoom: 0.95,
124
- };
125
- renderCountriesBox(opts, d3, d3Geo);
126
- // Draw Circle
127
- //container.append("circle").attr("r", 25).style("color","blue");
128
- }, [
129
- props.Data,
130
- d3,
131
- width,
132
- height,
133
- cpath,
134
- d3Geo,
135
- thematicMapMode,
136
- countries_metadata,
137
- ]); // redraw chart if data changes
63
+ euCountryFeatures.current = filtered;
64
+
65
+ filtered.forEach((feature) => {
66
+ let countryName = feature.get('na');
67
+ if (countryName === 'Türkiye') {
68
+ countryName = 'Turkey';
69
+ }
70
+ if (Object.hasOwn(countries_metadata, countryName)) {
71
+ let metadata = countries_metadata[countryName];
72
+ if (metadata !== undefined) {
73
+ if (thematicMapMode === 'hhap') {
74
+ switch (metadata.hhap) {
75
+ case 'National HHAP':
76
+ feature.set('fillColor', 'blue1');
77
+ break;
78
+ case 'Subnational or local HHAP':
79
+ feature.set('fillColor', 'blue2');
80
+ break;
81
+ case 'No HHAP':
82
+ feature.set('fillColor', 'gray1');
83
+ break;
84
+ case 'No information':
85
+ feature.set('fillColor', 'gray2');
86
+ break;
87
+ default:
88
+ }
89
+ } else {
90
+ switch (metadata.hhws) {
91
+ case 'HWWS exists':
92
+ feature.set('fillColor', 'blue1');
93
+ break;
94
+ case 'No information':
95
+ feature.set('fillColor', 'gray2');
96
+ break;
97
+ default:
98
+ }
99
+ }
100
+ }
101
+ }
102
+ });
103
+
104
+ setTileWMSSources([
105
+ new ol.source.TileWMS({
106
+ url: 'https://gisco-services.ec.europa.eu/maps/service',
107
+ params: {
108
+ // LAYERS: 'OSMBlossomComposite', OSMCartoComposite, OSMPositronComposite
109
+ LAYERS: 'OSMBrightBackground',
110
+ TILED: true,
111
+ },
112
+ serverType: 'geoserver',
113
+ transition: 0,
114
+ }),
115
+ ]);
116
+
117
+ filtered.forEach((feature) => {
118
+ const img = new Image();
119
+ img.onload = function () {
120
+ feature.set('flag', img);
121
+ };
122
+ img.src = getImageUrl(feature);
123
+ });
124
+
125
+ const euSource = new ol.source.Vector({ features: filtered });
126
+ setEuCountriessource(euSource);
127
+ }, [geofeatures, countries_metadata, thematicMapMode, euCountryNames]);
138
128
 
139
129
  return (
140
130
  <div>
141
131
  <Grid columns="12">
142
132
  <Grid.Column mobile={9} tablet={9} computer={10} className="col-left">
143
- <svg ref={svgRef} />
133
+ {tileWMSSources ? (
134
+ <Map
135
+ view={{
136
+ center: ol.proj.fromLonLat([10, 50], projection),
137
+ projection,
138
+ showFullExtent: true,
139
+ zoom: 4,
140
+ }}
141
+ pixelRatio={1}
142
+ >
143
+ <div
144
+ ref={tooltipRef}
145
+ style={tooltipStyle}
146
+ className="map-tooltip"
147
+ ></div>
148
+ <Controls attribution={false} />
149
+ <Layers>
150
+ {props.mode !== 'edit' && (
151
+ <Interactions
152
+ tooltipRef={tooltipRef}
153
+ // onFeatureClick={onFeatureClick}
154
+ countries_metadata={countries_metadata}
155
+ thematicMapMode={thematicMapMode}
156
+ euCountryFeatures={euCountryFeatures}
157
+ highlight={highlight}
158
+ setStateHighlight={setStateHighlight}
159
+ />
160
+ )}
161
+ <Layer.Vector
162
+ source={euCountriesSource}
163
+ zIndex={7}
164
+ style={styles.eucountriesStyle}
165
+ />
166
+ <Layer.Tile source={tileWMSSources[0]} zIndex={0} />
167
+ </Layers>
168
+ </Map>
169
+ ) : null}
144
170
  </Grid.Column>
145
171
  <Grid.Column
146
172
  mobile={3}
147
173
  tablet={3}
148
174
  computer={2}
149
175
  className="col-left"
150
- id="cse-filter"
176
+ id="country-map-filter"
151
177
  >
152
178
  <Filter
153
179
  thematicMapMode={thematicMapMode}
@@ -160,13 +186,8 @@ const CountryMapObservatoryView = (props) => {
160
186
  };
161
187
 
162
188
  export default compose(
189
+ withGeoJsonData,
163
190
  clientOnly,
164
- injectLazyLibs(['d3', 'd3Geo']),
165
191
  withResponsiveContainer('countryMapHeatIndex'),
166
- withCountriesData,
167
- )(CountryMapObservatoryView);
168
-
169
- // import loadable from '@loadable/component';
170
- //import * as d3 from 'd3';
171
- // import cpath from './euro-countries-simplified';
172
- //
192
+ withVisibilitySensor(),
193
+ )(View);