private void addBaseLayer(OpenLayersMap openLayersMap) { openLayersMap.addLayer(new OpenStreetMapLayer()); vectorLayer = new VectorLayer(); openLayersMap.addLayer(vectorLayer); openLayersMap.addActionHandler(this); openLayersMap.setImmediate(true); // to get extent eagerly, used to draw // relatively sized squares this.openLayersMap = openLayersMap; }
@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; }
@Override public Component getTestComponent() { OpenLayersMap map = new OpenLayersMap(); map.setCenter(22.30, 60.452); // NOTE, DO NOT USE THIS API KEY IN YOUR OWN APP!! This API key is only // for demos (at matti.virtuallypreinstalled.com) and testing of the // addon. Register your own in // https://www.bingmapsportal.com for (BingMapLayer.Type t : BingMapLayer.Type.values()) { BingMapLayer bingMapLayer = new BingMapLayer("AhzA29X4AedR8DapHQylLbWF1I-K_n7rpKjIsnagYt1ssp4Nz1Rx7Nf0UN_KWfuH"); bingMapLayer.setType(t); bingMapLayer.setDisplayName(t.toString()); map.addLayer(bingMapLayer); } map.setSizeFull(); return map; }
@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; }
public TrackingScreen() { setMargin(true); setSpacing(true); setSizeFull(); VerticalLayout vl = new VerticalLayout(); vl.setSizeUndefined(); final SatelliteTable table = new SatelliteTable( new String[] {"catalogNumber", "commonName"}, new String[] {"Catalog Number", "Common Name"}, 10); table.setSizeUndefined(); vl.addComponent(table); Button compute = new Button( "Track", new Button.ClickListener() { private static final long serialVersionUID = -2433152978338766513L; public void buttonClick(ClickEvent event) { if (table.getValue() == null) { return; } Item item = table.getItem(table.getValue()); Long id = (Long) item.getItemProperty("catalogNumber").getValue(); Satellite sat = satService.getSatellite(id); TleEntry entry = satService.getLatestTleEntry(sat); vectorLayer.removeAllComponents(); markerLayer.removeAllComponents(); try { TLE tle = new TLE(entry.getLine1(), entry.getLine2()); AbsoluteDate startDate = new AbsoluteDate(new Date(), TimeScalesFactory.getUTC()); double period = sat.getPeriod(); double iterations = 2; long step = period > 100 ? 180 : 90; BoundedPropagator boundedProp = SatellitePropagation.getEphemeris( tle, startDate.shiftedBy(-60 * 30), 60L * period * iterations, step); currentTracker = new Tracker(boundedProp); AbsoluteDate date = currentTracker.getStartDate(); List<Point> points = new LinkedList<Point>(); double lastLon = 0d; while (date.compareTo(currentTracker.getEndDate()) < 0) { GeodeticPoint gp = currentTracker.getPoint(date); double lat = Math.toDegrees(gp.getLatitude()); double lon = Math.toDegrees(gp.getLongitude()); if (lastLon > 0 && lon < 0) { Vector line = new PolyLine(); line.setPoints(points.toArray(new Point[points.size()])); vectorLayer.addVector(line); points.clear(); } points.add(new Point(lon, lat)); lastLon = lon; date = date.shiftedBy(step); } Vector line = new PolyLine(); line.setPoints(points.toArray(new Point[points.size()])); vectorLayer.addVector(line); GeodeticPoint gp = currentTracker.getPoint(startDate); double lat = Math.toDegrees(gp.getLatitude()); double lon = Math.toDegrees(gp.getLongitude()); marker = new Marker(lon, lat); // URL of marker Icon marker.setIcon("images/satellite_48_hot.png", 24, 24); markerLayer.addMarker(marker); } catch (Exception e) { e.printStackTrace(); } } }); compute.setWidth("100%"); compute.addStyleName(Runo.BUTTON_DEFAULT); compute.addStyleName(Runo.BUTTON_BIG); vl.addComponent(compute); addComponent(vl); OpenLayersMap map = new OpenLayersMap(); map.setSizeFull(); map.setImmediate(true); // update extent and zoom to server as they change OpenStreetMapLayer osm = new OpenStreetMapLayer(); map.addLayer(osm); vectorLayer = new VectorLayer(); vectorLayer.setSelectionMode(SelectionMode.NONE); Style defaultStyle = new Style(); /* Set stroke color to green, otherwise like default style */ defaultStyle.extendCoreStyle("default"); defaultStyle.setStrokeColor("#00b963"); defaultStyle.setStrokeOpacity(0.5); defaultStyle.setStrokeWidth(1); Style selectStyle = new Style(); /* Set select color to blue, otherwise like default style */ selectStyle.extendCoreStyle("default"); selectStyle.setStrokeColor("#0063b9"); selectStyle.setStrokeOpacity(0.5); selectStyle.setStrokeWidth(1); StyleMap styleMap = new StyleMap(defaultStyle, selectStyle, null); // make selectStyle inherit attributes not explicitly set styleMap.setExtendDefault(true); vectorLayer.setStyleMap(styleMap); vectorLayer.setDrawindMode(DrawingMode.NONE); map.addLayer(vectorLayer); // Define a Marker Layer markerLayer = new MarkerLayer(); map.addLayer(markerLayer); addComponent(map); setExpandRatio(map, 1); Refresher r = new Refresher(); r.setRefreshInterval(1000); r.addListener( new RefreshListener() { private static final long serialVersionUID = 2875834508560395285L; @Override public void refresh(Refresher source) { if (marker != null && currentTracker != null) { try { AbsoluteDate currentDate = new AbsoluteDate(new Date(), TimeScalesFactory.getUTC()); GeodeticPoint gp = currentTracker.getPoint(currentDate); double lat = Math.toDegrees(gp.getLatitude()); double lon = Math.toDegrees(gp.getLongitude()); marker.setLon(lon); marker.setLat(lat); } catch (OrekitException e) { e.printStackTrace(); } } } }); addComponent(r); }