@@ -4,14 +4,13 @@ import maplibregl from 'maplibre-gl';
44import 'maplibre-gl/dist/maplibre-gl.css' ;
55import { featureCollection } from '@turf/helpers' ;
66import MapboxLanguage from '@mapbox/mapbox-gl-language' ;
7- import MaplibreGeocoder from '@maplibre/maplibre-gl-geocoder' ;
87import '@maplibre/maplibre-gl-geocoder/dist/maplibre-gl-geocoder.css' ;
98import { useDropzone } from 'react-dropzone' ;
109
1110import { maplibreLayerDefn } from '../projects/projectsMap' ;
1211import 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' ;
1514import { fetchLocalJSONAPI } from '../../network/genericJSONRequest' ;
1615import { useDebouncedCallback } from '../../hooks/UseThrottle' ;
1716import isWebglSupported from '../../utils/isWebglSupported' ;
@@ -20,8 +19,6 @@ import { BasemapMenu } from '../basemapMenu';
2019import { ProjectsAOILayerCheckBox } from './projectsAOILayerCheckBox' ;
2120import WebglUnsupported from '../webglUnsupported' ;
2221
23- maplibregl . accessToken = MAPBOX_TOKEN ;
24-
2522const 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
0 commit comments