Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
jo-chemla committed Jun 26, 2024
2 parents abf7724 + 2740d15 commit 1ed1124
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"date-fns": "^2.30.0",
"dayjs": "^1.11.7",
"mapbox-gl": "^2.14.1",
"mapbox-gl-controls": "^2.3.5",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-map-gl": "^7.0.23",
Expand Down
24 changes: 19 additions & 5 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { useState, useRef, useEffect, useCallback, useMemo } from "react";

import "./App.css";
import Map, { type MapRef, Source, Layer, ScaleControl } from "react-map-gl";
import Map, { type MapRef, Source, Layer, ScaleControl, useControl } from "react-map-gl";
import GeocoderControl from "./geocoder-control";
import ControlPanel, { type MapSplitMode } from "./control-panel";
import { set, subMonths } from "date-fns";
import Split from "react-split";
import {RulerControl} from 'mapbox-gl-controls'
import { ToggleButton, ToggleButtonGroup } from "@mui/material";

import { ToggleButton, ToggleButtonGroup, Button } from "@mui/material";

import {
planetBasemapUrl,
Expand All @@ -19,7 +20,7 @@ import {
import mapboxgl from "mapbox-gl";

const MAPBOX_TOKEN = import.meta.env.VITE_MAPBOX_TOKEN;

let rulerOk = false;
// TODO Avoid tile popping on setTiles of rasterTileSet imagery source
// https://github.com/mapbox/mapbox-gl-js/issues/12707

Expand All @@ -32,7 +33,8 @@ function App() {
// State variables
const [backgroundBasemapStyle, setBackgroundBasemapStyle] = useState<any>(
// "satellite-streets-v12"
{ version: 8, sources: {}, layers: [] }
{ version: 8, sources: {}, layers: [], glyphs:"mapbox://fonts/mapbox/{fontstack}/{range}.pbf"
}
);
// const backgroundBasemapStyle = "satellite-streets-v12";
// const [leftTimelineDate, setLeftTimelineDate] = useState<Date>(
Expand Down Expand Up @@ -91,6 +93,17 @@ function App() {
// rightMapRef.current.resize();
}

const leftRuler = new RulerControl();
const rightRuler = new RulerControl();

if (!rulerOk) {
console.log("Adding ruler control");
leftMapRef.current?.getMap()?.addControl(leftRuler, "top-left");
rightMapRef.current?.getMap()?.addControl(rightRuler, "top-right");
if (leftMapRef.current?.getMap()) {rulerOk=true;}
// setRulerOk(true);
}

// Update raster TMS source faster than react component remount on timelineDate state update
// useEffect(() => {
// leftMapRef.current
Expand Down Expand Up @@ -155,6 +168,7 @@ function App() {
// Adding blending mode
mixBlendMode: blendingActivation ? blendingMode : "normal",
opacity: opacity,

};
useEffect(() => {
resizeMaps();
Expand Down Expand Up @@ -397,7 +411,6 @@ function App() {
onMove={activeMap === "right" ? onMoveDebounce : () => ({})}
style={RightMapStyle}
mapStyle={rightMapboxMapStyle}

>
{rightSelectedTms == BasemapsIds.Mapbox ? (
<></>
Expand Down Expand Up @@ -427,6 +440,7 @@ function App() {
<Layer type="raster" layout={{}} paint={{}} />
</Source>
)}
<ScaleControl maxWidth={60} unit="metric" position={'top-right'}/>
</Map>
<ControlPanel
// Adding blending mode opacity, and blending mode activation to pass downward
Expand Down

0 comments on commit 1ed1124

Please sign in to comment.