eu.webtoolkit.jwt
Class WGoogleMap

java.lang.Object
  extended by eu.webtoolkit.jwt.WObject
      extended by eu.webtoolkit.jwt.WWidget
          extended by eu.webtoolkit.jwt.WCompositeWidget
              extended by eu.webtoolkit.jwt.WGoogleMap

public class WGoogleMap
extends WCompositeWidget

A widget that displays a google map.

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
static class WGoogleMap.ApiVersion
          ApiVersion.
static class WGoogleMap.Coordinate
          A geographical coordinate (latitude/longitude).
static class WGoogleMap.MapTypeControl
          MapTypeControl.
 
Field Summary
 
Fields inherited from class eu.webtoolkit.jwt.WWidget
WT_GETPS_JS
 
Constructor Summary
WGoogleMap()
          Creates a map widget with optionally a parent argument.
WGoogleMap(WContainerWidget parent)
          Creates a map widget with optionally a parent argument.
WGoogleMap(WGoogleMap.ApiVersion version)
          Creates a map widget with a version and optionally a parent argument.
WGoogleMap(WGoogleMap.ApiVersion version, WContainerWidget parent)
          Creates a map widget with a version and optionally a parent argument.
 
Method Summary
 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, java.lang.String iconURL)
          Adds a icon marker overlay to the map.
 void addMarker(WGoogleMap.Coordinate pos)
          Adds a marker overlay to the map.
 void addPolyline(java.util.List<WGoogleMap.Coordinate> points)
          Adds a polyline overlay to the map.
 void addPolyline(java.util.List<WGoogleMap.Coordinate> points, WColor color)
          Adds a polyline overlay to the map.
 void addPolyline(java.util.List<WGoogleMap.Coordinate> points, WColor color, int width)
          Adds a polyline overlay to the map.
 void addPolyline(java.util.List<WGoogleMap.Coordinate> points, WColor color, int width, double opacity)
          Adds a polyline overlay to the map.
 void checkResize()
          Deprecated. the map is resized automatically when necessary
 void clearOverlays()
          Removes all overlays from the map.
 JSignal1<WGoogleMap.Coordinate> clicked()
          The click event.
 void disableDoubleClickZoom()
          Disables double click to zoom in and out.
 void disableDragging()
          Disables the dragging of the map.
 void disableGoogleBar()
          Disables the GoogleBar integrated search control.
 void disableScrollWheelZoom()
          Disables zooming using a mouse's scroll wheel.
