Closed jamesdoyle21 closed 2 years ago
This is easy to do, but I really think we need to combine the layer settings & layer details into only a few objects before doing this. Currently in the compare tool (and many others), support for traffic light layers is hardcoded into the tool with basically no other way to do it because of the way we handle our layer settings. To add support for custom layers, all I would have to do is hardcode it in, which is easy.
This is going to bite us at some point if we don't figure this out soon, as the more layer types we support the more hardcoding we are going to have to do.
Yeah, when you get a chance do you want to work up an example of what the proposed rafactor would look like?
I think we want to have 2 objects, an extended mapLayers
and layerSettings
, which would combine all of the wmsSettings
, trafficLightLayers
, scenarioLayers
, etc. We get rid of all of the selectedCatalogItems
and selectedTrafficLightLayers
and just use the mapLayers
to determine what is selected. I'm not really sure we should do with extents, maybe we make that a 3rd object?
For mapLayers
I think we should add the following fields:
mapLayers
will be required to accesstype
would be used for specific functionalitiesMapTwo
to re-render the layer. Once Map
has sent the refreshedLayers
to MapTwo
, this flag should be set to falseThose are the main fields to add that would probably alone cut the requests to the different layer settings objects in half, as a lot of the time we are accessing those objects just to get like the name of the layer.
Here is my proposed layerSettings
:
setMapLayer
setMapLayer
would update the mapLayers[layerID]
toUpdate flag to truewmsSettings
, trafficLightLayers
, etc)Also, to avoid infinite render loops maybe we have another object called mapLayerKeys
that works like selectedLayers
? Or maybe you can call Object.keys(mapLayers)
as a useEffect
dependency idk
These are just preliminary thoughts on how we would simplify all of our different objects. I would love to bounce these ideas with everyone so that we can make sure all of our bases are covered
Some sort of abstracting of legend? (like title being default on there or something)
This is a good start and lines up with how im thinking we need to move to start being able to rapidly add new types of letters without making the state bloat to be 10 gb or whatever
User should have the option to see their custom layers with the slider