java.lang.Object
org.vaadin.addons.componentfactory.leaflet.types.Icon
org.vaadin.addons.componentfactory.leaflet.types.DivIcon
All Implemented Interfaces:
Serializable, BasicType

public class DivIcon extends Icon
Represents a lightweight icon for markers that uses a simple element instead of an image. Inherits from Icon but ignores the iconUrl and shadow options.

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

Usage example

 Marker marker = new Marker(new LatLng(47.1, 18.4));
 marker.setIcon(new DivIcon("my-div-icon"));
 marker.addTo(leafletMap);
 
Since:
2020-05-29
Version:
1.0
Author:
Gabor Kokeny Email: kokeny19@gmail.com
See Also:
  • Constructor Details

    • DivIcon

      public DivIcon()
      Creates a DivIcon using the default leaflet-div-icon CSS class.
    • DivIcon

      public DivIcon(String className)
      Creates a DivIcon using the given CSS class name.
      Parameters:
      className - the CSS class name to apply to the icon element
  • Method Details

    • getHtml

      public String getHtml()
      Returns the custom HTML code placed inside the div element.
      Returns:
      the custom HTML content, or null if none is set
    • setHtml

      public void setHtml(String html)
      Sets the custom HTML code to put inside the div element, empty by default. Alternatively, an instance of HTMLElement.
      Parameters:
      html - custom HTML code to put inside the div
    • getBgPos

      public Point getBgPos()
      Returns the relative position of the background, in pixels.
      Returns:
      the background position
    • setBgPos

      public void setBgPos(Point bgPos)
      Sets the Optional relative position of the background, in pixels
      Parameters:
      bgPos - the position of the background to be used