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

CARTO: Automatically add labels to line & polygon layers #9449

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

felixpalmer
Copy link
Collaborator

@felixpalmer felixpalmer commented Feb 19, 2025

Background

It is often desirable to add labels to line or polygon layers, but calculating the positioning is not trivial - especially if the data is being loaded tile by tile.

This PR add functionality to the VectorTileLayer to automatically add labels when the autoLabels prop is set.

Usage:

const vectorTileLayer = new VectorTileLayer({
  // Configure as normal
  data: <LINE or POLYGON data>,
  ...,
  // Add props for text rendering
  getText: f => f.properties.name
});
Screenshot 2025-02-19 at 15 17 29

Doc PR to follow

Change List

  • Added new utils file label-utils that calculates label positions
  • Tests for label-utils
  • Tidy types and rework common code

@coveralls
Copy link

coveralls commented Feb 19, 2025

Coverage Status

coverage: 91.574% (-0.03%) from 91.607%
when pulling 9fe06b4 on felix/carto-line-poly-labels
into 31132ef on master.

@felixpalmer felixpalmer changed the title WIP: CARTO: Automatically add labels to line & polygon layers CARTO: Automatically add labels to line & polygon layers Feb 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants