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:
  • Field Details

  • Constructor Details

    • 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 id
      apiKey - 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 id
      scheme - the scheme ("http" or "https") which should be used
      apiKey - your Google API key
    • GMap

      public GMap(String id, GMapHeaderContributor headerContrib)
      Construct.
      Parameters:
      id -
      headerContrib -
  • Method Details

    • 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(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:
    • removeOverlay

      public GMap removeOverlay(GOverlay overlay)
      Remove an overlay.
      Specified by:
      removeOverlay in interface GOverlayContainer
      Parameters:
      overlay - overlay to remove
      Returns:
      This
      See Also:
    • removeAllOverlays

      public GMap removeAllOverlays()
      Clear all overlays.
      Specified by:
      removeAllOverlays in interface GOverlayContainer
      Returns:
      This
      See Also:
    • getOverlays

      public List<GOverlay> getOverlays()
      Specified by:
      getOverlays in interface GOverlayContainer
      Returns:
      all overlay's
      See Also:
    • 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
    • getMapType

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

      public void setMapType(GMapType mapType)
      Sets the map type which should be used.
      Parameters:
      mapType - the map type
      See Also:
    • 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

      public void fitMarkers(List<GLatLng> markersToShow, boolean showMarkersForPoints)
      See Also:
    • 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:
    • getJSFitMarkers

      public String getJSFitMarkers(List<GLatLng> markers)
    • 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)