c.setOutputMarkupId(true);
//Add or replace it on the hiddenContainer
hiddenContainersInfoPanel.addOrReplace(c);
infoWindow = new GInfoWindow(gLatLng, c);
map.addOverlay(infoWindow);
feedback.info("InfoWindow " + infoWindow.getId() + " was added");
target.add(feedback);
//add the hiddenContainer to be repainted
target.add(hiddenContainersInfoPanel);
// IMPORTANT: you must have the InfoWindow already added to the map
// before you can add any listeners
infoWindow.addListener(GEvent.closeclick, closeClickHandler);
}
}
});
add(map);
lbInfoWindow = new Label("infoWindow", "openInfoWindow");
lbInfoWindow.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)
{
GInfoWindow tmpInfoWindow = new GInfoWindow(new GLatLng(37.5 * (0.9995 + Math.random() / 1000), -122.1 * (0.9995 + Math.random() / 1000)), "Opened via button");
map.addOverlay(tmpInfoWindow);
// IMPORTANT: you must have the InfoWindow already added to the map
// before you can add any listeners
GEventHandler closeClickHandler = new GEventHandler()
{
private static final long serialVersionUID = 1L;
@Override
public void onEvent(AjaxRequestTarget target)
{
feedback.info("InfoWindow which was opened via a button was closed");
target.add(feedback);
}
};
tmpInfoWindow.addListener(GEvent.closeclick, closeClickHandler);
feedback.info("InfoWindow was opened via button");
target.add(feedback);
}
});
add(lbInfoWindow);