Control to display tooltip on hover. The content of the tooltip may depend on the data stored in the layer.
npm i @mapbox-controls/tooltip
import TooltipControl from '@mapbox-controls/tooltip';
import '@mapbox-controls/tooltip/src/index.css';
map.addControl(new TooltipControl({
getContent: (event) => `${event.lngLat.lng.toFixed(6)}, ${event.lngLat.lat.toFixed(6)}`,
layer: 'some-layer-id',
}));
export type ControlOptions = {
getContent: (event: import("mapbox-gl").MapMouseEvent) => string;
layer?: string;
};