Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use latest maps-gl dependency for 2.35 version (DHIS2-11967) #1959

Merged
merged 3 commits into from
Dec 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ coverage
src/locales/
.netlify
cypress/videos/
cypress/screenshots/
cypress/screenshots/
cypress.env.json
6 changes: 3 additions & 3 deletions i18n/en.pot
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ msgstr ""
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
"POT-Creation-Date: 2021-04-15T12:12:07.702Z\n"
"PO-Revision-Date: 2021-04-15T12:12:07.702Z\n"
"POT-Creation-Date: 2021-12-02T11:55:27.879Z\n"
"PO-Revision-Date: 2021-12-02T11:55:27.879Z\n"

msgid "Maps"
msgstr ""
Expand Down Expand Up @@ -888,7 +888,7 @@ msgstr ""
msgid "Monthly"
msgstr ""

msgid "Bi-monthly)"
msgid "Bi-monthly"
msgstr ""

msgid "Quarterly"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"@dhis2/d2-ui-interpretations": "^7.3.1",
"@dhis2/d2-ui-org-unit-dialog": "^7.1.6",
"@dhis2/d2-ui-org-unit-tree": "^7.1.6",
"@dhis2/maps-gl": "^1.8.6",
"@dhis2/maps-gl": "^2.2.5",
"@dhis2/ui-core": "^4.1.1",
"@dhis2/ui-widgets": "^2.1.0",
"@material-ui/core": "^4.11.0",
Expand Down
14 changes: 12 additions & 2 deletions src/components/map/EventLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import EventPopup from './EventPopup';
import { getDisplayPropertyUrl } from '../../util/helpers';
import { formatCount } from '../../util/numbers';
import { filterData } from '../../util/filter';
import { getContrastColor } from '../../util/colors';
import { EVENT_COLOR, EVENT_RADIUS } from '../../constants/layers';

class EventLayer extends Layer {
Expand Down Expand Up @@ -45,6 +46,13 @@ class EventLayer extends Layer {
? '#' + eventPointColor
: eventPointColor;

const fillColor = color || EVENT_COLOR;
const strokeColor = !styleDataItem
? getContrastColor(fillColor)
: undefined;
const countColor = strokeColor;
const radius = eventPointRadius || EVENT_RADIUS;

const map = this.context.map;
let d2;
let eventRequest;
Expand All @@ -60,8 +68,10 @@ class EventLayer extends Layer {
opacity,
isVisible,
data: filteredData,
fillColor: color || EVENT_COLOR,
radius: eventPointRadius || EVENT_RADIUS,
fillColor,
strokeColor,
countColor,
radius,
onClick: this.onEventClick.bind(this),
};

Expand Down
5 changes: 1 addition & 4 deletions src/loaders/facilityLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,7 @@ const toGeoJson = (facility, group, contextPath) => ({
id: facility.id,
name: facility.na,
label: `${facility.na} (${group.name})`,
icon: {
iconUrl: `${contextPath}/images/orgunitgroup/${group.symbol}`,
iconSize: [16, 16],
},
iconUrl: `${contextPath}/images/orgunitgroup/${group.symbol}`,
type: 'Point', // Accessible in data table
},
geometry: {
Expand Down
7 changes: 7 additions & 0 deletions src/util/colors.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { hcl } from 'd3-color';
import { isString } from 'lodash/fp';
import colorbrewer from '../constants/colorbrewer';

Expand Down Expand Up @@ -66,3 +67,9 @@ export const cssColor = color => {
}
return (/(^[0-9A-F]{6}$)|(^[0-9A-F]{3}$)/i.test(color) ? '#' : '') + color;
};

// Returns true if a color is dark
export const isDarkColor = color => hcl(color).l < 70;

// Returns constrasting color
export const getContrastColor = color => (isDarkColor(color) ? '#fff' : '#000');
24 changes: 9 additions & 15 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -395,10 +395,10 @@
react-select "^2.0.0"
rxjs "^5.5.7"

"@dhis2/maps-gl@^1.8.6":
version "1.8.6"
resolved "https://registry.yarnpkg.com/@dhis2/maps-gl/-/maps-gl-1.8.6.tgz#f3509f01b4de5d1a6caae5af06f9bb3af792f7cf"
integrity sha512-5mDPvu4aIB3+YGW+ZabI/VG6qgef/iPR2nBbyogDXzmZZnQfJpMTfzcORP4TunwjGhGvvSSXn7KN6HNx8ue3tw==
"@dhis2/maps-gl@^2.2.5":
version "2.2.5"
resolved "https://registry.yarnpkg.com/@dhis2/maps-gl/-/maps-gl-2.2.5.tgz#bf6e9d925ccb3ffdd87c31e8dc29895cf80b4196"
integrity sha512-rhoj6sk7fJuL5y/bHLdzuxAdAf05mGtGWyQN0htQEvAuR428KPemMnYRtR2egBmNDwlqI7CWDJUELoQ2SCVg6Q==
dependencies:
"@mapbox/sphericalmercator" "^1.1.0"
"@turf/area" "^6.3.0"
Expand All @@ -409,8 +409,7 @@
"@turf/length" "^6.3.0"
fetch-jsonp "^1.1.3"
lodash.throttle "^4.1.1"
mapbox-gl "^1.13.1"
mapboxgl-spiderifier "^1.0.9"
maplibre-gl "^1.15.2"
polylabel "^1.1.0"
suggestions "^1.7.1"
uuid "^8.3.2"
Expand Down Expand Up @@ -9197,10 +9196,10 @@ map-visit@^1.0.0:
dependencies:
object-visit "^1.0.0"

mapbox-gl@^1.13.1:
version "1.13.1"
resolved "https://registry.yarnpkg.com/mapbox-gl/-/mapbox-gl-1.13.1.tgz#322efe75ab4c764fc4c776da1506aad58d5a5b9d"
integrity sha512-GSyubcoSF5MyaP8z+DasLu5v7KmDK2pp4S5+VQ5WdVQUOaAqQY4jwl4JpcdNho3uWm2bIKs7x1l7q3ynGmW60g==
maplibre-gl@^1.15.2:
version "1.15.2"
resolved "https://registry.yarnpkg.com/maplibre-gl/-/maplibre-gl-1.15.2.tgz#7fb47868b62455af916c090903f2154394450f9c"
integrity sha512-uPeV530apb4JfX3cRFfE+awFnbcJTOnCv2QvY4mw4huiInbybElWYkNzTs324YLSADq0f4bidRoYcR81ho3aLA==
dependencies:
"@mapbox/geojson-rewind" "^0.5.0"
"@mapbox/geojson-types" "^1.0.2"
Expand All @@ -9226,11 +9225,6 @@ mapbox-gl@^1.13.1:
tinyqueue "^2.0.3"
vt-pbf "^3.1.1"

mapboxgl-spiderifier@^1.0.9:
version "1.0.9"
resolved "https://registry.yarnpkg.com/mapboxgl-spiderifier/-/mapboxgl-spiderifier-1.0.9.tgz#332d3f53eff9b4a0ea9e062dc480ddaae581f244"
integrity sha512-qox8WOWU9MGdH4IL8wtUO/inEyivCi44e4lYStJ9BXuTGU0t2TVdu6SsnStRNqnE67n0423FfCDXycGUj9XROA==

markdown-it@^8.4.2:
version "8.4.2"
resolved "https://registry.yarnpkg.com/markdown-it/-/markdown-it-8.4.2.tgz#386f98998dc15a37722aa7722084f4020bdd9b54"
Expand Down