org.wicketstuff.gmap
Class GMap

java.lang.Object
  extended by org.apache.wicket.Component
      extended by org.apache.wicket.MarkupContainer
          extended by org.apache.wicket.markup.html.WebMarkupContainer
              extended by org.apache.wicket.markup.html.panel.Panel
                  extended by org.wicketstuff.gmap.GMap
All Implemented Interfaces:
Serializable, Iterable<Component>, IEventSink, IEventSource, IConverterLocator, IHeaderContributor, IRequestableComponent, IHierarchical<Component>, IClusterable, GOverlayContainer
Direct Known Subclasses:
GMapStateless

public class GMap
extends Panel
implements GOverlayContainer

Wicket component to embed Google Maps into your pages.

See Also:
Serialized Form

Nested Class Summary
 class GMap.OverlayListener
           
 class GMap.PanDirectionBehavior
           
 class GMap.SetCenterBehavior
           
 class GMap.SetMapTypeBehavior
           
 class GMap.SetZoomBehavior
           
 class GMap.ZoomInBehavior
           
 class GMap.ZoomOutBehavior
           
 
Field Summary
protected  WebMarkupContainer map
           
 
Fields inherited from class org.apache.wicket.markup.html.panel.Panel
PANEL
 
Fields inherited from class org.apache.wicket.Component
ENABLE, FLAG_INITIALIZED, FLAG_REMOVING_FROM_HIERARCHY, FLAG_RESERVED1, FLAG_RESERVED2, FLAG_RESERVED3, FLAG_RESERVED4, FLAG_RESERVED5, FLAG_RESERVED8, PARENT_PATH, PATH_SEPARATOR, RENDER
 
Constructor Summary
GMap(String id)
          Construct.
GMap(String id, boolean sensor)
           
GMap(String id, GMapHeaderContributor headerContrib)
          Construct.
 
Method Summary
 GMap addOverlay(GOverlay overlay)
          Add an overlay.
 void fitMarkers(List<GLatLng> markersToShow)
           
 void fitMarkers(List<GLatLng> markersToShow, boolean showMarkersForPoints)
           
 void fitMarkers(List<GLatLng> markersToShow, boolean showMarkersForPoints, double zoomAdjustment)
           Makes the map zoom out and centre around all the GLatLng points in markersToShow.
 GLatLngBounds getBounds()
           
 GLatLng getCenter()
           
 String getJSinit()
          Generates the JavaScript used to instantiate this GMap3 as an JavaScript class on the client side.
 String getJSinvoke(String invocation)
          Convenience method for generating a JavaScript call on this GMap with the given invocation.
 String getJsReference()
          Build a reference in JS-Scope.
 String getMapId()
           
 GMapType getMapType()
           
 int getMaxZoom()
           
 int getMinZoom()
           
protected  GMap.OverlayListener getOverlayListener()
           
 List<GOverlay> getOverlays()
           
 CharSequence getTriggerEventScript(String event)
          Returns the script for triggering an event on map.
 CharSequence getTriggerResizeScript()
           
 int getZoom()
           
 boolean isDoubleClickZoomEnabled()
          Is the function zooming-by-doubleclick enabled? Disabled by default.
 boolean isDraggingEnabled()
          Is dragging allowed? Enabled by default.
 boolean isFailSilently()
           
 boolean isMapTypeControlEnabled()
          Is the map type control enabled? Enabled by default.
 boolean isMarkerClusterEnabled()
           
 boolean isPanControlEnabled()
          Is the pan control enabled? Enabled by default.
 boolean isScaleControlEnabled()
          Is the scale control enabled? Disabled by default.
 boolean isScrollWheelZoomEnabled()
          Is the function zooming-by-mousewheel enabled? Disabled by default.
 boolean isStreetViewControlEnabled()
          Is the StreetView control enabled? Disabled by default.
 boolean isZoomControlEnabled()
          Is the zoom control enabled? Enabled by default.
