You're reading the documentation for Wicket Stuff 11.x, the current feature line. The 10.x long-term support documentation is the default.
JavaScript libraries
GMap3
The GMap3 project offers a component to use Google Maps v3 within Wicket applications.
History
Even though the code is based on the old GMap2 module, those components are not compatible!
Maven
<dependency>
<groupId>org.wicketstuff</groupId>
<artifactId>wicketstuff-gmap3</artifactId>
</dependency>
Import org.wicketstuff:wicketstuff-bom in your dependencyManagement section to manage the version.
Examples
A simple map
<html>
<body>
<div wicket:id="map">Map</div>
</body>
</html>
public class SimplePage extends WebPage
{
public SimplePage()
{
GMap map = new GMap("map", "your-api-key");
map.setStreetViewControlEnabled(false);
map.setScaleControlEnabled(true);
map.setScrollWheelZoomEnabled(true);
map.setCenter(new GLatLng(52.47649, 13.228573));
add(map);
}
}
Google Maps requires an API key; pass it to the GMap constructor (or use a GMapHeaderContributor).
The setXXXEnabled methods modify the behavior and/or the appearance of the map. More setters of this kind are:
setDoubleClickZoomEnabledsetScrollWheelZoomEnabledsetDraggingEnabledsetMapTypeControlEnabledsetStreetViewControlEnabledsetZoomControlEnabled
The names should be self explainable.
Adding markers with each click on the map
This example demonstrates how to add a marker to each position you click on. The HTML file stays the same.
public class HomePage extends WebPage
{
public HomePage()
{
final GMap map = new GMap("map", "your-api-key");
add(map);
map.add(new ClickListener()
{
@Override
protected void onClick(AjaxRequestTarget target, GLatLng latLng)
{
if (latLng != null)
{
map.addOverlay(new GMarker(new GMarkerOptions(map, latLng)));
}
}
});
}
}
Make sure that you add your map to the page before you apply any listeners!
A GMarker is only one overlay among others. Also available:
GGroundOverlayGInfoWindow(since version 3 you can have more than one InfoWindow)GPolygonGPolyline
For more examples see the examples project. It covers nearly all methods provided by this component.
License
Just like Wicket itself, GMap3 is licensed under Apache 2.0.
The gmap3-examples module contains a runnable example application.
Source: gmap3-parent