Skip to content

Commit fdf102b

Browse files
committed
Remove Mapbox-specific code and fallback conditions
Eliminates checks for Mapbox tokens. Eliminates checks for Mapbox tokens and render Mapbox-only style.
1 parent 21bd7e2 commit fdf102b

File tree

9 files changed

+9
-59
lines changed

9 files changed

+9
-59
lines changed

frontend/.env.expand

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ REACT_APP_IMAGE_UPLOAD_API_URL=$TM_IMAGE_UPLOAD_API_URL
2525
REACT_APP_HOMEPAGE_VIDEO_URL=$TM_HOMEPAGE_VIDEO_URL
2626
REACT_APP_HOMEPAGE_IMG_HIGH=$TM_HOMEPAGE_IMG_HIGH
2727
REACT_APP_HOMEPAGE_IMG_LOW=$TM_HOMEPAGE_IMG_LOW
28-
REACT_APP_MAPBOX_TOKEN=$TM_MAPBOX_TOKEN
2928
REACT_APP_ENABLE_SERVICEWORKER=$TM_ENABLE_SERVICEWORKER
3029
REACT_APP_MAX_FILESIZE=$TM_IMPORT_MAX_FILESIZE
3130
REACT_APP_MAX_AOI_AREA=$TM_MAX_AOI_AREA

frontend/src/components/basemapMenu.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
import { useState } from 'react';
22

3-
import { MAPBOX_TOKEN, BASEMAP_OPTIONS } from '../config';
3+
import { BASEMAP_OPTIONS } from '../config';
44