protected  void onBeforeRender()
           
 void panTo(GLatLng center)
          Changes the center point of the map to the given point.
 GMap removeAllOverlays()
          Clear all overlays.
 GMap removeOverlay(GOverlay overlay)
          Remove an overlay.
 void renderHead(org.apache.wicket.markup.head.IHeaderResponse response)
           
 void setCenter(GLatLng center)
          Set the center.
 void setDoubleClickZoomEnabled(boolean enabled)
          Sets if zooming-by-doubleclicking should be allowed or not.
 void setDraggingEnabled(boolean enabled)
          Sets if dragging should be allowed or not.
 void setFailSilently(boolean failSilently)
           
 void setMapType(GMapType mapType)
          Sets the map type which should be used.
 void setMapTypeControlEnabled(boolean enabled)
          Sets if the map type control should be visible or not.
 void setMarkerCluster(GMarkerCluster markerCluster)
           
 void setMaxZoom(int level)
          Sets a new maxZoom limit.
 void setMinZoom(int level)
          Sets a new minZoom limit.
 void setOverlays(List<GOverlay> overlays)
           
 void setPanControlEnabled(boolean enabled)
          Sets if the pan control should be visible or not.
 void setScaleControlEnabled(boolean enabled)
          Sets if the scale control should be visible or not.
 void setScrollWheelZoomEnabled(boolean enabled)
          Sets if zooming-by-mousewheel should be allowed or not.
 void setStreetViewControlEnabled(boolean enabled)
          Sets if the StreeView control should be visible or not.
 void setZoom(int level)
          Sets a new zoom level.
 void setZoomControlEnabled(boolean enabled)
          Sets if the zoom control should be visible or not.
 void update()
          Update state from a request to an AJAX target.
 
Methods inherited from class org.apache.wicket.markup.html.panel.Panel
newMarkupSourcingStrategy
 
Methods inherited from class org.apache.wicket.markup.html.WebMarkupContainer
getWebPage, getWebRequest, getWebResponse, getWebSession
 
Methods inherited from class org.apache.wicket.MarkupContainer
add, addOrReplace, autoAdd, contains, get, get, getAssociatedMarkup, getAssociatedMarkupStream, getMarkup, getMarkupType, internalAdd, internalInitialize, iterator, iterator, onAfterRenderChildren, onComponentTagBody, onRender, remove, remove, removeAll, renderAll, renderAssociatedMarkup, renderNext, replace, setDefaultModel, size, swap, toString, toString, visitChildren, visitChildren, visitChildren, visitChildren
 
Methods inherited from class org.apache.wicket.Component
add, addStateChange, afterRender, beforeRender, canCallListenerInterface, checkComponentTag, checkComponentTagAttribute, checkHierarchyChange, clearOriginalDestination, configure, continueToOriginalDestination, debug, detach, detachModel, detachModels, determineVisibility, error, exceptionMessage, fatal, findMarkupStream, findPage, findParent, findParentWithAssociatedMarkup, getAjaxRegionMarkupId, getApplication, getBehaviorById, getBehaviorId, getBehaviors, getBehaviors, getClassRelativePath, getConverter, getDefaultModel, getDefaultModelObject, getDefaultModelObjectAsString, getDefaultModelObjectAsString, getEscapeModelStrings, getFeedbackMessages, getFlag, getId, getInnermostModel, getInnermostModel, getLocale, getLocalizer, getMarkup, getMarkupAttributes, getMarkupId, getMarkupId, getMarkupIdFromMarkup, getMarkupIdImpl, getMarkupSourcingStrategy, getMetaData, getModelComparator, getOutputMarkupId, getOutputMarkupPlaceholderTag, getPage, getPageRelativePath, getParent, getPath, getRenderBodyOnly, getRequest, getRequestCycle, getRequestFlag, getResponse, getSession, getSizeInBytes, getStatelessHint, getString, getString, getString, getStyle, getVariation, hasBeenRendered, hasErrorMessage, hasFeedbackMessage, info, initModel, internalOnModelChanged, internalPrepareForRender, internalRenderComponent, isActionAuthorized, isAuto, isBehaviorAccepted, isEnableAllowed, isEnabled, isEnabledInHierarchy, isIgnoreAttributeModifier, isRenderAllowed, isStateless, isVersioned, isVisibilityAllowed, isVisible, isVisibleInHierarchy, markRendering, modelChanged, modelChanging, onAfterRender, onComponentTag, onConfigure, onDetach, onEvent, onInitialize, onModelChanged, onModelChanging, onRemove, prepareForRender, redirectToInterceptPage, remove, remove, render, renderComponentTag, rendered, renderHead, renderHead, renderPlaceholderTag, replaceComponentTagBody, replaceWith, sameInnermostModel, sameInnermostModel, send, setAuto, setDefaultModelObject, setEnabled, setEscapeModelStrings, setFlag, setIgnoreAttributeModifier, setMarkup, setMarkupId, setMarkupIdImpl, setMetaData, setOutputMarkupId, setOutputMarkupPlaceholderTag, setParent, setRenderBodyOnly, setRequestFlag, setResponsePage, setResponsePage, setResponsePage, setVersioned, setVisibilityAllowed, setVisible, success, urlFor, urlFor, urlFor, urlFor, urlFor, visitParents, visitParents, warn, wrap
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

