- 
                Notifications
    
You must be signed in to change notification settings  - Fork 295
 
Gmap3
The GMap3 project offers a component to use Google Maps v3 within Wicket 6 applications.
Even though the code is based on https://github.com/wicketstuff/core/tree/core-1.4.x/jdk-1.6-parent/gmap3-parent which was forked from https://github.com/wicketstuff/core/tree/master/jdk-1.6-parent/gmap2-parent those components are not compatible!
- wicketstuff-gmap3
 - wicketstuff-gmap3-examples
 
At the time of this writing no stable release is available. You have to use the snapshot:
<dependency>
    <groupId>org.wicketstuff</groupId>
    <artifactId>wicketstuff-gmap3</artifactId>
    <version>6.0-SNAPSHOT</version>
</dependency>
<repository>
	<id>wicketstuff-core-snapshots</id>
	<url>ttps://oss.sonatype.org/content/repositories/snapshots</url>
	<snapshots>
		<enabled>true</enabled>
	</snapshots>		
</repository><html>
    <body>
        <div wicket:id="map">Map</div>
    </body>
</html>public class SimplePage extends WebPage
{
    public SimplePage()
    {
        GMap map = new GMap("map");
        map.setStreetViewControlEnabled(false);
        map.setScaleControlEnabled(true);
        map.setScrollWheelZoomEnabled(true);
        map.setCenter(new GLatLng(52.47649, 13.228573));        
        add(map);
    }
}Since version 3 the Google Maps API does not need an API-key anymore. Even though it is still supported by Google (for tracking) this component does NOT provide the possibility to pass a key at the moment.
The setXXXEnabled methods modifies the behavior and/or the appearance of the map. More setters of this kind are:
- setDoubleClickZoomEnabled
 - setScrollWheelZoomEnabled
 - setDraggingEnabled
 - setMapTypeControlEnabled
 - setStreetViewControlEnabled
 - setZoomControlEnabled The names should be self explainable.
 
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");
        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:
- GGroundOverlay
 - GInfoWindow (since version 3 you can have more than one InfoWindow)
 - GPolygon
 - GPolyline
 
For more examples see the example-project. It covers nearly all methods provided by this component.
The component itself can be found under https://github.com/wicketstuff/core/tree/master/jdk-1.6-parent/gmap3-parent/gmap3 The examples under https://github.com/wicketstuff/core/tree/master/jdk-1.6-parent/gmap3-parent/gmap3-examples
Just like Wicket itself, GMap3 is licensed under Apache 2.0.