Skip to content

Latest commit

 

History

History

tooltip

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

<< all controls

🏷️ @mapbox-controls/tooltip

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',
}));

Options

export type ControlOptions = {
    getContent: (event: import("mapbox-gl").MapMouseEvent) => string;
    layer?: string;
};