mapbox / mapbox/mapbox-gl-js

Dynamically set filtering based on another layer

Open
#12,052 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature :green_apple:
Dominant language
TypeScript
Stars
12.4k
Forks
2.4k
PR merge metrics
No merged PRs in 30d

Description

## Motivation
I have two layers, one is the polygons with yellow outlines and the other one is the purple dots. I want to highlight the yellow outlined polygons by filling them blue when there's one or multiple purple dots on them, but I couldn't find a good way to do so.
![Screen Shot 2022-06-29 at 1 09 01 PM](https://user-images.githubusercontent.com/17789117/176495678-ecf998f6-07d2-4840-84d1-a17c127c4b77.png)

## Design Alternatives

The closest thing I could find is "within" (https://docs.mapbox.com/mapbox-gl-js/style-spec/expressions/#within) that I can use in expressions, but it only returns true when the features is **fully** contained inside the input geometry.

## Design

I would suggest adding another expression called "touch", which is similar to "within", but instead of only "returns true if the evaluated feature is fully contained inside a boundary of the input geometry", we can make it "returns true if the evaluated feature touches the boundary of the input geometry"

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no implementation files or tests. Start by reviewing the style-spec documentation for the existing `within` expression and how filtering is evaluated across layers, then clarify the intended boundary-intersection semantics. Done means the expression behavior is agreed and can identify polygon features touched by points from another layer.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.