Beispiel #1
0
  @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;
  }
  @Override
  public Component getTestComponent() {
    // create the map
    map = new OpenLayersMap();
    map.setApiProjection("EPSG:4326");
    OpenStreetMapLayer layer = new OpenStreetMapLayer();
    layer.setProjection("EPSG:900913");
    map.addLayer(layer);
    map.setSizeFull();

    // create the marker layer
    markerLayer = new MarkerLayer();
    map.addLayer(markerLayer);

    map.setCenter(22.30, 60.452);
    map.setZoom(14);

    // add marker
    addMarker(22.30, 60.452);

    return map;
  }
Beispiel #3
0
  @Override
  Component getMap() {

    OpenStreetMapLayer osm = new OpenStreetMapLayer();
    osm.setDisplayName("OSM Streets Base");

    GoogleStreetMapLayer gsm = new GoogleStreetMapLayer();
    gsm.setDisplayName("Google Streets Base");

    GoogleHybridMapLayer ghm = new GoogleHybridMapLayer();
    ghm.setDisplayName("Google Hybrid Base");

    map.addLayer(osm);
    map.addLayer(gsm);
    map.addLayer(ghm);

    map.setCenter(-104.9, 38);
    map.setZoom(6);
    map.setSizeFull();

    Label l1 =
        new Label(
            "The map's base layer state should be synchronized between this OptionGroup and the OL LayerSwitcher.");
    l1.setSizeUndefined();

    final Layer[] layers = {osm, gsm, ghm};
    final List<Layer> layerlist = Arrays.asList(layers);
    final OptionGroup baseLayers = new OptionGroup("Base Layers", layerlist);
    baseLayers.select(osm.getDisplayName());
    baseLayers.setNullSelectionAllowed(false);
    baseLayers.setImmediate(true);
    baseLayers.addValueChangeListener(
        new ValueChangeListener() {
          public void valueChange(ValueChangeEvent event) {
            Layer newlayer = (Layer) event.getProperty().getValue();
            if (!newlayer.equals(map.getBaseLayer())) {
              map.setBaseLayer(newlayer);
            }
          }
        });

    map.addBaseLayerChangeListener(
        new BaseLayerChangeListener() {

          public void baseLayerChanged(BaseLayerChangeEvent event) {
            Layer newBaseLayer = map.getBaseLayer();
            if (!newBaseLayer.equals(baseLayers.getValue())) {
              baseLayers.select(newBaseLayer);
            }
          }
        });

    VerticalLayout vl = new VerticalLayout();
    vl.setSizeFull();
    vl.addComponent(l1);
    vl.addComponent(baseLayers);
    vl.addComponent(map);
    vl.setExpandRatio(map, 1f);

    return vl;
  }