protected  void doGmJavaScript(java.lang.String jscode)
          Execute a piece of JavaScript that manipulates the map.
 JSignal1<WGoogleMap.Coordinate> doubleClicked()
          The double click event.
 void enableDoubleClickZoom()
          Enables double click to zoom in and out (enabled by default).
 void enableDragging()
          Enables the dragging of the map (enabled by default).
 void enableGoogleBar()
          Enables the GoogleBar, an integrated search control, on the map.
 void enableScrollWheelZoom()
          Enables zooming using a mouse's scroll wheel.
 WGoogleMap.ApiVersion getApiVersion()
          Return the used Google Maps API version.
 JSignal1<WGoogleMap.Coordinate> mouseMoved()
          This event is fired when the user moves the mouse inside the map.
 void openInfoWindow(WGoogleMap.Coordinate pos, java.lang.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.
 void returnToSavedPosition()
          Restores the map view that was saved by savePosition().
 void savePosition()
          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 setMapTypeControl(WGoogleMap.MapTypeControl type)
          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, getClearSides, getDecorationStyle, getFloatSide, getHeight, getId, getImplementation, getJavaScriptMember, getLineHeight, getMargin, getMaximumHeight, getMaximumWidth, getMinimumHeight, getMinimumWidth, getOffset, getPositionScheme, getStyleClass, getTabIndex, getTakeImplementation, getToolTip, getVerticalAlignment, getVerticalAlignmentLength, getWidth, hasStyleClass, isDisabled, isEnabled, isHidden, isHiddenKeepsGeometry, isInline, isLoaded, isPopup, isVisible, load, propagateSetEnabled, refresh, removeStyleClass, resize, setAttributeValue, setClearSides, setDecorationStyle, setDisabled, setFloatSide, setHidden, setHiddenKeepsGeometry, setId, setImplementation, setInline, setJavaScriptMember, setLineHeight, setMargin, setMaximumSize, setMinimumSize, setOffsets, setPopup, setPositionScheme, setSelectable, setStyleClass, setTabIndex, setToolTip, setVerticalAlignment
 
Methods inherited from class eu.webtoolkit.jwt.WWidget
acceptDrops, acceptDrops, addCssRule, addCssRule, addStyleClass, animateHide, animateShow, createJavaScript, disable, dropEvent, enable, getDrop, getJsRef, getParent, hide, htmlText, isExposed, isLayoutSizeAware, isRendered, layoutSizeChanged, positionAt, positionAt, removeStyleClass, resize, scheduleRender, scheduleRerender, setClearSides, 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
addChild, getObjectName, setObjectName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WGoogleMap

public WGoogleMap(WGoogleMap.ApiVersion version,
                  WContainerWidget parent)
Creates a map widget with a version and optionally a parent argument.


WGoogleMap

public WGoogleMap(WGoogleMap.ApiVersion version)
Creates a map widget with a version and optionally a parent argument.

Calls this(version, (WContainerWidget)null)


WGoogleMap

public WGoogleMap(WContainerWidget parent)
Creates a map widget with optionally a parent argument.


WGoogleMap

public WGoogleMap()
Creates a map widget with optionally a parent argument.

Calls this((WContainerWidget)null)

Method Detail

remove

public void remove()
Destructor.

Overrides:
remove in class WCompositeWidget
See Also:
WContainerWidget.removeWidget(WWidget widget)

addMarker

public void addMarker(WGoogleMap.Coordinate pos)
Adds a marker overlay to the map.


addPolyline

public void addPolyline(java.util.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

public final void addPolyline(java.util.List<WGoogleMap.Coordinate> points)
Adds a polyline overlay to the map.

Calls addPolyline(points, WColor.red, 2, 1.0)


addPolyline

public final void addPolyline(java.util.List<WGoogleMap.Coordinate> points,
                              WColor color)
Adds a polyline overlay to the map.

Calls addPolyline(points, color, 2, 1.0)


addPolyline

public final void addPolyline(java.util.List<WGoogleMap.Coordinate> points,
                              WColor color,
                              int width)
Adds a polyline overlay to the map.

Calls addPolyline(points, color, width, 1.0)


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

public void addIconMarker(WGoogleMap.Coordinate pos,
                          java.lang.String iconURL)
Adds a icon marker overlay to the map.


clearOverlays

public void clearOverlays()
Removes all overlays from the map.


openInfoWindow

public void openInfoWindow(WGoogleMap.Coordinate pos,
                           java.lang.CharSequence myHtml)
Opens a text bubble with html text at a specific location.


setCenter

public void setCenter(WGoogleMap.Coordinate center)
Sets the map view to the given center.


setCenter

public void setCenter(WGoogleMap.Coordinate center,
                      int zoom)
Sets the map view to the given center and zoom level.


panTo

public void panTo(WGoogleMap.Coordinate center)
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

public void zoomWindow(WGoogleMap.Coordinate topLeft,
                       WGoogleMap.Coordinate rightBottom)
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 by savePosition().


checkResize

public void checkResize()
Deprecated. the map is resized automatically when necessary

Notifies the map of a change of the size of its container.

Call this method after the size of the container DOM object has changed, so that the map can adjust itself to fit the new size.


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

public void setMapTypeControl(WGoogleMap.MapTypeControl type)
Sets the map type control.

The control allows selecting and switching between supported map types via buttons.


clicked

public JSignal1<WGoogleMap.Coordinate> clicked()
The click event.

This event is fired when the user clicks on the map with the mouse.


doubleClicked

public JSignal1<WGoogleMap.Coordinate> doubleClicked()
The double click event.

This event is fired when a double click is done on the map.


mouseMoved

public JSignal1<WGoogleMap.Coordinate> mouseMoved()
This event is fired when the user moves the mouse inside the map.


getApiVersion

public WGoogleMap.ApiVersion getApiVersion()
Return the used Google Maps API version.


doGmJavaScript

protected void doGmJavaScript(java.lang.String jscode)
Execute a piece of JavaScript that manipulates the map.

This is like WCompositeWidget#doJavaScript() but delays the javascript until the map has been loaded.