diff --git a/.changeset/map-look.md b/.changeset/map-look.md
new file mode 100644
index 000000000..70fc902e8
--- /dev/null
+++ b/.changeset/map-look.md
@@ -0,0 +1,7 @@
+---
+"@tabler/core": minor
+"@tabler/preview": minor
+"@tabler/docs": patch
+---
+
+Updated the map look: gray basemap, dot markers, popups with no arrow, `.map-tooltip`, `.map-marker-label`, and a 3D globe demo.
diff --git a/core/scss/_variables.scss b/core/scss/_variables.scss
index d078ece95..03d0e2b8a 100644
--- a/core/scss/_variables.scss
+++ b/core/scss/_variables.scss
@@ -1281,7 +1281,7 @@ $ribbon-bookmark-notch-width: 0.5rem !default;
// scss-docs-start map-marker-variables
$map-marker-size: 1.75rem !default;
-$map-marker-dot-size: 0.875rem !default;
+$map-marker-dot-size: 1rem !default;
$map-marker-bg: var(--primary) !default;
$map-marker-color: var(--primary-fg) !default;
$map-marker-border-width: 2px !default;
diff --git a/core/scss/tests/__snapshots__/css-var-prefix.test.mjs.snap b/core/scss/tests/__snapshots__/css-var-prefix.test.mjs.snap
index 92074577e..c9f4a6477 100644
--- a/core/scss/tests/__snapshots__/css-var-prefix.test.mjs.snap
+++ b/core/scss/tests/__snapshots__/css-var-prefix.test.mjs.snap
@@ -52,6 +52,7 @@ exports[`css custom-property prefixing > leaves vendor-owned names alone and pre
"--tblr-border-color-translucent",
"--tblr-border-radius",
"--tblr-border-radius-pill",
+ "--tblr-border-radius-sm",
"--tblr-border-style",
"--tblr-border-width",
"--tblr-card-bg",
diff --git a/core/scss/vendor/_maplibre.scss b/core/scss/vendor/_maplibre.scss
index bb7df8d60..600249ccd 100644
--- a/core/scss/vendor/_maplibre.scss
+++ b/core/scss/vendor/_maplibre.scss
@@ -65,9 +65,9 @@
border-color: var(--body-color);
}
-// Popup
-.maplibregl-popup-content {
- padding: 0.75rem 1rem;
+// Popup: a small bordered panel with no arrow
+.maplibregl-popup .maplibregl-popup-content {
+ padding: 0.75rem;
color: var(--body-color);
background: var(--bg-surface);
box-shadow:
@@ -76,21 +76,25 @@
@include border-radius(var(--border-radius));
}
+.maplibregl-popup-tip {
+ display: none;
+}
+
// Room for the close button, which MapLibre pins to the right edge in both directions
-.maplibregl-popup-content:has(.maplibregl-popup-close-button) {
+.maplibregl-popup .maplibregl-popup-content:has(.maplibregl-popup-close-button) {
/* rtl:ignore */
- padding-right: 2.25rem;
+ padding-right: 2rem;
}
.maplibregl-popup-close-button {
- width: 1.5rem;
- height: 1.5rem;
+ width: 1.25rem;
+ height: 1.25rem;
padding: 0;
- margin: 0.375rem;
+ margin: 0.25rem;
font-size: 1rem;
line-height: 1;
color: var(--secondary);
- @include border-radius(var(--border-radius));
+ @include border-radius(var(--border-radius-sm));
&:hover {
color: var(--body-color);
@@ -98,32 +102,17 @@
}
}
-.maplibregl-popup-anchor-top,
-.maplibregl-popup-anchor-top-left,
-.maplibregl-popup-anchor-top-right {
- .maplibregl-popup-tip {
- border-bottom-color: var(--bg-surface);
- }
-}
-
-.maplibregl-popup-anchor-bottom,
-.maplibregl-popup-anchor-bottom-left,
-.maplibregl-popup-anchor-bottom-right {
- .maplibregl-popup-tip {
- border-top-color: var(--bg-surface);
- }
-}
-
-.maplibregl-popup-anchor-left .maplibregl-popup-tip {
- border-right-color: var(--bg-surface);
-}
-
-.maplibregl-popup-anchor-right .maplibregl-popup-tip {
- border-left-color: var(--bg-surface);
+// Popup used as a tooltip: a short inverted label, shown on hover
+.map-tooltip .maplibregl-popup-content {
+ padding: 0.25rem 0.5rem;
+ color: var(--text-inverted);
+ pointer-events: none;
+ background: var(--bg-surface-inverted);
+ box-shadow: #{$box-shadow-md};
}
// Popup that holds a card-like block: an image on top, padded content below
-.map-popup-card {
+.map-popup-card.maplibregl-popup {
.maplibregl-popup-content {
width: #{$map-popup-card-width};
padding: 0;
@@ -161,7 +150,6 @@
line-height: 1;
color: var(--map-marker-color);
cursor: pointer;
- filter: #{$map-marker-shadow};
&::before {
position: absolute;
@@ -169,6 +157,7 @@
z-index: -1;
content: '';
background: var(--map-marker-bg);
+ filter: #{$map-marker-shadow};
border: var(--map-marker-border-width) solid var(--map-marker-border-color);
@include border-radius(var(--border-radius-pill));
}
@@ -187,6 +176,24 @@
--map-marker-size: #{$map-marker-dot-size};
}
+// Short text under a marker
+.map-marker-label {
+ position: absolute;
+ top: 100%;
+ left: 50%;
+ margin-top: 0.125rem;
+ font-size: $h6-font-size;
+ font-weight: var(--font-weight-medium);
+ line-height: 1.2;
+ color: var(--body-color);
+ text-shadow:
+ 0 0 2px var(--bg-surface),
+ 0 0 2px var(--bg-surface),
+ 0 0 4px var(--bg-surface);
+ white-space: nowrap;
+ transform: translateX(-50%);
+}
+
// Teardrop: a square with one sharp corner, turned to point down. Its tip
// reaches 20.7% below the circle, so the root is that much taller.
.map-marker-pin {
diff --git a/docs/content/ui/components/map.mdx b/docs/content/ui/components/map.mdx
index d4ba7294c..e9ee709cd 100644
--- a/docs/content/ui/components/map.mdx
+++ b/docs/content/ui/components/map.mdx
@@ -12,6 +12,9 @@ classnames:
desc: Wrapper that keeps the map at a fixed aspect ratio
- class: map-marker
desc: Marker drawn in HTML, a circle that can hold an icon, a count or an avatar
+ part:
+ - class: map-marker-label
+ desc: Short text under a marker
modifier:
- class: map-marker-dot
desc: Small dot with no content
@@ -19,6 +22,8 @@ classnames:
desc: Teardrop pin that points down, used with the bottom anchor
- class: map-popup-card
desc: Popup with no padding and a fixed width, for an image above the text
+ - class: map-tooltip
+ desc: Popup shown as a small dark label, for text on hover
color:
- class: map-marker-{color}
desc: Any theme color, for example map-marker-red or map-marker-green
@@ -83,7 +88,7 @@ Create the map after the DOM is ready. Pass the id of your container, a style, a
document.addEventListener('DOMContentLoaded', function () {
const map = new maplibregl.Map({
container: 'map-simple',
- style: 'https://tiles.openfreemap.org/styles/liberty',
+ style: 'https://tiles.openfreemap.org/styles/positron',
zoom: 13,
center: [13.4049, 52.518827],
})
@@ -102,10 +107,10 @@ Set `style` to the URL of any MapLibre style. OpenFreeMap has five of them:
| Style | Result |
| --- | --- |
-| `https://tiles.openfreemap.org/styles/liberty` | Default street map. |
+| `https://tiles.openfreemap.org/styles/positron` | Light gray map, used by the Tabler demos. Markers and data stand out on it. |
+| `https://tiles.openfreemap.org/styles/dark` | Dark gray map, used by the demos in dark mode. |
+| `https://tiles.openfreemap.org/styles/liberty` | Street map in color. |
| `https://tiles.openfreemap.org/styles/bright` | Street map with stronger colors. |
-| `https://tiles.openfreemap.org/styles/positron` | Light gray map, good under charts and markers. |
-| `https://tiles.openfreemap.org/styles/dark` | Dark map. |
| `https://tiles.openfreemap.org/styles/fiord` | Dark blue map. |
@@ -116,7 +121,7 @@ Styles from other providers work the same way, as long as they follow the MapLib
### Markers
-Add a marker for each place. `setLngLat` takes the same longitude and latitude order as `center`.
+Add a marker for each place. `setLngLat` takes the same longitude and latitude order as `center`. The demos use a small dot, drawn with the `.map-marker` and `.map-marker-dot` classes.
```js
const cities = [
@@ -126,7 +131,10 @@ const cities = [
]
cities.forEach(function (coords) {
- new maplibregl.Marker({ color: 'var(--tblr-primary)' }).setLngLat(coords).addTo(map)
+ const element = document.createElement('span')
+ element.className = 'map-marker map-marker-dot'
+
+ new maplibregl.Marker({ element: element }).setLngLat(coords).addTo(map)
})
```
@@ -134,7 +142,7 @@ cities.forEach(function (coords) {
-The `color` option is written to the `fill` attribute of the marker icon. A CSS variable works there, so `var(--tblr-primary)` keeps the markers in your theme color, including after a theme change.
+Without `element`, MapLibre draws its own pin. Its `color` option accepts a CSS variable, for example `var(--tblr-primary)`.
### Custom markers
@@ -148,6 +156,8 @@ element.textContent = '12'
new maplibregl.Marker({ element: element }).setLngLat([13.35, 52.512]).addTo(map)
```
+Put a `.map-marker-label` element inside the marker for a short text under it.
+
Add `.map-marker-dot` for a small dot, or `.map-marker-pin` for a pin that points down. A pin needs `anchor: 'bottom'`, so its tip sits on the place. Change the color with `.map-marker-{color}`.
```js
@@ -161,7 +171,7 @@ new maplibregl.Marker({ element: pin, anchor: 'bottom' }).setLngLat([13.47, 52.5