File tree Expand file tree Collapse file tree
frontend/src/components/Map/components/AltimetricProfile Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import { useMap } from 'react-leaflet';
66import { useIntl } from 'react-intl' ;
77import { useRouter } from 'next/router' ;
88import { getDefaultLanguage } from 'modules/header/utills' ;
9+ import { FeatureCollection , LineString } from 'geojson' ;
910
1011interface AltimetricProfileProps {
1112 trekGeoJSON : string ;
@@ -22,6 +23,11 @@ export const AltimetricProfile: React.FC<AltimetricProfileProps> = ({ trekGeoJSO
2223 return ;
2324 }
2425
26+ const { features } = JSON . parse ( trekGeoJSON ) as FeatureCollection ;
27+ const elevationValues = ( features [ 0 ] . geometry as LineString ) . coordinates . map ( coord => coord [ 2 ] ) ;
28+ const yAxisMin = Math . min ( ...elevationValues ) * 0.75 ;
29+ const yAxisMax = Math . max ( ...elevationValues ) * 1.25 ;
30+
2531 // @ts -expect-error the lib is not typed
2632 const elevationControl = L . control . elevation ( {
2733 theme : 'lightblue-theme' ,
@@ -33,6 +39,8 @@ export const AltimetricProfile: React.FC<AltimetricProfileProps> = ({ trekGeoJSO
3339 followMarker : false ,
3440 legend : false ,
3541 zooming : false ,
42+ yAxisMin,
43+ yAxisMax,
3644 } ) ;
3745 elevationControl . addTo ( map ) ;
3846
You can’t perform that action at this time.
0 commit comments