Package org.vaadin.addons.maplibre
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 ClassesModifier and TypeClassDescriptionclassstatic interfaceclassstatic interfacestatic final record -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected LayeraddFillLayer(String name, String source, String sourceLayer, FillPaint paintJson, org.locationtech.jts.geom.Geometry geom) addFillLayer(org.locationtech.jts.geom.Geometry geom, FillPaint style) addFillLayer(org.locationtech.jts.geom.Polygon polygon, FillPaint style) addLineLayer(String name, String source, String sourceLayer, LinePaint paint) Adds a new layer only on the client sidedprotected LineLayeraddLineLayer(String name, String source, String sourceLayer, LinePaint paint, org.locationtech.jts.geom.Geometry geom) addLineLayer(org.locationtech.jts.geom.LineString geometry, LinePaint linePaint) voidaddMapClickListener(MapLibre.MapClickListener listener) addMarker(double x, double y) addMarker(org.locationtech.jts.geom.Point point) voidaddMoveEndListener(MapLibre.MoveEndListener listener) voidvoidfitBounds(org.locationtech.jts.geom.Geometry geometry) protected voidfitTo(org.locationtech.jts.geom.Envelope envelope, double padding) voidfitTo(org.locationtech.jts.geom.Geometry geom, double padding) voidvoidvoidflyTo(org.locationtech.jts.geom.Geometry geometry) voidflyTo(org.locationtech.jts.geom.Geometry geometry, double zoomLevel) org.locationtech.jts.geom.CoordinateDeprecated.Might contain outdated value, consider using getViewPort()protected org.apache.velocity.VelocityContextDetects current view port details.protected com.vaadin.flow.component.page.PendingJavaScriptResultprotected com.vaadin.flow.component.page.PendingJavaScriptResultExecutes given JS in the context of the map component, either right away, or right after initial loading is done.protected voidLoads the MapLibre JS library to the host page.protected voidonAttach(com.vaadin.flow.component.AttachEvent attachEvent) protected voidonDetach(com.vaadin.flow.component.DetachEvent detachEvent) voidvoidremoveLayer(Layer layer) voidsetCenter(double x, double y) voidsetCenter(org.locationtech.jts.geom.Coordinate coordinate) voidsetCenter(org.locationtech.jts.geom.Geometry geom) voidRemoves all current styles and layers and inits the map with given style URLvoidsetZoomLevel(double zoomLevel) Methods inherited from class org.vaadin.addons.velocitycomponent.AbstractVelocityJsComponent
jsTemplate, velocityJs, velocityJs, velocityJsMethods 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, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setVisibleMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListenerMethods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListenerMethods inherited from interface com.vaadin.flow.component.HasElement
getElementMethods 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, setWidthFullMethods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
-
Constructor Details
-
MapLibre
public MapLibre() -
MapLibre
-
MapLibre
-
MapLibre
-
-
Method Details
-
onAttach
protected void onAttach(com.vaadin.flow.component.AttachEvent attachEvent) - Overrides:
onAttachin classcom.vaadin.flow.component.Component
-
onDetach
protected void onDetach(com.vaadin.flow.component.DetachEvent detachEvent) - Overrides:
onDetachin classcom.vaadin.flow.component.Component
-
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
-
setZoomLevel
public void setZoomLevel(double zoomLevel) -
getCenter
Deprecated.Might contain outdated value, consider using getViewPort()Returns the defined center of this map. Note that user can most likely pan the map. Use getViewPort() method to detect the current value from the client side.- Returns:
- the last set center of this map.
-
setCenter
public void setCenter(org.locationtech.jts.geom.Coordinate coordinate) -
setCenter
public void setCenter(org.locationtech.jts.geom.Geometry geom) -
addLineLayer
-
addFillLayer
-
addFillLayer
-
addFillLayer
-
addLineLayer
Adds a new layer only on the client sided- Parameters:
name- the name of the new layersource- the source idsourceLayer- the source layerpaint- the paint for the features- Returns:
- Layer handle (e.g. to remove the layer)
-
addLineLayer
-
removeLayer
-
addSource
-
addMarker
-
addMarker
-
getVelocityContext
protected org.apache.velocity.VelocityContext getVelocityContext()- Overrides:
getVelocityContextin classorg.vaadin.addons.velocitycomponent.AbstractVelocityJsComponent
-
setCenter
public void setCenter(double x, double y) -
fitTo
public void fitTo(org.locationtech.jts.geom.Geometry geom, double padding) -
fitTo
protected void fitTo(org.locationtech.jts.geom.Envelope envelope, double padding) -
flyTo
-
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
-
flyTo
public void flyTo(org.locationtech.jts.geom.Geometry geometry, double zoomLevel) -
flyTo
public void flyTo(org.locationtech.jts.geom.Geometry geometry) -
addMapClickListener
-
fitBounds
public void fitBounds(org.locationtech.jts.geom.Geometry geometry) -
addMoveEndListener
-
getViewPort
Detects current view port details.- Returns:
- viewport details
-
fitToContent
public void fitToContent() -
removeAll
public void removeAll() -
setStyle
Removes all current styles and layers and inits the map with given style URL- Parameters:
styleUrl- the styleUrl
-