map

protected final WebMarkupContainer map
Constructor Detail

GMap

public GMap(String id)
Construct. Default the header contributor of the component will added and the gmap will be inited directly on rendering of the map.

Parameters:
id - wicket id

GMap

public GMap(String id,
            boolean sensor)

GMap

public GMap(String id,
            GMapHeaderContributor headerContrib)
Construct.

Parameters:
id -
headerContrib -
Method Detail

getOverlayListener

protected GMap.OverlayListener getOverlayListener()

getMapId

public String getMapId()
Returns:
the markup-id of the container

onBeforeRender

protected void onBeforeRender()
Overrides:
onBeforeRender in class Component

renderHead

public void renderHead(org.apache.wicket.markup.head.IHeaderResponse response)
Specified by:
renderHead in interface IHeaderContributor
Overrides:
renderHead in class Component

addOverlay

public GMap addOverlay(GOverlay overlay)
Add an overlay.

Specified by:
addOverlay in interface GOverlayContainer
Parameters:
overlay - overlay to add
Returns:
This
See Also:
GOverlayContainer.addOverlay(GOverlay)

removeOverlay

public GMap removeOverlay(GOverlay overlay)
Remove an overlay.

Specified by:
removeOverlay in interface GOverlayContainer
Parameters:
overlay - overlay to remove
Returns:
This
See Also:
GOverlayContainer.removeOverlay(GOverlay)

removeAllOverlays

public GMap removeAllOverlays()
Clear all overlays.

Specified by:
removeAllOverlays in interface GOverlayContainer
Returns:
This
See Also:
GOverlayContainer.removeAllOverlays()

getOverlays

public List<GOverlay> getOverlays()
Specified by:
getOverlays in interface GOverlayContainer
Returns:
all overlay's
See Also:
GOverlayContainer.getOverlays()

getBounds

public GLatLngBounds getBounds()

getTriggerEventScript

public CharSequence getTriggerEventScript(String event)
Returns the script for triggering an event on map.

Parameters:
event -
Returns:

getTriggerResizeScript

public CharSequence getTriggerResizeScript()
Returns:
returns the script to make map re-paint after resize.

setDraggingEnabled

public void setDraggingEnabled(boolean enabled)
Sets if dragging should be allowed or not.

Parameters:
enabled - true if dragging should be allowed, false otherwise

isDraggingEnabled

public boolean isDraggingEnabled()
Is dragging allowed? Enabled by default.

Returns:
true if it's allowed, false if not

setDoubleClickZoomEnabled

public void setDoubleClickZoomEnabled(boolean enabled)
Sets if zooming-by-doubleclicking should be allowed or not.

Parameters:
enabled - true if zooming-by-doubleclicking should be allowed, false otherwise

isDoubleClickZoomEnabled

public boolean isDoubleClickZoomEnabled()
Is the function zooming-by-doubleclick enabled? Disabled by default.

Returns:
true if enabled, false if disabled

setScrollWheelZoomEnabled

public void setScrollWheelZoomEnabled(boolean enabled)
Sets if zooming-by-mousewheel should be allowed or not.

Parameters:
enabled - true if zooming-by-mousewheel should be allowed, false otherwise

isScrollWheelZoomEnabled

public boolean isScrollWheelZoomEnabled()
Is the function zooming-by-mousewheel enabled? Disabled by default.

Returns:
true if enabled, false if disabled

isStreetViewControlEnabled

public boolean isStreetViewControlEnabled()
Is the StreetView control enabled? Disabled by default.

Returns:
true if enabled, false if disabled

setStreetViewControlEnabled

public void setStreetViewControlEnabled(boolean enabled)
Sets if the StreeView control should be visible or not.

Parameters:
enabled - true if StreetView should be allowed, false otherwise

