Zum Hauptinhalt springen
tsecurity.de LIVE
Echtzeit-Radar & Feeds
Alle RSS Feeds
👥 Community & Social
Windows Tipps & SecurityNighthawk M7 Pro im Test: Flexibler, aber teurer 5G-Router(21.09.2026 um 10:30 Uhr)
Sichere ProgrammierungNeue Gmail-Funktion: So sparst du jetzt Zeit bei Einmalcodes(21.09.2026 um 10:00 Uhr)
Sichere ProgrammierungYour GIF exporter is fine — the container is the problem(21.09.2026 um 10:01 Uhr)
Sichere ProgrammierungCSS, Motion, or GSAP? I Choose by Who Owns the Animation(21.09.2026 um 10:12 Uhr)
Windows Tipps & SecurityNighthawk M7 Pro im Test: Flexibler, aber teurer 5G-Router(21.09.2026 um 10:30 Uhr)
Sichere ProgrammierungNeue Gmail-Funktion: So sparst du jetzt Zeit bei Einmalcodes(21.09.2026 um 10:00 Uhr)
Sichere ProgrammierungYour GIF exporter is fine — the container is the problem(21.09.2026 um 10:01 Uhr)
Sichere ProgrammierungCSS, Motion, or GSAP? I Choose by Who Owns the Animation(21.09.2026 um 10:12 Uhr)
Intelligence View
⚡ tsecurity.de Intelligence

Adding a Hover Tooltip to a Polygon Layer in Mapbox GL JS

Hover tooltips are a great way to enhance the UX of your web maps. When the user moves their mouse across a region, district, delivery zone, or any other polygon, the map can talk back — instantly showing what the user is pointing a…

0
↗ Quelle (dev.to)
Reagiere als Erste:r — dein Feedback zählt!

Hover tooltips are a great way to enhance the UX of your web maps. When the user moves their mouse across a region, district, delivery zone, or any other polygon, the map can talk back — instantly showing what the user is pointing at.



Screen capture of hover tooltips on a polygon layer in a web map



At Mapbox, we just published an updated code example demonstrating this pattern, and it highlights one of the most common UX needs: a lightweight tooltip that follows the cursor and displays the properties of the polygon underneath. If you're designing thematic maps, dashboards, or interactive exploratory tools, this is a pattern worth adding to your toolkit.









Why this pattern matters



A hover-follow tooltip gives users:




  • Instant context without clicking

  • A smooth, responsive feel as users move the mouse across boundaries

  • A clean, focused UI (no permanent labels cluttering the map)

  • A natural interaction pattern for data-rich polygons



This approach uses a single popup that moves dynamically with the cursor, updating its content with the feature you're hovering.









Key Concepts (with snippet examples)






1. Create a single reusable popup



You don’t want a new popup on every movement — just one that updates.




const popup = new mapboxgl.Popup({
closeButton: false,
closeOnClick: false,
offset: [0, -20] // keeps tooltip above the cursor
});







  1. Update the popup position + content on mousemove
    The new example uses map.addInteraction to target a specific polygon layer and update the tooltip as the cursor moves across it.




map.addInteraction('hover-tooltip', {
type: 'mousemove',
target: { layerId: 'polygon-fills' },
handler: (e) => {
const label = e.feature.properties.name;

popup
.setLngLat(e.lngLat)
.setHTML(`<strong>${label}</strong>`)
.addTo(map);
}
});






This keeps the tooltip synced to the cursor while pulling feature properties on demand.




  1. Hide the tooltip on mouseleave
    A tiny interaction detail that keeps your UI clean:




map.on('mouseleave', 'polygon-fills', () => {
popup.remove();
});









See the full working example



These snippets illustrate the pattern, but the full example includes a real dataset, layer styling, and the complete interaction flow.






👉 Check out the latest Mapbox GL JS hover tooltip example:



https://docs.mapbox.com/mapbox-gl-js/example/hover-tooltip/



The example shows exactly how this pattern works in a realistic scenario — a polygon dataset that updates the tooltip in real time as you move the mouse pointer across the map.






Explore More UX Patterns



If you're building interactive maps—dashboards, analytics tools, administrative boundaries, or selection-based interfaces—you’ll find more great patterns across the Mapbox GL JS example gallery.






👉 Browse all Mapbox GL JS examples



https://docs.mapbox.com/mapbox-gl-js/examples/



These examples are excellent starting points for designing modern, intuitive map interactions to make your web maps sing!

Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Adding a Hover Tooltip to a Polygon Layer in Mapbox GL JS

Thematisch verwandte Begriffe: Adding, Hover, Tooltip, Polygon · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Zum Aktualisieren ziehen
ZERO-DAY CVE-2026-94030 | A security vulnerability has been detected in SerenityOS up to 3d83e4509…
Advisory →
TTS Reader • tsecurity.de Voice
tsecurity.de Icon
tsecurity.de App
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag
Themen-Radar & Intelligence Matrix
Echtzeit-Taxonomie nach Angriffsvektoren & Plattformen

tsecurity.de Live Threat Radar

🔴 LIVE RADAR
MONITORING
AKTIV
CVE-DATENBANK
LIVE
🔍
Community Radar & Live Chat
Sentinel Bot online • Live-Stream
Dein Cluster: Security Explorer
Match:
lädt…
Verbindung zum Community-Stream wird aufgebaut...
Bearbeitungsmodus — Senden überschreibt deine Nachricht
Community-Puls — was gerade passiert
lädt…
Aktivitäten deiner Analysten
lädt…
Neues Thema oder Eilmeldung einreichen

Reiche interessante Links, Zero-Days oder Debatten ein. Die Community entscheidet per Upvote über die Veröffentlichung.

Heiß diskutierte Einreichungen
🔖 Gespeicherte Artikel
📂 Keine gespeicherten Artikel vorhanden.
Zurück Ziehen Vor
Links: vorheriger Artikel Rechts: nächster Artikel unten: schließen
News NIS-2 Frühwarnung Tier-1 Intel ⏱️ 3 Min vor 10 Min
Artikeldaten werden geladen...

Zurück: vorheriger Vor: nächster
↗ Original-Quelle
Social Reaktionen Deine Reaktion zählt
Einstufung & Relevanz-Poll 0 Stimmen
In sozialen Netzwerken teilen 1-Klick