public void extend(Point point) { BoundsImpl.extend(this.getJSObject(), point.getJSObject()); }
@Override public void buildPanel() { OpenLayers.setProxyHost("olproxy?targetURL="); // create some MapOptions MapOptions defaultMapOptions = new MapOptions(); defaultMapOptions.setNumZoomLevels(16); // Create a MapWidget MapWidget mapWidget = new MapWidget("500px", "500px", defaultMapOptions); // Create a WMS layer as base layer WMSParams wmsParams = new WMSParams(); wmsParams.setFormat("image/png"); wmsParams.setLayers("basic"); wmsParams.setStyles(""); WMSOptions wmsLayerParams = new WMSOptions(); wmsLayerParams.setUntiled(); wmsLayerParams.setTransitionEffect(TransitionEffect.RESIZE); String wmsUrl = "http://vmap0.tiles.osgeo.org/wms/vmap0"; WMS wmsLayer = new WMS("Basic WMS", wmsUrl, wmsParams, wmsLayerParams); Map map = mapWidget.getMap(); // Add some control to the map LayerSwitcher layerSwitcher = new LayerSwitcher(); map.addControl(layerSwitcher); // Display the LayerSwitcher map.addControl(new ScaleLine()); // Display the scaleline // Add the WMS to the map map.addLayer(wmsLayer); // Add some vectors final Point point = new Point(-110, 45); final Vector vectorLayer = new Vector("Features to Transform"); // Style for the vector final Style featureStyle = new Style(); featureStyle.setFillColor("#eeeeff"); featureStyle.setStrokeColor("#3300ff"); featureStyle.setStrokeWidth(2); featureStyle.setPointRadius(3); // Style for the rotation Handle final Style rotationHandlerStyle = new Style(); rotationHandlerStyle.setFillColor("#eeeeee"); rotationHandlerStyle.setFillOpacity(1); rotationHandlerStyle.setPointRadius(12); // create a polygon feature from a linear ring of points Point[] pointList = new Point[6]; for (int p = 0; p < 6; p++) { double a = p * (2 * Math.PI) / 7; double r = Math.random() + 1; Point newPoint = new Point(point.getX() + (r * Math.cos(a)), point.getY() + (r * Math.sin(a))); pointList[p] = newPoint; } LinearRing linearRing = new LinearRing(pointList); final Polygon polygon = new Polygon(new LinearRing[] {linearRing}); final VectorFeature polygonFeature = new VectorFeature(polygon, featureStyle); // create a VectorFeature from the polygon vectorLayer.addFeature(polygonFeature); // Create Options For the Transform Control TransformFeatureOptions transformFeatureOptions = new TransformFeatureOptions(); transformFeatureOptions.setRotate(true); transformFeatureOptions.setRotation(0); transformFeatureOptions.setRederIntent("transform"); transformFeatureOptions.setRotationHandleSymbolizer(rotationHandlerStyle); // Create The Transform Control TransformFeature transformFeature = new TransformFeature(vectorLayer, transformFeatureOptions); map.setCenter(new LonLat(point.getX(), point.getY()), 7); map.addLayer(vectorLayer); // Add and activate the control map.addControl(transformFeature); transformFeature.activate(); contentPanel.add(new HTML("<p>This example shows the transformation of a Feature.</p>")); contentPanel.add(mapWidget); initWidget(contentPanel); mapWidget .getElement() .getFirstChildElement() .getStyle() .setZIndex(0); // force the map to fall behind popups }
@Override public void buildPanel() { OpenLayers.setProxyHost("olproxy?targetURL="); // create some MapOptions MapOptions defaultMapOptions = new MapOptions(); defaultMapOptions.setNumZoomLevels(16); // Create a MapWidget MapWidget mapWidget = new MapWidget("500px", "500px", defaultMapOptions); // Create a WMS layer as base layer WMSParams wmsParams = new WMSParams(); wmsParams.setFormat("image/png"); wmsParams.setLayers("basic"); wmsParams.setStyles(""); WMSOptions wmsLayerParams = new WMSOptions(); wmsLayerParams.setUntiled(); wmsLayerParams.setTransitionEffect(TransitionEffect.RESIZE); String wmsUrl = "http://vmap0.tiles.osgeo.org/wms/vmap0"; WMS wmsLayer = new WMS("Basic WMS", wmsUrl, wmsParams, wmsLayerParams); // Add the WMS to the map Map map = mapWidget.getMap(); map.addLayer(wmsLayer); // Add some vectors final Vector vectorLayer = new Vector("Simple Geometry"); map.addLayer(vectorLayer); // create a point feature final Point point = new Point(-110, 45); // we need a Point object because this has the rotate method Style pointStyle = new Style(); pointStyle.setFillColor("blue"); pointStyle.setStrokeColor("blue"); pointStyle.setStrokeWidth(3); pointStyle.setPointRadius(6); pointStyle.setFillOpacity(0.6); final VectorFeature pointFeature = new VectorFeature(point, pointStyle); // create a VectorFeature from the rotatable Polygon vectorLayer.addFeature(pointFeature); // create a line feature Point[] linePoints = {new Point(-120, 40), new Point(-115, 45), new Point(-110, 40)}; final LineString lineString = new LineString( linePoints); // we need a LineString object because this has the rotate method final Style lineStyle = new Style(); lineStyle.setStrokeColor("#339933"); lineStyle.setStrokeWidth(3); lineStyle.setPointRadius(6); final VectorFeature lineFeature = new VectorFeature( lineString, lineStyle); // create a VectorFeature from the rotatable LineString vectorLayer.addFeature(lineFeature); // create a polygon feature from a linear ring of points Point[] pointList = new Point[6]; for (int p = 0; p < 6; p++) { double a = p * (2 * Math.PI) / 7; double r = Math.random() + 1; Point newPoint = new Point(point.getX() + (r * Math.cos(a)), point.getY() + (r * Math.sin(a))); pointList[p] = newPoint; } LinearRing linearRing = new LinearRing(pointList); final Polygon polygon = new Polygon( new LinearRing[] { linearRing }); // we need a Polygon object because this has the rotate method final VectorFeature polygonFeature = new VectorFeature(polygon, lineStyle); // create a VectorFeature from the rotatable Polygon vectorLayer.addFeature(polygonFeature); // Lets add some default controls to the map map.addControl( new LayerSwitcher()); // + sign in the upperright corner to display the layer switcher map.addControl(new OverviewMap()); // + sign in the lowerright to display the overviewmap map.addControl(new ScaleLine()); // Display the scaleline // Center and zoom to a location map.setCenter(new LonLat(point.getX(), point.getY()), 5); // start the actual rotating final Point origin = new Point(-111.04, 45.68); final Timer t = new Timer() // we just use a GWT timer to have animation, no need for special OpenLayer // timer stuff... { @Override public void run() { polygon.rotate(-360 / 20, origin); vectorLayer.drawFeature(polygonFeature, lineStyle); lineString.rotate(360 / 40, origin); vectorLayer.drawFeature(lineFeature, lineStyle); point.rotate(360 / 20, origin); vectorLayer.drawFeature(pointFeature, lineStyle); } }; t.scheduleRepeating(100); contentPanel.add( new HTML( "<p>This example shows a few features rotating. There is not yet a control built that provides a tool for rotating, but the geometry.rotate method can be accessed to rotate programmatically.</p>")); contentPanel.add(mapWidget); initWidget(contentPanel); mapWidget .getElement() .getFirstChildElement() .getStyle() .setZIndex(0); // force the map to fall behind popups }