55
export const BasemapMenu = ({ map }) => {
66
// Remove elements that require mapbox token;
7-
let styles = BASEMAP_OPTIONS;
8-
if (!MAPBOX_TOKEN) {
9-
styles = BASEMAP_OPTIONS.filter((s) => typeof s.value === 'object');
10-
}
7+
const styles = BASEMAP_OPTIONS.filter((s) => typeof s.value === 'object');
118

129
const [basemap, setBasemap] = useState(styles[0].label);
1310

frontend/src/components/partnerMapswipeStats/contributionsHeatmap.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,10 @@ import { FormattedMessage } from 'react-intl';
55
import PropTypes from 'prop-types';
66
import 'maplibre-gl/dist/maplibre-gl.css';
77

8-
import { MAPBOX_TOKEN, MAP_STYLE, CHART_COLOURS } from '../../config';
8+
import { MAP_STYLE, CHART_COLOURS } from '../../config';
99
import messages from './messages';
1010
import './contributionsHeatmap.css';
1111

12-
maplibregl.accessToken = MAPBOX_TOKEN;
13-
1412
export const ContributionsHeatmap = ({ contributionsByGeo = [] }) => {
1513
const mapContainer = useRef(null);
1614
const map = useRef(null);

frontend/src/components/projectCreate/projectCreationMap.js

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,13 @@ import maplibregl from 'maplibre-gl';
44
import 'maplibre-gl/dist/maplibre-gl.css';
55
import { featureCollection } from '@turf/helpers';
66
import MapboxLanguage from '@mapbox/mapbox-gl-language';
7-
import MaplibreGeocoder from '@maplibre/maplibre-gl-geocoder';
87
import '@maplibre/maplibre-gl-geocoder/dist/maplibre-gl-geocoder.css';
98
import { useDropzone } from 'react-dropzone';
109

1110
import { maplibreLayerDefn } from '../projects/projectsMap';
1211
import useMapboxSupportedLanguage from '../../hooks/UseMapboxSupportedLanguage';
1312

14-
import { MAPBOX_TOKEN, MAP_STYLE, CHART_COLOURS, TASK_COLOURS } from '../../config';
13+
import { MAP_STYLE, CHART_COLOURS, TASK_COLOURS } from '../../config';
1514
import { fetchLocalJSONAPI } from '../../network/genericJSONRequest';
1615
import { useDebouncedCallback } from '../../hooks/UseThrottle';
1716
import isWebglSupported from '../../utils/isWebglSupported';
@@ -20,8 +19,6 @@ import { BasemapMenu } from '../basemapMenu';
2019
import { ProjectsAOILayerCheckBox } from './projectsAOILayerCheckBox';
2120
import WebglUnsupported from '../webglUnsupported';
2221

23-
maplibregl.accessToken = MAPBOX_TOKEN;
24-
2522
const ProjectCreationMap = ({ mapObj, setMapObj, metadata, updateMetadata, step, uploadFile }) => {
2623
const mapRef = createRef();
2724
const mapboxSupportedLanguage = useMapboxSupportedLanguage();
@@ -82,18 +79,6 @@ const ProjectCreationMap = ({ mapObj, setMapObj, metadata, updateMetadata, step,
8279
.addControl(new maplibregl.AttributionControl({ compact: false }))
8380
.addControl(new MapboxLanguage({ defaultLanguage: mapboxSupportedLanguage }))
8481
.addControl(new maplibregl.ScaleControl({ unit: 'metric' }));
85-
if (MAPBOX_TOKEN) {
86-
map.addControl(
87-
new MaplibreGeocoder({
88-
accessToken: MAPBOX_TOKEN,
89-
maplibregl,
90-
marker: false,
91-
collapsed: true,
92-
language: mapboxSupportedLanguage,
93-
}),
94-
'top-right',
95-
);
96-
}
9782

9883
setMapObj({ ...mapObj, map: map });
9984
return () => {
@@ -254,24 +239,6 @@ const ProjectCreationMap = ({ mapObj, setMapObj, metadata, updateMetadata, step,
254239
setAOICanBeActivated(true);
255240
}
256241
});
257-
258-
mapObj.map.on('style.load', (event) => {
259-
if (!MAPBOX_TOKEN) {
260-
return;
261-
}
262-
addMapLayers(mapObj.map);
263-
const features = mapObj.draw.getAll();
264-
if (features.features.length === 0 && mapObj.map.getSource('aoi') !== undefined) {
265-
mapObj.map.getSource('aoi').setData(metadata.geom);
266-
}
267-
268-
if (metadata.taskGrid && step !== 1 && mapObj.map.getSource('grid') !== undefined) {
269-
mapObj.map.getSource('grid').setData(metadata.taskGrid);
270-
} else {
271-
mapObj.map.getSource('grid') &&
272-
mapObj.map.getSource('grid').setData(featureCollection([]));
273-
}
274-
});
275242
}
276243
}, [mapObj, metadata, updateMetadata, step]);
277244

frontend/src/components/projectEdit/priorityAreasForm.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import messages from './messages';
1313
import { StateContext, styleClasses } from '../../views/projectEdit';
1414
import { CustomButton } from '../button';
1515
import { MappedIcon, WasteIcon, MappedSquareIcon, FileImportIcon } from '../svgIcons';
16-
import { MAPBOX_TOKEN, MAP_STYLE, CHART_COLOURS } from '../../config';
16+
import { MAP_STYLE, CHART_COLOURS } from '../../config';
1717
import { BasemapMenu } from '../basemapMenu';
1818
import {
1919
verifyGeometry,
@@ -28,8 +28,6 @@ import { Alert } from '../alert';
2828
import WebglUnsupported from '../webglUnsupported';
2929
import useMapboxSupportedLanguage from '../../hooks/UseMapboxSupportedLanguage';
3030

31-
maplibregl.accessToken = MAPBOX_TOKEN;
32-
3331
export const PriorityAreasForm = () => {
3432
const { projectInfo, setProjectInfo } = useContext(StateContext);
3533
const mapboxSupportedLanguage = useMapboxSupportedLanguage();

frontend/src/components/projects/projectsMap.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,14 @@ import MapboxLanguage from '@mapbox/mapbox-gl-language';
66
import WebglUnsupported from '../webglUnsupported';
77
import isWebglSupported from '../../utils/isWebglSupported';
88
import useSetRTLTextPlugin from '../../utils/useSetRTLTextPlugin';
9-
import { MAPBOX_TOKEN, MAP_STYLE } from '../../config';
9+
import { MAP_STYLE } from '../../config';
1010
import mapMarker from '../../assets/img/mapMarker.png';
1111
import useMapboxSupportedLanguage from '../../hooks/UseMapboxSupportedLanguage';
1212

1313
let markerIcon = new Image(17, 20);
1414
markerIcon.src = mapMarker;
1515

16-
maplibregl.accessToken = MAPBOX_TOKEN;
17-
18-
const licensedFonts = MAPBOX_TOKEN
19-
? ['DIN Offc Pro Medium', 'Arial Unicode MS Bold']
20-
: ['Open Sans Semibold'];
16+
const licensedFonts = ['Open Sans Semibold'];
2117

2218
export const maplibreLayerDefn = (map, mapResults, clickOnProjectID, disablePoiClick = false) => {
2319
map.addImage('mapMarker', markerIcon, { width: 15, height: 15, data: markerIcon });

frontend/src/components/taskSelection/map.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import WebglUnsupported from '../webglUnsupported';
1010
import isWebglSupported from '../../utils/isWebglSupported';
1111
import useSetRTLTextPlugin from '../../utils/useSetRTLTextPlugin';
1212
import messages from './messages';
13-
import { MAPBOX_TOKEN, TASK_COLOURS, MAP_STYLE } from '../../config';
13+
import { TASK_COLOURS, MAP_STYLE } from '../../config';
1414
import lock from '../../assets/img/lock.png';
1515
import redlock from '../../assets/img/red-lock.png';
1616
import useMapboxSupportedLanguage from '../../hooks/UseMapboxSupportedLanguage';
@@ -21,8 +21,6 @@ lockIcon.src = lock;
2121
let redlockIcon = new Image(17, 20);
2222
redlockIcon.src = redlock;
2323

24-
maplibregl.accessToken = MAPBOX_TOKEN;
25-
2624
export const TasksMap = ({
2725
className,
2826
mapResults,

frontend/src/components/userDetail/countriesMapped.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,14 @@ import MapboxLanguage from '@mapbox/mapbox-gl-language';
55
import { FormattedMessage } from 'react-intl';
66

77
import messages from './messages';
8-
import { MAPBOX_TOKEN, MAP_STYLE } from '../../config';
8+
import { MAP_STYLE } from '../../config';
99
import { maplibreLayerDefn } from '../projects/projectsMap';
1010
import { BarListChart } from './barListChart';
1111
import WebglUnsupported from '../webglUnsupported';
1212
import isWebglSupported from '../../utils/isWebglSupported';
1313
import useSetRTLTextPlugin from '../../utils/useSetRTLTextPlugin';
1414
import useMapboxSupportedLanguage from '../../hooks/UseMapboxSupportedLanguage';
1515

16-
maplibregl.accessToken = MAPBOX_TOKEN;
17-
1816
const UserCountriesMap = ({ projects }) => {
1917
const navigate = useNavigate();
2018
const mapboxSupportedLanguage = useMapboxSupportedLanguage();

frontend/src/config/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ export const DEFAULT_LOCALE = process.env.REACT_APP_DEFAULT_LOCALE || 'en';
1414
export const ENVIRONMENT = process.env.REACT_APP_ENVIRONMENT || '';
1515
export const PROJECTCARD_CONTRIBUTION_SHOWN_THRESHOLD =
1616
process.env.REACT_APP_PROJECTCARD_CONTRIBUTION_SHOWN_THRESHOLD || 5;
17-
export const MAPBOX_TOKEN = process.env.REACT_APP_MAPBOX_TOKEN || '';
1817
export const ENABLE_SERVICEWORKER = process.env.REACT_APP_ENABLE_SERVICEWORKER || 0;
1918
export const MAX_AOI_AREA = Number(process.env.REACT_APP_MAX_AOI_AREA) || 5000;
2019
export const MAX_FILESIZE = parseInt(process.env.REACT_APP_MAX_FILESIZE) || 1000000; // bytes

0 commit comments

Comments
 (0)