private static final long serialVersionUID = 1L;
@Override
protected void onClick(AjaxRequestTarget target, GLatLng latLng, GOverlay overlay)
{
GMarker marker = (overlay instanceof GMarker) ? (GMarker)overlay : null;
if (marker != null)
{
topMap.getInfoWindow().open(marker, new HelloPanel());
}
else if (latLng != null)
{
marker = new GMarker(latLng);
topMap.addOverlay(marker);
}
markerSelected(target, marker);
}
});
topMap.setZoom(10);
GMarkerOptions options = new GMarkerOptions("Home").draggable(true).autoPan(true);
topMap.addOverlay(new GMarker(new GLatLng(37.4, -122.1), options));
topMap.addControl(GControl.GLargeMapControl);
topMap.addControl(GControl.GMapTypeControl);
add(topMap);
final IModel<GMarker> markerModel = new Model<GMarker>(null);
markerLabel = new Label("markerLabel", markerModel);
markerLabel.add(new AjaxEventBehavior("onclick")
{
private static final long serialVersionUID = 1L;
/**
* @see org.apache.wicket.ajax.AjaxEventBehavior#onEvent(org.apache.wicket.ajax.AjaxRequestTarget)
*/
@Override
protected void onEvent(AjaxRequestTarget target)
{
GMarker marker = markerModel.getObject();
if (marker != null)
{
GLatLng point = marker.getLatLng();
GMarker random = new GMarker(new GLatLng(point.getLat()
* (0.9995 + Math.random() / 1000), point.getLng()
* (0.9995 + Math.random() / 1000)));
topMap.addOverlay(random);
}