mapbox / mapbox/mapbox-gl-js

Feature: Within Expression for Polygon & Polygon Centroid

Open
#9,795 11 comments 6 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

Would be nice to style or filter all polygons which are inside a specific polygon.
Within means the polygon is full inside of the other. But for a polygon selection it looks like more correct when only the centroid of the polygon is within the other.

So it would be nice not only to use within with a polygon but also with it centroid.

Otherwise if the calculation of centroid is to heavy, it would be nice to precalculate the centroid, load it into the mbtile as property and then use it for the within. This means using the within with properties.

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

Start by tracing how the existing within expression handles polygon geometry and how style or filter expressions are evaluated. Define the intended centroid semantics, including whether centroids are calculated dynamically or supplied as properties. Done means the chosen behavior is implemented and covered by tests, but the issue does not name files or tests to begin with.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend, web-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.