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

address stylistic issues in the public map layer code #3716

Merged
merged 1 commit into from
Nov 27, 2024
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
2 changes: 1 addition & 1 deletion app/src/UI/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Redirect, Route, useHistory } from 'react-router-dom';
import './App.css';
import { Footer } from './Footer/Footer';
import { Header } from './Header/Header';
import { MainMap as PublicMap } from './Map2/Map3';
import { PublicMap } from './Map2/PublicMap';
import { Map } from './Map2/Map';
import { LandingComponent } from './Overlay/Landing/Landing';
import Overlay from './Overlay/Overlay';
Expand Down
42 changes: 9 additions & 33 deletions app/src/UI/Map2/Map3.tsx → app/src/UI/Map2/PublicMap.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import React, { useEffect, useRef, useState } from 'react';
import { useSelector } from 'utils/use_selector';
import Map, { ScaleControl, NavigationControl } from 'react-map-gl/maplibre';
import Map, { NavigationControl, ScaleControl } from 'react-map-gl/maplibre';
import { getCurrentJWT } from 'state/sagas/auth/auth';
import maplibregl from 'maplibre-gl';
// import { RecordSetLayers } from './RecordSetLayers3';
import { PublicLayer } from './PublicLayer';
import { MOBILE } from 'state/build-time-config';

Expand Down Expand Up @@ -105,15 +104,19 @@ const mapStyleLayers: Record<string, maplibregl.LayerSpecification[]> = {
]
};

export const MainMap = ({ children }) => {
export const PublicMap = ({ children }) => {
const API_BASE = useSelector((state) => state.Configuration.current.API_BASE);
const authenticated = useSelector((state) => state.Auth.authenticated);
const [currentAuthHeader, setCurrentAuthHeader] = useState<string>('');
const authHeaderRef = useRef<string>();
authHeaderRef.current = currentAuthHeader;
const baseMapLayer = useSelector((state: any) => state.Map.baseMapLayer);
const baseMapLayer = useSelector((state) => state.Map.baseMapLayer);
const map_center = useSelector((state) => state.Map.map_center);

if (!baseMapLayer) {
return null;
}

const mapstyle_current_layer: maplibregl.LayerSpecification[] = mapStyleLayers[wmsBaseLayersValue[baseMapLayer]];

/* map can have platform-specific options */
Expand Down Expand Up @@ -156,7 +159,7 @@ export const MainMap = ({ children }) => {
}
return authHeaderRef.current;
};
const transformRequest = (url, resourceType) => {
const transformRequest: maplibregl.RequestTransformFunction = (url) => {
if (url.includes(API_BASE)) {
return {
url,
Expand Down Expand Up @@ -184,7 +187,6 @@ export const MainMap = ({ children }) => {
attributionControl={false}
transformRequest={transformRequest}
mapLib={maplibregl}
// interactiveLayerIds={['pmtiles-layer']}
mapStyle={{
...(MOBILE && { sprite: '/assets/basemaps/sprite/sprite' }),
glyphs: MOBILE
Expand All @@ -200,38 +202,12 @@ export const MainMap = ({ children }) => {
layers: mapstyle_current_layer
}}
>
{/* <Source
id='esri-sat-label-source'
type='raster'
tiles={[
'https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}'
]}
tileSize={256}
maxzoom={18}
/>
<Source
id='esri-sat-layer-hd'
type='raster'
tiles={[
"https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}"
]}
tileSize={256}
>
<Layer
id='wms-layer'
type='raster'
source='esri-sat-layer-hd'
/>
</Source> */}

<ScaleControl maxWidth={80} unit="metric" position="top-left" />
<NavigationControl position="top-left" />

{!authenticated ? <PublicLayer /> : <></>}

{/* <RecordSetLayers /> */}
</Map>
<div id="LoadingMap" className={!true ? 'loadingMap' : 'loadedMap'}>
<div id="LoadingMap" className={'loadedMap'}>
Loading tiles...
</div>
{children}
Expand Down
Loading