-
Notifications
You must be signed in to change notification settings - Fork 3
[G2M] POIMap clusters #91
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
Conversation
d2e29f1 to
7066db0
Compare
…setLayer in it from shared/utils
… we see or not clusters in the current viewport
…luster to state and use it to change map layers and view
…erclusterRadius from constants and shared/utils
…tate; refactor useEffect for showClusters state; add onViewStateChange to get zoom; refactor onInteractionStateChange
…add switch for Show Clusters; adjust mapLayers to the new state; add conditions for switch elements
… to calculate clusters
…onViewStateChange; move setLayerVisibleData to onAfterRender; fix useEffect fro clusterZoom
c40f0bb to
20238f9
Compare
woozyking
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, minor suggestions
src/components/poi-map/index.js
Outdated
| if (mapLayers.includes('POICluster')) { | ||
| setClusterClick(true) | ||
| } else { | ||
| setClusterClick(false) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- perhaps
| if (mapLayers.includes('POICluster')) { | |
| setClusterClick(true) | |
| } else { | |
| setClusterClick(false) | |
| } | |
| setClusterClick(mapLayers.includes('POICluster')) |
src/components/layers/poi-cluster.js
Outdated
| const index = new Supercluster({ | ||
| maxZoom: props.superclusterZoom, | ||
| radius: props.getSuperclusterRadius(this.context.viewport.zoom, props.sizeScale), | ||
| radius: props.getSuperclusterRadius({ zoom: this.context.viewport.zoom }), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
```suggestion
radius: props.getSuperclusterRadius(this.context.viewport),
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After I get zoom in by clicking a POI and I toggle the show cluster or show radius it zooms me back to its map original view. Is this how it supposed to behave?
Screen.Recording.2021-09-28.at.10.18.27.AM.mov
24029ed to
3ca2e2a
Compare
Yes, the integration with POIManage will use the onClick event that will select an activePOI with the result of selecting that activePOI as the only POI on the map, so this is not seen in POIManage. Here is how it works: Screen.Recording.2021-09-28.at.12.19.24.PM.mov |
eef8978 to
55eecfb
Compare
1351464 to
fe32f81
Compare
…state in useLayoutEffect; simplify conditions for switch rendering
fe32f81 to
9236d34
Compare
… useResizeObserver
…k; reset clusterClick at the end of useLayoutEffect"
a50f011 to
4a600a1
Compare
woozyking
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
approved with some minor observations
| */ | ||
| const setLayer = ({ layer, props, visible }) => | ||
| layer === 'POICluster' ? | ||
| new eqMapLayers[layer]({ ...props, visible }) : |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- why does the
POIClustertype layer requirenewto instantiate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cluster layer is a class component - I am pretty sure you asked that before, like a year ago LOL. When I have time will try change it into function.
Source: https://github.com/visgl/deck.gl/blob/8.5-release/examples/website/icon/icon-cluster-layer.js
| */ | ||
| export const isClusterZoomLevel = ({ layerVisibleData, viewportBBOX, zoom }) => { | ||
| const visiblePOIs = layerVisibleData.reduce((agg, elem) => { | ||
| return elem.objects ? [...agg, ...elem.objects] : [...agg, elem.object] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- would you mean
return Array.isArray(elem.objects) ? [...agg, ...elem.objects] : [...agg, elem.object]There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/components/poi-map/utils.js
Outdated
| return elem.objects ? [...agg, ...elem.objects] : [...agg, elem.object] | ||
| }, []) | ||
|
|
||
| if (visiblePOIs?.length) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- with a reduce operation like ^
visiblePOIsshould be guaranteed as an Array, thus the optional chain should be unnecessary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
squashed
… there was a delay in the POICluster of calc zoom and we had cluster icons changing quick between 2 zooms; set transitionDuration to 2 sec; remove optional chain for visiblePOI in isClusterZoomLevel
73c24c5 to
73a2aab
Compare


Cluster implementation:
Storybook: https://60f06c1c5a1772003b824d76-dbmgbrqtav.chromatic.com/
Logic for state use: https://www.figma.com/file/g2ww5nK6pazEWRTlmPKXXV/POIMap---cluster-logic
Recording:
Screen.Recording.2021-09-28.at.9.27.59.AM.mov