Package org.wicketstuff.gmap
Class GMap
-
- All Implemented Interfaces:
Serializable
,Iterable<Component>
,IEventSink
,IEventSource
,IFeedbackContributor
,IConverterLocator
,IMetadataContext<Serializable,Component>
,IQueueRegion
,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
Nested Classes Modifier and Type Class Description class
GMap.OverlayListener
class
GMap.PanDirectionBehavior
class
GMap.SetCenterBehavior
class
GMap.SetMapTypeBehavior
class
GMap.SetZoomBehavior
class
GMap.ZoomInBehavior
class
GMap.ZoomOutBehavior
-
Field Summary
Fields Modifier and Type Field Description protected WebMarkupContainer
map
-
Fields inherited from class org.apache.wicket.Component
ENABLE, FLAG_INITIALIZED, FLAG_RESERVED1, FLAG_RESERVED2, FLAG_RESERVED3, FLAG_RESERVED4, FLAG_RESERVED5, FLAG_RESERVED8, PARENT_PATH, PATH_SEPARATOR, RENDER, RFLAG_CONTAINER_DEQUEING, RFLAG_CONTAINER_HAS_REMOVALS
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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
getJSFitMarkers(List<GLatLng> markers)
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(IHeaderResponse response)
void
setBounds(GLatLngBounds bounds)
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 StreetView 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
getRegionMarkup, newMarkupSourcingStrategy
-
Methods inherited from class org.apache.wicket.markup.html.WebMarkupContainer
getWebApplication, getWebPage, getWebRequest, getWebResponse, getWebSession
-
Methods inherited from class org.apache.wicket.MarkupContainer
add, addDequeuedComponent, addOrReplace, autoAdd, canDequeueTag, contains, dequeue, dequeue, dequeuePreamble, findChildComponent, findComponentToDequeue, get, getAssociatedMarkup, getAssociatedMarkupStream, getMarkup, getMarkupType, internalAdd, internalInitialize, iterator, iterator, newDequeueContext, onComponentTagBody, onDetach, onInitialize, onRender, queue, remove, remove, removeAll, renderAll, renderAssociatedMarkup, renderAssociatedMarkup, renderNext, replace, setDefaultModel, size, stream, streamChildren, toString, toString, visitChildren, visitChildren
-
Methods inherited from class org.apache.wicket.Component
add, addStateChange, beforeRender, canCallListener, canCallListenerAfterExpiry, checkComponentTag, checkComponentTagAttribute, checkHierarchyChange, clearOriginalDestination, configure, continueToOriginalDestination, createConverter, 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, getMarkupTag, 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, internalRenderComponent, internalRenderHead, isActionAuthorized, isAuto, isBehaviorAccepted, isEnableAllowed, isEnabled, isEnabledInHierarchy, isIgnoreAttributeModifier, isInitialized, isRenderAllowed, isRendering, isStateless, isVersioned, isVisibilityAllowed, isVisible, isVisibleInHierarchy, markRendering, modelChanged, modelChanging, onAfterRender, onComponentTag, onConfigure, onEvent, onModelChanged, onModelChanging, onReAdd, onRemove, redirectToInterceptPage, remove, remove, render, renderComponentTag, rendered, renderPart, renderPlaceholderTag, replaceComponentTagBody, replaceWith, sameInnermostModel, sameInnermostModel, send, setAuto, setDefaultModelObject, setEnabled, setEscapeModelStrings, setFlag, setIgnoreAttributeModifier, setMarkup, setMarkupId, setMarkupIdImpl, setMetaData, setOutputMarkupId, setOutputMarkupPlaceholderTag, setParent, setRenderBodyOnly, setResponsePage, setResponsePage, setResponsePage, setVersioned, setVisibilityAllowed, setVisible, success, urlFor, urlFor, urlFor, urlForListener, urlForListener, visitParents, visitParents, warn, wrap
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.wicket.IQueueRegion
dequeue, newDequeueContext
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Field Detail
-
map
protected final WebMarkupContainer map
-
-
Constructor Detail
-
GMap
public GMap(String id, String apiKey)
Constructor. Default the header contributor of the component will added and the gmap will be initiated directly on rendering of the map.- Parameters:
id
- wicket idapiKey
- your Google API key
-
GMap
public GMap(String id, String apiKey, String scheme)
Constructor. Default the header contributor of the component will added and the gmap will be initiated directly on rendering of the map.- Parameters:
id
- wicket idscheme
- the scheme ("http" or "https") which should be usedapiKey
- your Google API key
-
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 classComponent
-
renderHead
public void renderHead(IHeaderResponse response)
- Specified by:
renderHead
in interfaceIHeaderContributor
- Overrides:
renderHead
in classComponent
-
addOverlay
public GMap addOverlay(GOverlay overlay)
Add an overlay.- Specified by:
addOverlay
in interfaceGOverlayContainer
- 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 interfaceGOverlayContainer
- Parameters:
overlay
- overlay to remove- Returns:
- This
- See Also:
GOverlayContainer.removeOverlay(GOverlay)
-
removeAllOverlays
public GMap removeAllOverlays()
Clear all overlays.- Specified by:
removeAllOverlays
in interfaceGOverlayContainer
- Returns:
- This
- See Also:
GOverlayContainer.removeAllOverlays()
-
getOverlays
public List<GOverlay> getOverlays()
- Specified by:
getOverlays
in interfaceGOverlayContainer
- Returns:
- all overlay's
- See Also:
GOverlayContainer.getOverlays()
-
getBounds
public GLatLngBounds getBounds()
-
setBounds
public void setBounds(GLatLngBounds bounds)
-
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 StreetView 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
-
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.
-
isFailSilently
public boolean isFailSilently()
-
setFailSilently
public void setFailSilently(boolean failSilently)
-
-