Class WGoogleMap
This widget uses the online Google Maps server to display a map. It exposes a part of the google maps API.
This widget supports both version 2 and version 3 of the Google Maps API. The version 2 API is used by default, to enable the version 3 API, use the constructor's version argument.
To use the map on a public server you will need to obtain a key. The widget will look for this
key as the configuration property "google_api_key"
. If this configuration
property has not been set, it will use a key that is suitable for localhost.
CSS
Styling through CSS is not applicable.
Contributed by: Richard Ulrich.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
A geographical coordinate (latitude/longitude)Nested classes/interfaces inherited from class eu.webtoolkit.jwt.WObject
WObject.FormData
-
Constructor Summary
ConstructorDescriptionCreates a map widget with a version.WGoogleMap
(GoogleMapsVersion version) Creates a map widget with a version.WGoogleMap
(GoogleMapsVersion version, WContainerWidget parentContainer) Creates a map widget with a version. -
Method Summary
Modifier and TypeMethodDescriptionfinal void
addCircle
(WGoogleMap.Coordinate center, double radius, WColor strokeColor, int strokeWidth) Adds a circle to the map.void
addCircle
(WGoogleMap.Coordinate center, double radius, WColor strokeColor, int strokeWidth, WColor fillColor) Adds a circle to the map.void
addIconMarker
(WGoogleMap.Coordinate pos, String iconURL) Adds a icon marker overlay to the map.void
Adds a marker overlay to the map.final void
addPolyline
(List<WGoogleMap.Coordinate> points) Adds a polyline overlay to the map.final void
addPolyline
(List<WGoogleMap.Coordinate> points, WColor color) Adds a polyline overlay to the map.final void
addPolyline
(List<WGoogleMap.Coordinate> points, WColor color, int width) Adds a polyline overlay to the map.void
addPolyline
(List<WGoogleMap.Coordinate> points, WColor color, int width, double opacity) Adds a polyline overlay to the map.void
Removes all overlays from the map.clicked()
The click event.void
Disables double click to zoom in and out.void
Disables the dragging of the map.void
Disables the GoogleBar integrated search control.void
Disables zooming using a mouse's scroll wheel.protected void
doGmJavaScript
(String jscode) Execute a piece of JavaScript that manipulates the map.The double click event.void
Enables double click to zoom in and out (enabled by default).void
Enables the dragging of the map (enabled by default).void
Enables the GoogleBar, an integrated search control, on the map.void
Enables zooming using a mouse's scroll wheel.Return the used Google Maps API version.This event is fired when the user moves the mouse inside the map.void
openInfoWindow
(WGoogleMap.Coordinate pos, CharSequence myHtml) Opens a text bubble with html text at a specific location.void
panTo
(WGoogleMap.Coordinate center) Changes the center point of the map to the given point.void
remove()
Destructor.protected void
render
(EnumSet<RenderFlag> flags) Renders the widget.void
Restores the map view that was saved bysavePosition()
.void
Stores the current map position and zoom level.void
setCenter
(WGoogleMap.Coordinate center) Sets the map view to the given center.void
setCenter
(WGoogleMap.Coordinate center, int zoom) Sets the map view to the given center and zoom level.void
Sets the map type control.void
setZoom
(int level) Sets the zoom level to the given new value.void
zoomIn()
Increments zoom level by one.void
zoomOut()
Decrements zoom level by one.void
zoomWindow
(WGoogleMap.Coordinate topLeft, WGoogleMap.Coordinate rightBottom) Zooms the map to a region defined by a bounding box.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, 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, createJavaScript, disable, dropEvent, enable, getDropTouch, getJsRef, getParent, hide, htmlText, isExposed, isGlobalWidget, isLayoutSizeAware, isRendered, layoutSizeChanged, needsRerender, positionAt, positionAt, removeFromParent, removeStyleClass, render, resize, scheduleRender, scheduleRender, scheduleRender, 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 Details
-
WGoogleMap
Creates a map widget with a version. -
WGoogleMap
public WGoogleMap()Creates a map widget with a version. -
WGoogleMap
Creates a map widget with a version.
-
-
Method Details
-
remove
public void remove()Destructor.- Overrides:
remove
in classWCompositeWidget
- See Also:
-
addMarker
Adds a marker overlay to the map. -
addPolyline
public void addPolyline(List<WGoogleMap.Coordinate> points, WColor color, int width, double opacity) Adds a polyline overlay to the map.Specify a value between 0.0 and 1.0 for the opacity or set the alpha value in the color.
-
addPolyline
Adds a polyline overlay to the map.Calls
addPolyline(points, new WColor(StandardColor.Red), 2, 1.0)
-
addPolyline
Adds a polyline overlay to the map. -
addPolyline
Adds a polyline overlay to the map. -
addCircle
public void addCircle(WGoogleMap.Coordinate center, double radius, WColor strokeColor, int strokeWidth, WColor fillColor) Adds a circle to the map.The stroke and fill opacity can be configured respectively in the strokeColor and fillColor. This feature is only supported by the Google Maps API version 3.
-
addCircle
public final void addCircle(WGoogleMap.Coordinate center, double radius, WColor strokeColor, int strokeWidth) Adds a circle to the map.Calls
addCircle(center, radius, strokeColor, strokeWidth, new WColor())
-
addIconMarker
Adds a icon marker overlay to the map. -
clearOverlays
public void clearOverlays()Removes all overlays from the map. -
openInfoWindow
Opens a text bubble with html text at a specific location. -
setCenter
Sets the map view to the given center. -
setCenter
Sets the map view to the given center and zoom level. -
panTo
Changes the center point of the map to the given point.If the point is already visible in the current map view, change the center in a smooth animation.
-
zoomWindow
Zooms the map to a region defined by a bounding box. -
setZoom
public void setZoom(int level) Sets the zoom level to the given new value. -
zoomIn
public void zoomIn()Increments zoom level by one. -
zoomOut
public void zoomOut()Decrements zoom level by one. -
savePosition
public void savePosition()Stores the current map position and zoom level.You can later restore this position using
returnToSavedPosition()
. -
returnToSavedPosition
public void returnToSavedPosition()Restores the map view that was saved bysavePosition()
. -
enableDragging
public void enableDragging()Enables the dragging of the map (enabled by default). -
disableDragging
public void disableDragging()Disables the dragging of the map. -
enableDoubleClickZoom
public void enableDoubleClickZoom()Enables double click to zoom in and out (enabled by default). -
disableDoubleClickZoom
public void disableDoubleClickZoom()Disables double click to zoom in and out. -
enableGoogleBar
public void enableGoogleBar()Enables the GoogleBar, an integrated search control, on the map.When enabled, this control takes the place of the default Powered By Google logo.
This control is initially disabled.
Note: This functionality is no longer available in the Google Maps API v3.
-
disableGoogleBar
public void disableGoogleBar()Disables the GoogleBar integrated search control.When disabled, the default Powered by Google logo occupies the position formerly containing this control. Note that this control is already disabled by default.
Note: This functionality is no longer available in the Google Maps API v3.
-
enableScrollWheelZoom
public void enableScrollWheelZoom()Enables zooming using a mouse's scroll wheel.Scroll wheel zoom is disabled by default.
-
disableScrollWheelZoom
public void disableScrollWheelZoom()Disables zooming using a mouse's scroll wheel.Scroll wheel zoom is disabled by default.
-
setMapTypeControl
Sets the map type control.The control allows selecting and switching between supported map types via buttons.
-
clicked
The click event.This event is fired when the user clicks on the map with the mouse.
-
doubleClicked
The double click event.This event is fired when a double click is done on the map.
-
mouseMoved
This event is fired when the user moves the mouse inside the map. -
getApiVersion
Return the used Google Maps API version. -
render
Description copied from class:WWidget
Renders 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:
render
in classWCompositeWidget
-
doGmJavaScript
Execute a piece of JavaScript that manipulates the map.This is like
WCompositeWidget#doJavaScript()
but delays the javascript until the map has been loaded.
-