isZoomControlEnabled

public boolean isZoomControlEnabled()
Is the zoom control enabled? Enabled by default.

Returns:
true if enabled, false if disabled

setZoomControlEnabled

public void setZoomControlEnabled(boolean enabled)
Sets if the zoom control should be visible or not.

Parameters:
enabled - true if the zoom-control should be enabled, false otherwise

isMapTypeControlEnabled

public boolean isMapTypeControlEnabled()
Is the map type control enabled? Enabled by default.

Returns:
true if enabled, false if disabled

setMapTypeControlEnabled

public void setMapTypeControlEnabled(boolean enabled)
Sets if the map type control should be visible or not.

Parameters:
enabled - true if you want the user to have the possibility to change the map type, false otherwise

isScaleControlEnabled

public boolean isScaleControlEnabled()
Is the scale control enabled? Disabled by default.

Returns:
true if enabled, false if disabled

setScaleControlEnabled

public void setScaleControlEnabled(boolean enabled)
Sets if the scale control should be visible or not.

Parameters:
enabled - true if the scale-control should be enabled, false otherwise

isPanControlEnabled

public boolean isPanControlEnabled()
Is the pan control enabled? Enabled by default.

Returns:
true if enabled, false if disabled

setPanControlEnabled

public void setPanControlEnabled(boolean enabled)
Sets if the pan control should be visible or not.

Parameters:
enabled - true if the pan-control should be enabled, false otherwise

getMapType

public GMapType getMapType()
Returns:
the current map type.
See Also:
GMapType

setMapType

public void setMapType(GMapType mapType)
Sets the map type which should be used.

Parameters:
mapType - the map type
See Also:
GMapType

getZoom

public int getZoom()
Returns:
the current zoom level

getMinZoom

public int getMinZoom()
Returns:
the minZoom level

getMaxZoom

public int getMaxZoom()
Returns:
the maxZoom level

setZoom

public void setZoom(int level)
Sets a new zoom level.

Parameters:
level - the new zoom level

setMinZoom

public void setMinZoom(int level)
Sets a new minZoom limit.

Parameters:
level - the new minZoom level

setMaxZoom

public void setMaxZoom(int level)
Sets a new maxZoom limit.

Parameters:
level - the new maxZoom level

getCenter

public GLatLng getCenter()
Returns:
the current center point

setCenter

public void setCenter(GLatLng center)
Set the center.

Parameters:
center - center to set

panTo

public void panTo(GLatLng 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.

Parameters:
center - the new center of the map

setMarkerCluster

public void setMarkerCluster(GMarkerCluster markerCluster)

isMarkerClusterEnabled

public boolean isMarkerClusterEnabled()

getJSinit

public String getJSinit()
Generates the JavaScript used to instantiate this GMap3 as an JavaScript class on the client side.

Returns:
The generated JavaScript

getJSinvoke

public String getJSinvoke(String invocation)
Convenience method for generating a JavaScript call on this GMap with the given invocation.

Parameters:
invocation - The JavaScript call to invoke on this GMap.
Returns:
The generated JavaScript.

getJsReference

public String getJsReference()
Build a reference in JS-Scope.


fitMarkers

public void fitMarkers(List<GLatLng> markersToShow)
See Also:
fitMarkers(List, boolean, double)

fitMarkers

public void fitMarkers(List<GLatLng> markersToShow,
                       boolean showMarkersForPoints)
See Also:
fitMarkers(List, boolean, double)

fitMarkers

public void fitMarkers(List<GLatLng> markersToShow,
                       boolean showMarkersForPoints,
                       double zoomAdjustment)

Makes the map zoom out and centre around all the GLatLng points in markersToShow.

Big ups to Doug Leeper for the code.

Parameters:
markersToShow - the points to centre around.
showMarkersForPoints - if true, will also add basic markers to the map for each point focused on. Just a simple convenience method - you will probably want to turn this off so that you can show more information with each marker when clicked etc.
See Also:
Doug's Nabble post

update

public void update()
Update state from a request to an AJAX target. You need to call this method explictly if you want to have up-to-date values.


setOverlays

public void setOverlays(List<GOverlay> overlays)

isFailSilently

public boolean isFailSilently()

setFailSilently

public void setFailSilently(boolean failSilently)


Copyright © 2014. All rights reserved.