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

[Feature Request]: Provide symbol options for point_data layers #1358

Open
wadhwamatic opened this issue Oct 7, 2024 · 3 comments
Open

[Feature Request]: Provide symbol options for point_data layers #1358

wadhwamatic opened this issue Oct 7, 2024 · 3 comments
Assignees
Labels
enhancement New feature or request triage to be triaged for next action

Comments

@wadhwamatic
Copy link
Member

wadhwamatic commented Oct 7, 2024

Provide a clear and concise description of what you want to happen.

Currently, point_data layers in PRISM are shown as circles, with the exception of RBD's crop change data where have applied a hex_display parameter as true. When more than one point_data layer is shown, using a single symbol makes it impossible to differentiate the layers if they use similar legends.

We should add the ability to choose a symbol for point_data layers and allow an icon to be included in the image folder as a source. It's also worth considering creating a few icons in a shared location that any PRISM deployment could make use of.

MapLibre symbol specification for reference: https://maplibre.org/maplibre-style-spec/layers/#symbol

Is there anything else you can add about the proposal? You might want to link to related issues here, if you haven't already.

This example from Cambodia showing Google Floods plus EWS-1294 river levels side by side illustrates why we need the ability apply different symbols for a layer. The circles on the map come from a combination of both layers.

Screenshot 2024-10-07 at 16 34 24
@wadhwamatic wadhwamatic added enhancement New feature or request triage to be triaged for next action labels Oct 7, 2024
@wadhwamatic wadhwamatic self-assigned this Oct 7, 2024
@wadhwamatic
Copy link
Member Author

@gislawill @ericboucher - interested to hear your thoughts on this suggested feature.

@gislawill
Copy link
Collaborator

Good catch, @wadhwamatic. Adding custom symbols for layers should be pretty straightforward — I've included a snippet we should be able to use in our PointDataLayer component.

We should also consider supporting an icon library like Iconify to build in more flexibility. This would allow us to use any icon in their library rather than needing to upload and bundle a new image file for new icon.

const MapComponent = () => {
  const mapRef = useRef();

  useEffect(() => {
    const map = mapRef.current?.getMap();
    
    if (map) {
      map.loadImage('/path/to/custom-icon.png', (error, image) => {
        if (error) throw error;
        if (!map.hasImage('custom-icon')) {
          map.addImage('custom-icon', image);
        }
      });
    }
  }, [mapLoaded]);

  const layerStyle = {
    id: 'points',
    type: 'symbol',
    source: 'my-data',
    layout: {
      'icon-image': 'custom-icon',
      'icon-size': 0.5, 
      'icon-anchor': 'bottom',
    },
  };

  return (
    <Map>
      <Source id="my-data" type="geojson" data={geojsonData}>
        <Layer {...layerStyle} />
      </Source>
    </Map>
  );
};

@wadhwamatic
Copy link
Member Author

Great, thanks @gislawill! And good recommendation to use an existing icon library. We already include Material icons FYI

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request triage to be triaged for next action
Projects
None yet
Development

No branches or pull requests

2 participants