@shenyong/mapbox-gl-tooltip
v0.0.5
Published
Display tooltip on hover
Downloads
7
Readme
🏷️ @shenyong/mapbox-gl-tooltip
Control to display tooltip on hover. The content of the tooltip may depend on the data stored in the layer.
npm i @shenyong/mapbox-gl-tooltip
import TooltipControl from '@shenyong/mapbox-gl-tooltip';
import '@shenyong/mapbox-gl-tooltip/src/index.css';
map.addControl(new TooltipControl({
getContent: (event) => `${event.lngLat.lng.toFixed(6)}, ${event.lngLat.lat.toFixed(6)}`,
layer: 'some-layer-id',
}));
Options
export type TooltipControlOptions = {
getContent: (event: MapLayerMouseEvent) => string;
layer?: string | undefined;
};