private WebFeatureServiceLayer createWfsLayer(
     String displayName, String proxyUrl, String featureType) {
   WebFeatureServiceLayer wfsLayer = new WebFeatureServiceLayer();
   wfsLayer.setDisplayName(displayName);
   wfsLayer.setUri(proxyUrl);
   wfsLayer.setFeatureType(featureType);
   wfsLayer.setFeatureNS("http://www.openplans.org/topp");
   wfsLayer.setProjection("EPSG:4326");
   wfsLayer.setSelectionCtrlId("1");
   wfsLayer.addLoadStartListener(loadStartListener);
   wfsLayer.addLoadEndListener(loadEndListener);
   wfsLayer.addVisibilityChangedListener(visChangedListener);
   return wfsLayer;
 }
  @Override
  Component getMap() {
    OpenLayersMap openLayersMap = new OpenLayersMap();
    OpenStreetMapLayer osmLayer = new OpenStreetMapLayer();

    osmLayer.addLoadStartListener(loadStartListener);
    osmLayer.addLoadEndListener(loadEndListener);

    osmLayer.setUrl("http://b.tile.openstreetmap.org/${z}/${x}/${y}.png");
    osmLayer.setDisplayName("OSM");

    String proxyUrl = contextPath + "/WFSPROXY/demo.opengeo.org/geoserver/wfs";

    WebFeatureServiceLayer wfsCities = createWfsLayer("Cities", proxyUrl, "tasmania_cities");
    setStyle(wfsCities, 1, "yellow", "red", 4, 2);

    WebFeatureServiceLayer wfsRoads = createWfsLayer("Roads", proxyUrl, "tasmania_roads");
    setStyle(wfsRoads, 1, "gray", "gray", 0, 4);
    // don't use beforeselected and selected listener at the same time to show massages
    WebFeatureServiceLayer wfsBoundaries =
        createWfsLayer("Boundaries", proxyUrl, "tasmania_state_boundaries");
    wfsBoundaries.setVisibility(false);
    WebFeatureServiceLayer wfsWater = createWfsLayer("Water", proxyUrl, "tasmania_water_bodies");
    setStyle(wfsWater, 0.5, "blue", "blue", 1, 2);
    openLayersMap.addLayer(osmLayer);
    openLayersMap.addLayer(wfsCities);
    openLayersMap.addLayer(wfsRoads);
    openLayersMap.addLayer(wfsWater);
    openLayersMap.addLayer(wfsBoundaries);
    openLayersMap.setSizeFull();

    openLayersMap.setCenter(146.9417, -42.0429);
    openLayersMap.setZoom(7);

    controls = new HorizontalLayout();

    editor = new com.vaadin.ui.TextArea();
    editor.setRows(20);
    editor.setColumns(20);
    editor.setImmediate(true);
    ((ComponentContainer) getContent()).addComponent(editor);
    controls.addComponent(editor);

    return openLayersMap;
  }
 private void setStyle(
     WebFeatureServiceLayer wfs,
     double opacity,
     String fillColor,
     String strokeColor,
     double pointRadius,
     double strokeWidth) {
   Style style = new Style();
   style.extendCoreStyle("default");
   style.setFillColor(fillColor);
   style.setStrokeColor(strokeColor);
   style.setStrokeWidth(strokeWidth);
   style.setPointRadius(pointRadius);
   style.setFillOpacity(opacity);
   StyleMap styleMap = new StyleMap(style);
   styleMap.setExtendDefault(true);
   wfs.setStyleMap(styleMap);
 }