Class MapLibre

java.lang.Object
com.vaadin.flow.component.Component
org.vaadin.addons.velocitycomponent.AbstractVelocityJsComponent
org.vaadin.addons.maplibre.MapLibre
All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier, com.vaadin.flow.component.DetachNotifier, com.vaadin.flow.component.HasElement, com.vaadin.flow.component.HasSize, com.vaadin.flow.component.HasStyle, Serializable

@Tag("div") public class MapLibre extends org.vaadin.addons.velocitycomponent.AbstractVelocityJsComponent implements com.vaadin.flow.component.HasSize, com.vaadin.flow.component.HasStyle
A Java/Vaadin API for MapLibre GL JS.
See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    class 
     
    static interface 
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    MapLibre(InputStream styleJson)
     
    MapLibre(String styleUrl)
     
    MapLibre(URI styleUrl)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected Layer
    addFillLayer(String name, String source, String sourceLayer, FillPaint paintJson, org.locationtech.jts.geom.Geometry geom)
     
    addFillLayer(org.locationtech.jts.geom.Polygon polygon, FillPaint style)
     
    protected Layer
    addLineLayer(String name, String source, String sourceLayer, LinePaint paint, org.locationtech.jts.geom.Geometry geom)
     
    addLineLayer(org.locationtech.jts.geom.Geometry geometry, LinePaint linePaint)
     
    void
     
    addMarker(double x, double y)
     
    addMarker(org.locationtech.jts.geom.Point point)
     
    void
    addSource(String name, String sourceDeclarationJson)
     
    void
    fitBounds(org.locationtech.jts.geom.Geometry geometry)
     
    void
    fitTo(org.locationtech.jts.geom.Geometry geom, double padding)
     
    void
    flyTo(double x, double y, double zoom)
     
    void
    flyTo(org.locationtech.jts.geom.Geometry geometry, int i)
     
    org.locationtech.jts.geom.Coordinate
     
     
    protected org.apache.velocity.VelocityContext
     
     
    protected void
    init(String styleJson, String styleUrl)
     
    protected void
    js(String js)
     
    protected com.vaadin.flow.component.page.PendingJavaScriptResult
    js(String js, Map<String,Object> variables)
    Executes given JS in the context of the map component, either right away, or right after initial loading is done.
    protected void
    Loads the MapLibre JS library to the host page.
    void
     
    void
    setCenter(double x, double y)
     
    void
    setZoomLevel(int zoomLevel)
     

    Methods inherited from class org.vaadin.addons.velocitycomponent.AbstractVelocityJsComponent

    jsTemplate, velocityJs, velocityJs, velocityJs

    Methods inherited from class com.vaadin.flow.component.Component

    addListener, findAncestor, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getListeners, getLocale, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onAttach, onDetach, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setVisible

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface com.vaadin.flow.component.AttachNotifier

    addAttachListener

    Methods inherited from interface com.vaadin.flow.component.DetachNotifier

    addDetachListener

    Methods inherited from interface com.vaadin.flow.component.HasElement

    getElement

    Methods inherited from interface com.vaadin.flow.component.HasSize

    getHeight, getHeightUnit, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, getWidthUnit, setHeight, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFull

    Methods inherited from interface com.vaadin.flow.component.HasStyle

    addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
  • Constructor Details

    • MapLibre

      public MapLibre(URI styleUrl)
    • MapLibre

      public MapLibre(String styleUrl)
    • MapLibre

      public MapLibre(InputStream styleJson)
  • Method Details

    • init

      protected void init(String styleJson, String styleUrl)
    • loadMapLibreJs

      protected void loadMapLibreJs()
      Loads the MapLibre JS library to the host page. Not using @JavaScript annotation, as not all users necessarily want to use the unpkg.com CDN.

      Override if you want for example to load it from a local file instead of from unpkg.com.

    • getZoomLevel

      public Integer getZoomLevel()
    • setZoomLevel

      public void setZoomLevel(int zoomLevel)
    • getCenter

      public org.locationtech.jts.geom.Coordinate getCenter()
    • getMapStyle

      public String getMapStyle()
    • addLineLayer

      public Layer addLineLayer(org.locationtech.jts.geom.Geometry geometry, LinePaint linePaint)
    • addFillLayer

      public Layer addFillLayer(org.locationtech.jts.geom.Polygon polygon, FillPaint style)
    • addFillLayer

      protected Layer addFillLayer(String name, String source, String sourceLayer, FillPaint paintJson, org.locationtech.jts.geom.Geometry geom)
    • addLineLayer

      protected Layer addLineLayer(String name, String source, String sourceLayer, LinePaint paint, org.locationtech.jts.geom.Geometry geom)
    • removeLayer

      public void removeLayer(Layer layer)
    • addSource

      public void addSource(String name, String sourceDeclarationJson)
    • addMarker

      public Marker addMarker(org.locationtech.jts.geom.Point point)
    • addMarker

      public Marker addMarker(double x, double y)
    • getVelocityContext

      protected org.apache.velocity.VelocityContext getVelocityContext()
      Overrides:
      getVelocityContext in class org.vaadin.addons.velocitycomponent.AbstractVelocityJsComponent
    • setCenter

      public void setCenter(double x, double y)
    • fitTo

      public void fitTo(org.locationtech.jts.geom.Geometry geom, double padding)
    • flyTo

      public void flyTo(double x, double y, double zoom)
    • js

      protected com.vaadin.flow.component.page.PendingJavaScriptResult js(String js, Map<String,Object> variables)
      Executes given JS in the context of the map component, either right away, or right after initial loading is done.
      Parameters:
      js - the JS to execute, map and component variables are initialized automatically.
      Returns:
    • js

      protected void js(String js)
    • flyTo

      public void flyTo(org.locationtech.jts.geom.Geometry geometry, int i)
    • addMapClickListener

      public void addMapClickListener(MapLibre.MapClickListener listener)
    • fitBounds

      public void fitBounds(org.locationtech.jts.geom.Geometry geometry)