Skip to content
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

Paint by county #74

Merged
merged 4 commits into from
Aug 31, 2024
Merged

Paint by county #74

merged 4 commits into from
Aug 31, 2024

Conversation

raphaellaude
Copy link
Collaborator

@raphaellaude raphaellaude commented Aug 29, 2024

Description

  • Support variable paint/hover functions w/ single mapEvent
    • Add paint/hover function to mapStore
    • Refactor map hover and click event to use store's function
  • Add (still slightly buggy) paint by county function (fixes Paint by County #68). Mostly works well but has a hard time with complex geometries. Need to dig into it a bit.

Discussion

  • Advantage of this geometry-based paint-by-countie method over a data-based approach (i.e. having county FIPS in layer features) is we don't need to send that extra data down and could easily support paint-by-{{ insert geometry here }}
  • Downside is it's slightly less reliable (for now) and may have slightly worse perf – though it feels fine to me. One idea is for any document using census geographies we could querySourceFeatures using an expression that slices the first five chars in the Path. In that case the geometry-based approach is more of a fallback but nice-to-have.
  • Either way, the pattern of storing the function in the mapStore works v well.

Reviewers

Checklist

  • Added/Updated related documentation (if applicable).
  • Added/Updated related unit tests (if applicable).

Screenshots (if applicable):

output.mp4

Comment on lines +1681 to +1684
paint: {
"fill-color": "#fff",
"fill-opacity": 0,
},
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kind of an ugly hack for queryRenderedFeatures to work but was fine with it.

Comment on lines +130 to +131
paintFunction: getFeaturesInBbox,
setPaintFunction: (paintFunction) => set({ paintFunction }),
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using this pattern made it really easy to handle different behaviors on hover without messing with map events.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i like it!

@raphaellaude raphaellaude self-assigned this Aug 29, 2024
@raphaellaude raphaellaude added enhancement New feature or request frontend roadmap layers Contextual map layers including the basemap labels Aug 29, 2024
@raphaellaude raphaellaude marked this pull request as ready for review August 29, 2024 04:04
Copy link
Collaborator

@mariogiampieri mariogiampieri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks good to me

@raphaellaude raphaellaude merged commit 0870642 into main Aug 31, 2024
@raphaellaude raphaellaude deleted the paint-by-county branch August 31, 2024 15:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request frontend layers Contextual map layers including the basemap roadmap
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Paint by County
2 participants