carto-react icon indicating copy to clipboard operation
carto-react copied to clipboard

[RFC] Add a territory selector widget

Open efernandezleon opened this issue 2 years ago • 3 comments

Target Use Case

Many projects from PS need the functionality of filtering some layers (and widgets) based on territory (state, city, county, DMA, FSA, ...). Some examples of projects that use this feature would be Telus Insight or Radarview, where a user wants to focus the data exploration on a specific geometry that comes from a well-known territory.

Implementation Proposal

To cover this functionality, the framework C4R could provide a widget composed of a UI component to select a territory (single dropdown select or autocomplete) that uses a source to show the geometry in the map by using the Spatial Filter to filter some layers. An extra ball for business strategy could be to support directly territory geometries from the DO, like https://carto.com/spatial-data-catalog/browser/geography/cdb_block_96b823a2/ or https://carto.com/spatial-data-catalog/browser/geography/mbi_counties_46ea8aaa

Some options for this widget can be:

  • Filtered sources: list of sources to be filtered when a territory is selected
  • Show the contour: boolean to indicate if the contour of the geometry should be shown or not

efernandezleon avatar Oct 05 '22 09:10 efernandezleon

You can load a GeoJson layer that represents the territory selected and add the spatial filter using the addSpatialFilter action

padawannn avatar Oct 05 '22 14:10 padawannn

@padawannn Yes, that would be the under-the-hood implementation, we can develop a reusable widget with minimum configuration to cover the feature. The point is if you think this widget could be interesting to add as an official C4R widget.

efernandezleon avatar Oct 06 '22 10:10 efernandezleon

+1 to this feature. Can you go further and define how the API will look like for this widget?

I will keep this very simple right now. You should need from the user:

  • A table
  • The geom column of the table
  • The column name to get the filter.

alasarr avatar Oct 22 '22 09:10 alasarr