layerList.add(layer);
layerList.add(select);
layerList.add(hover);
GetFeature control = new GetFeature(layer, true, true, "shiftKey", "ctrlKey");
//
// control = new OpenLayers.Control.GetFeature({
// protocol: OpenLayers.Protocol.WFS.fromWMSLayer(layer),
// box: true,
// hover: true,
// multipleKey: "shiftKey",
// toggleKey: "ctrlKey"
// });
// map.addControl(control);
// control.activate();
//
// map.setCenter();
HashMap<String, String> mapOptions = new LinkedHashMap<String, String>();
// mapOptions.put("maxExtent",
// "new OpenLayers.Bounds(143.834,-43.648,148.479,-39.573)");
final WFSProxyBehavior proxyBehaviour = new WFSProxyBehavior();
OpenLayersMap map = new OpenLayersMap("map", true, layerList, mapOptions)
{
private static final long serialVersionUID = 1L;
/*
* (non-Javadoc)
*
* @see org.wicketstuff.openlayers.OpenLayersMap#getJSinit()
*/
@Override
protected String getJSinit()
{
return "OpenLayers.ProxyHost='" + proxyBehaviour.getProxyUrl() + "';\n" +
super.getJSinit();
}
};
map.setCenter(LonLat.parse("-140.444336,25.115234,-44.438477,50.580078"));
map.setZoom(3);
map.addControl(control);
map.addControl(Control.PanZoomBar);
map.addControl(Control.Navigation);
map.addControl(Control.Permalink);
map.add(proxyBehaviour);
control.registerJavascriptEvent(map, "featureselected",
new Model<String>("vec" + select.getId() + ".addFeatures([evt.feature]);"));
control.registerJavascriptEvent(map, "featureunselected",
new Model<String>("vec" + select.getId() + ".removeFeatures([evt.feature]);"));
control.registerJavascriptEvent(map, "hoverfeature",
new Model<String>("vec" + hover.getId() + ".addFeatures([evt.feature]);"));
control.registerJavascriptEvent(map, "outfeature", new Model<String>("vec" + hover.getId() +
".removeFeatures([evt.feature]);"));
add(map);
}