mapbox / mapbox/mapbox-gl-js

Show/hide labels based on overlap with external elements

Open
#9,249 3 comments 1 reaction 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 a map in a webapp (mapbox gl js, vue js) with a filter/legend over it. This filter/legend has a transparent background: this is a design decision. Generally this is fine, but sometimes the filter/legend obviously overlaps labels on the map. It would be nice if there was a way to detect whether there is a shape on the map and to hide labels in that area.

If there is already some way to manage this, I would be grateful if someone could tell me how.

images:

Works great
![Screen Shot 2020-01-31 at 1 58 56 PM](https://user-images.githubusercontent.com/30444613/73541100-e2f4c600-4431-11ea-9b68-36673fb15257.png)

Not that great (overlap with text)
![Screen Shot 2020-01-31 at 1 59 00 PM](https://user-images.githubusercontent.com/30444613/73541115-eab46a80-4431-11ea-9916-ed11e9288a39.png)

### Implementation
Showing/hiding labels could work many different ways: it would also be fine if I could tell mapbox, for Pixels in this range, don't show labels. Or for labels inside this geojson shape. Or in these bounds. I just want to shut off labels in one specific area of the map.

Thanks!

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 source files, tests, or entry points. Start by reproducing the transparent filter or legend overlapping map labels in a Mapbox GL JS and Vue JS app, then define whether pixel ranges, GeoJSON shapes, or bounds should control label visibility; done means labels can be suppressed reliably in one specified area.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.