Demo
Markers, clusters, bubbles and routes
Documented in Map overlays and tiles.
Markers, clusters, bubbles and routes
Balloon markers that cluster until you zoom in, bubbles sized by a data field, a curved route with an arrow, a polygon overlay, an annotation, map-click coordinates and a planar seat map.
Route: Alpha to Delta
Cities, 9 shapes, 5 markers.
| Name | population |
|---|---|
| Northwest | 12 |
| North | 30 |
| Northeast | 8 |
| West | 45 |
| Central | 60 |
| East | 22 |
| Southwest | 5 |
| South | 18 |
| Southeast | 40 |
| Alpha | 55, -4 |
| Beta | 54.6, -3.2 |
| Gamma | 45, 6 |
| Delta | 36, 14 |
| Epsilon | 51, 12 |
Seats, 12 shapes.
| Name | Value |
|---|---|
| Seat A1 | |
| Seat A2 | |
| Seat A3 | |
| Seat A4 | |
| Seat A5 | |
| Seat A6 | |
| Seat B1 | |
| Seat B2 | |
| Seat B3 | |
| Seat B4 | |
| Seat B5 | |
| Seat B6 |
Demo.tsx
'use client';
import { useState } from 'react';
import { GeoMap } from '@salmonui/charts/geo-map';
import { CITIES, POPULATION, REGIONS, SEATS } from '../../lib/geo-fixture';
// Markers with clustering, bubbles, a route, a polygon and a planar seat map.
export default function GeoMapMarkersDemo() {
const [clicked, setClicked] = useState('');
return (
<div style={{ display: 'grid', gap: 12, maxInlineSize: 640 }}>
<GeoMap
title="Cities"
projection="winkelTripel"
zoom
layers={[
{
shapes: REGIONS,
data: POPULATION,
dataKey: 'region',
bubbles: { valueField: 'population', radius: [4, 22] },
getShapeStyle: (ctx) => (ctx.name === 'Central' ? { fill: '#c2410c' } : undefined),
markers: { data: CITIES, labelField: 'name', shape: 'balloon', size: 16, cluster: true },
routes: [{ points: [[55, -4], [45, 6], [36, 14]], curvature: 0.25, arrows: 'end', lineStyle: 'dashed' }],
polygons: [{ points: [[50, 10], [47, 16], [42, 12]], color: '#9c27b0', label: 'Zone' }],
},
]}
annotations={[{ x: '50%', y: 30, content: <em>Route: Alpha to Delta</em> }]}
tooltip
onMapClick={(p) => setClicked(`${p.latitude.toFixed(2)}, ${p.longitude.toFixed(2)}`)}
/>
<output>Clicked: {clicked || 'nothing yet'}</output>
<GeoMap title="Seats" width={420} height={210} selection={{ multiple: true }} layers={[{ shapes: SEATS, geometry: 'planar', labels: true }]} />
</div>
);
}
Click a cluster to zoom into it. Clicking anywhere reports the latitude and longitude under the pointer. The seat map uses planar geometry.