Class WLeafletMap
- java.lang.Object
-
- eu.webtoolkit.jwt.WObject
-
- eu.webtoolkit.jwt.WWidget
-
- eu.webtoolkit.jwt.WCompositeWidget
-
- eu.webtoolkit.jwt.WLeafletMap
-
public class WLeafletMap extends WCompositeWidget
A widget that displays a leaflet map.This is a simple wrapper around the Leaflet JavaScript library.
Leaflet itself does not provide maps. It is a JavaScript library that enables you to use any "tile server", like OpenStreetMap. If you just create a WLeafletMap (and give it a size), then you will be presented with an empty map. You can then add tile layers to the map using
addTileLayer().WLeafletMap is not exhaustive in its support for Leaflet features. It supports a subset out of the box. One of these features is markers, which come in two flavors: standard leaflet markers (
WLeafletMap.LeafletMarker) and widget markers (WLeafletMap.WidgetMarker). Using a widget marker, you can place arbitrary widgets on the map.If you need direct access to the leaflet map in your own custom JavaScript, you can use
getMapJsRef().Leaflet itself is not bundled with JWt. Use the
leafletJSURLandleafletCSSURLproperties to configure where the JavaScript and CSS of Leaflet should be loaded from.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classWLeafletMap.AbstractMapItemAn abstract map item.static classWLeafletMap.AbstractOverlayItemAn abstract map item with text.static classWLeafletMap.CoordinateA geographical coordinate (latitude/longitude)static classWLeafletMap.LeafletMarkerA standard leaflet marker.static classWLeafletMap.MarkerAn abstract marker.static classWLeafletMap.PopupA popup that can be added to theWLeafletMap.static classWLeafletMap.TooltipAWLeafletMap.Tooltipthat can be added to theWLeafletMap.static classWLeafletMap.WidgetMarkerA marker rendered with a widget.-
Nested classes/interfaces inherited from class eu.webtoolkit.jwt.WObject
WObject.FormData
-
-
Field Summary
-
Fields inherited from class eu.webtoolkit.jwt.WWidget
WT_GETEXTRAMS_JS
-
-
Constructor Summary
Constructors Constructor Description WLeafletMap()Create a newWLeafletMap.WLeafletMap(com.google.gson.JsonObject options)Create a newWLeafletMapwith the given options.WLeafletMap(com.google.gson.JsonObject options, WContainerWidget parentContainer)Create a newWLeafletMapwith the given options.WLeafletMap(WContainerWidget parentContainer)Create a newWLeafletMap.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddCircle(WLeafletMap.Coordinate center, double radius, WPen stroke, WBrush fill)Add a circle.voidaddMarker(WLeafletMap.Marker marker)Add the given marker.voidaddPolyline(java.util.List<WLeafletMap.Coordinate> points, WPen pen)Add a polyline.voidaddPopup(WLeafletMap.Popup popup)Add the given popup.voidaddTileLayer(java.lang.String urlTemplate, com.google.gson.JsonObject options)Add a new tile layer.voidaddTooltip(WLeafletMap.Tooltip tooltip)Add the given tooltip.java.lang.StringgetMapJsRef()Returns a JavaScript expression to the Leaflet map object.WLeafletMap.CoordinategetPosition()Get the current position.intgetZoomLevel()Get the current zoom level.JSignal2<java.lang.Double,java.lang.Double>panChanged()Signalemitted when the user has panned the map.voidpanTo(WLeafletMap.Coordinate center)Pan to the given coordinate.voidremove()Destructor.WLeafletMap.MarkerremoveMarker(WLeafletMap.Marker marker)Remove the given marker.WLeafletMap.PopupremovePopup(WLeafletMap.Popup popup)Remove the given popup.WLeafletMap.TooltipremoveTooltip(WLeafletMap.Tooltip tooltip)Remove the given tooltip.protected voidrender(java.util.EnumSet<RenderFlag> flags)Renders the widget.voidsetOptions(com.google.gson.JsonObject options)Change the options of the WLeafletMap.voidsetZoomLevel(int level)Set the current zoom level.JSignal1<java.lang.Integer>zoomLevelChanged()Signalemitted when the user has changed the zoom level of the map.-
Methods inherited from class eu.webtoolkit.jwt.WCompositeWidget
addStyleClass, boxBorder, boxPadding, callJavaScriptMember, doJavaScript, enableAjax, find, findById, getAttributeValue, getBaseZIndex, getChildren, getClearSides, getDecorationStyle, getFloatSide, getHeight, getId, getImplementation, getJavaScriptMember, getLineHeight, getMargin, getMaximumHeight, getMaximumWidth, getMinimumHeight, getMinimumWidth, getObjectName, getOffset, getPositionScheme, getScrollVisibilityMargin, getStyleClass, getTabIndex, getTakeImplementation, getToolTip, getVerticalAlignment, getVerticalAlignmentLength, getWidth, hasFocus, hasStyleClass, isCanReceiveFocus, isDisabled, isEnabled, isHidden, isHiddenKeepsGeometry, isInline, isLoaded, isPopup, isScrollVisibilityEnabled, isScrollVisible, isSetFirstFocus, isThemeStyleEnabled, isVisible, load, propagateSetEnabled, propagateSetVisible, refresh, removeStyleClass, removeWidget, resize, scrollVisibilityChanged, setAttributeValue, setCanReceiveFocus, setClearSides, setDecorationStyle, setDeferredToolTip, setDisabled, setFloatSide, setFocus, setHidden, setHiddenKeepsGeometry, setId, setImplementation, setInline, setJavaScriptMember, setLineHeight, setMargin, setMaximumSize, setMinimumSize, setObjectName, setOffsets, setParentWidget, setPopup, setPositionScheme, setScrollVisibilityEnabled, setScrollVisibilityMargin, setSelectable, setStyleClass, setTabIndex, setThemeStyleEnabled, setToolTip, setVerticalAlignment
-
Methods inherited from class eu.webtoolkit.jwt.WWidget
acceptDrops, acceptDrops, addCssRule, addCssRule, addJSignal, addStyleClass, animateHide, animateShow, applyThemeStyles, createJavaScript, disable, dropEvent, enable, getDropTouch, getJsRef, getParent, hide, htmlText, isExposed, isGlobalWidget, isLayoutSizeAware, isRendered, layoutSizeChanged, needsRerender, positionAt, positionAt, positionAt, positionAt, removeFromParent, removeStyleClass, render, resize, scheduleRender, scheduleRender, scheduleRender, scheduleThemeStyleApply, setClearSides, setDeferredToolTip, setFocus, setHeight, setHidden, setLayoutSizeAware, setMargin, setMargin, setMargin, setMargin, setMargin, setOffsets, setOffsets, setOffsets, setOffsets, setOffsets, setToolTip, setVerticalAlignment, setWidth, show, stopAcceptDrops, toggleStyleClass, toggleStyleClass, tr
-
Methods inherited from class eu.webtoolkit.jwt.WObject
setFormData
-
-
-
-
Constructor Detail
-
WLeafletMap
public WLeafletMap(WContainerWidget parentContainer)
Create a newWLeafletMap.
-
WLeafletMap
public WLeafletMap()
Create a newWLeafletMap.
-
WLeafletMap
public WLeafletMap(com.google.gson.JsonObject options, WContainerWidget parentContainer)Create a newWLeafletMapwith the given options.
-
WLeafletMap
public WLeafletMap(com.google.gson.JsonObject options)
Create a newWLeafletMapwith the given options.
-
-
Method Detail
-
remove
public void remove()
Description copied from class:WWidgetDestructor.Deletes a widget and all contained contents.
- Overrides:
removein classWCompositeWidget- See Also:
WWidget.removeWidget(WWidget widget)
-
setOptions
public void setOptions(com.google.gson.JsonObject options)
Change the options of the WLeafletMap.Note: This fully rerenders the map, because it creates a new Leaflet map, so any custom JavaScript modifying the map with e.g.
WCompositeWidget#doJavaScript()is undone, much like reloading the page whenreload-is-new-sessionis set to false. See https://leafletjs.com/reference.html#map for a list of options.
-
addTileLayer
public void addTileLayer(java.lang.String urlTemplate, com.google.gson.JsonObject options)Add a new tile layer.
-
addPopup
public void addPopup(WLeafletMap.Popup popup)
Add the given popup.
-
removePopup
public WLeafletMap.Popup removePopup(WLeafletMap.Popup popup)
Remove the given popup.
-
addTooltip
public void addTooltip(WLeafletMap.Tooltip tooltip)
Add the given tooltip.
-
removeTooltip
public WLeafletMap.Tooltip removeTooltip(WLeafletMap.Tooltip tooltip)
Remove the given tooltip.
-
addMarker
public void addMarker(WLeafletMap.Marker marker)
Add the given marker.
-
removeMarker
public WLeafletMap.Marker removeMarker(WLeafletMap.Marker marker)
Remove the given marker.
-
addPolyline
public void addPolyline(java.util.List<WLeafletMap.Coordinate> points, WPen pen)
Add a polyline.This will draw a polyline on the map going through the given list of coordinates, with the given pen.
-
addCircle
public void addCircle(WLeafletMap.Coordinate center, double radius, WPen stroke, WBrush fill)
Add a circle.This will draw a circle on the map centered at
center, with the givenradius(in meters), drawn with the givenstrokeandfill.
-
setZoomLevel
public void setZoomLevel(int level)
Set the current zoom level.
-
getZoomLevel
public int getZoomLevel()
Get the current zoom level.
-
panTo
public void panTo(WLeafletMap.Coordinate center)
Pan to the given coordinate.
-
getPosition
public WLeafletMap.Coordinate getPosition()
Get the current position.
-
zoomLevelChanged
public JSignal1<java.lang.Integer> zoomLevelChanged()
Signalemitted when the user has changed the zoom level of the map.
-
panChanged
public JSignal2<java.lang.Double,java.lang.Double> panChanged()
Signalemitted when the user has panned the map.
-
getMapJsRef
public java.lang.String getMapJsRef()
Returns a JavaScript expression to the Leaflet map object.You may want to use this in conjunction with
JSlotorWCompositeWidget#doJavaScript()in custom JavaScript code, e.g. to access features not built-in to WLeafletMap.
-
render
protected void render(java.util.EnumSet<RenderFlag> flags)
Description copied from class:WWidgetRenders the widget.This function renders the widget (or an update for the widget), after this has been scheduled using
scheduleRender().The default implementation will render the widget by serializing changes to JavaScript and HTML. You may want to reimplement this widget if you have been postponing some of the layout / rendering implementation until the latest moment possible. In that case you should make sure you call the base implementation however.
- Overrides:
renderin classWCompositeWidget
-
-