Skip to content

DivIcon

Represents a lightweight icon for markers that uses a simple <div> element instead of an image. Inherits from Icon but ignores the iconUrl and shadow options.

Usage example

js
const myIcon = new DivIcon({className: 'my-div-icon'});

new Marker([50.505, 30.57], {icon: myIcon}).addTo(map);

By default, it has a 'leaflet-div-icon' CSS class and is styled as a little white square with a shadow.

Options

OptionTypeDefaultDescription
html`StringHTMLElement`''
bgPosPoint[0,Optional relative position of the background, in pixels