From 444667ca35217a96c6ef82b129e4e2b0c88d2860 Mon Sep 17 00:00:00 2001 From: Nate-Wessel Date: Thu, 19 Dec 2024 19:57:00 +0000 Subject: [PATCH] render nodes --- frontend/src/Map/index.jsx | 62 ++++++++++++++------------------------ frontend/src/corridor.js | 3 ++ 2 files changed, 25 insertions(+), 40 deletions(-) diff --git a/frontend/src/Map/index.jsx b/frontend/src/Map/index.jsx index 82da717..4a642f8 100644 --- a/frontend/src/Map/index.jsx +++ b/frontend/src/Map/index.jsx @@ -1,10 +1,5 @@ -import { - CircleMarker, - Popup, - Polyline, - LayerGroup -} from 'react-leaflet' -import {Map, useMap} from 'react-map-gl/maplibre' +import {CircleMarker, Polyline, LayerGroup} from 'react-leaflet' +import {Map, useMap, Source, Layer} from 'react-map-gl/maplibre' import { useContext, useState } from 'react' import { DataContext } from '../Layout' import { useMapEvent } from 'react-leaflet/hooks' @@ -46,39 +41,26 @@ function DataLayer(){ } ) } } ) - return <> - return data.corridors.filter( c => c.isComplete || c.isActive ).map( (corridor,i) => { - // red: active not complete; green: active complete: grey: inactive - const color = corridor.isActive ? corridor.isComplete ? 'green' : 'red' : '#0005' - return ( - - {corridor.intersections.map( intersection => ( - - {corridor.isActive && -

{intersection.description}

- - - - -
Intersection ID{intersection.id}
-
} -
- ) ) } - {corridor.links.map( link => { - return ( - ({lng,lat}) ) } - pathOptions={{color}} - /> - ) - } ) } -
- ) - } ) + const corridorsGeojson = { + type: 'FeatureCollection', + features: data.corridors.flatMap(c=>c.geojsonFeatures) + } + const nodeStyle = { + id:'corridor-links', + type:'circle', + paint:{'circle-radius': 5, 'circle-color': 'red'} + } + const lineStyle = { + id:'corridor-links', + type:'line', + paint:{'line-width': 10, 'line-color': 'black'} + } + return ( + + + + + ) } function NodeLayer(){ diff --git a/frontend/src/corridor.js b/frontend/src/corridor.js index cc0ec26..60a84c5 100644 --- a/frontend/src/corridor.js +++ b/frontend/src/corridor.js @@ -20,6 +20,9 @@ export class Corridor extends Factor { return link.source == links[i-1].target } ) } + get geojsonFeatures(){ + return this.intersections.map( i => i.geojson ) + } addIntersection(intersection,logActivity){ console.assert(intersection instanceof Intersection) this.#intersections.set(intersection.id, intersection)