From 8a2f85faa4b193c5f3f5349fafcb1f0a1f04017d Mon Sep 17 00:00:00 2001 From: Sajjad Anwar Date: Mon, 17 Jul 2023 16:49:33 +0530 Subject: [PATCH 1/2] dont filter kosovo. create an non-independent label style --- .../components/map/common/map-component.js | 3 +- src/root/selectors/index.js | 7 +++-- src/root/utils/country-labels.js | 28 +++++++++++++++++++ 3 files changed, 35 insertions(+), 3 deletions(-) diff --git a/src/root/components/map/common/map-component.js b/src/root/components/map/common/map-component.js index f94a92438..9e6fab5c5 100755 --- a/src/root/components/map/common/map-component.js +++ b/src/root/components/map/common/map-component.js @@ -9,7 +9,7 @@ import exportMap from '#utils/export-map'; import DownloadButton from './download-button'; import MapHeader from './map-header'; import Translate from '#components/Translate'; -import { countryLabels } from '#utils/country-labels'; +import { countryLabels, countryNonIndependentLabels } from '#utils/country-labels'; export default class MapComponent extends React.Component { constructor (props) { @@ -39,6 +39,7 @@ export default class MapComponent extends React.Component { // add custom language labels this.theMap.addLayer(countryLabels); + this.theMap.addLayer(countryNonIndependentLabels); } get(this.props, 'layers', []).forEach(layer => this.theMap.addLayer(layer)); diff --git a/src/root/selectors/index.js b/src/root/selectors/index.js index ab406581d..102db14b6 100644 --- a/src/root/selectors/index.js +++ b/src/root/selectors/index.js @@ -182,9 +182,10 @@ export const countriesGeojsonSelector = (state) => { state.allCountries.data.results.forEach(country => { // select only independent = true or null and record_type = 1 // also remove ICRC and IFRC + // don't filter independent=false Kosovo using id 335 if ( country.centroid && - (country.independent || country.independent === null) && + (country.independent || country.independent === null || country.id === 335) && country.record_type === 1 && // This filters out the ICRC and IFRC "countries". FIXME: this should be handled better @@ -198,7 +199,9 @@ export const countriesGeojsonSelector = (state) => { 'name': country.iso === 'ps' ? palestineLabel(currentLang) : country.name, 'iso': country.iso, 'iso3': country.iso3, - 'society_name': country.society_name + 'society_name': country.society_name, + 'independent': country.independent, + 'id': country.id } }; featureCollection.features.push(f); diff --git a/src/root/utils/country-labels.js b/src/root/utils/country-labels.js index 72ad0d0df..9df4c02b4 100644 --- a/src/root/utils/country-labels.js +++ b/src/root/utils/country-labels.js @@ -17,9 +17,37 @@ export const countryLabels = { 6, 16 ] }, + filter: ['==', ['get', 'independent'], true], paint: { 'text-color': '#000000', 'text-halo-color': '#000000', 'text-halo-width': 0.2 } +}; + +export const countryNonIndependentLabels = { + 'id': 'countryNonIndependentLabels', + 'source': 'countryCentroids', + 'type': 'symbol', + layout: { + 'text-field': ['get', 'name'], + 'text-font': ['Poppins Regular', 'Arial Unicode MS Regular'], + 'text-letter-spacing': 0.15, + 'text-line-height': 1.2, + 'text-max-width': 8, + 'text-justify': 'center', + 'text-anchor': 'top', + 'text-padding': 2, + 'text-size': [ + 'interpolate', ['linear', 1], ['zoom'], + 0, 5, + 6, 15 + ] + }, + filter: ['==', ['get', 'independent'], false], + paint: { + 'text-color': '#aaaaaa', + 'text-halo-color': '#000000', + 'text-halo-width': 0.2 + } }; \ No newline at end of file From e1f1674dd196ba8500ab2c8af713072e993cb4c1 Mon Sep 17 00:00:00 2001 From: Sajjad Anwar Date: Mon, 17 Jul 2023 16:55:43 +0530 Subject: [PATCH 2/2] adjust style --- src/root/utils/country-labels.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/root/utils/country-labels.js b/src/root/utils/country-labels.js index 9df4c02b4..dd511b4f7 100644 --- a/src/root/utils/country-labels.js +++ b/src/root/utils/country-labels.js @@ -46,8 +46,8 @@ export const countryNonIndependentLabels = { }, filter: ['==', ['get', 'independent'], false], paint: { - 'text-color': '#aaaaaa', - 'text-halo-color': '#000000', + 'text-color': '#716f6f', + 'text-halo-color': '#ffffff', 'text-halo-width': 0.2 } }; \ No newline at end of file