OpenLayers 2 Add-on
OpenLayers 2 add-on for Vaadin 7
This add-on is a port of the excellent OpenLayers Wrapper add-on for Vaadin 6. It implements all of the same features as the Vaadin 6 version.
This add-on contains server side wrapper component for an OpenLayers 2 Map. It also provides API's for different types of layers.
The integration is built on its own GWT wrappers around OpenLayers javascript API. The GWT part is designed so that the add-on can also be used in plain GWT applications without Vaadin.
Some of the most essential features listed below:
- Multiple base layers (E.g. WMS, TMS, Google maps, VirtualEarth (aka Bing), OpenStreetMap)
- VectorLayer (Points, Areas, Lines, drawing, editing and styling either explicitly or via StyleMaps)
- Popups
- MarkerLayer (Users can start using VectorLayer instead. Also with plain OpenLayers)
The client side implementation is based on GWT's JavaScript overlays. Extending the API to any of OpenLayers features should be rather straightforward. Contributions, feature requests and bug reports are welcome via the Github project page.
Sample code
import com.vaadin.annotations.JavaScript; import com.vaadin.annotations.Theme; import com.vaadin.annotations.Title; import com.vaadin.annotations.VaadinServletConfiguration; import com.vaadin.server.VaadinRequest; import com.vaadin.server.VaadinServlet; import com.vaadin.ui.UI; import javax.servlet.annotation.WebServlet; import org.vaadin.vol.OpenLayersMap; import org.vaadin.vol.OpenStreetMapLayer; @Theme("demo") @Title("OpenLayers 2 Add-on Demo") @JavaScript({"http://openlayers.org/api/2.13/OpenLayers.js", "http://www.openstreetmap.org/openlayers/OpenStreetMap.js"}) @SuppressWarnings("serial") public class DemoUI extends UI { @WebServlet(value = "/*", asyncSupported = true) @VaadinServletConfiguration(productionMode = false, ui = DemoUI.class, widgetset = "org.vaadin.vol.demo.DemoWidgetSet") public static class Servlet extends VaadinServlet { } @Override protected void init(VaadinRequest request) { // Initialize our new UI component final OpenLayersMap map = new OpenLayersMap(); map.setApiProjection("EPSG:4326"); map.setSizeFull(); // base layers OpenStreetMapLayer osmLayer = new OpenStreetMapLayer(); //osmLayer.setUrl("http://b.tile.openstreetmap.org/${z}/${x}/${y}.png"); osmLayer.setDisplayName("OSM"); map.addLayer(osmLayer); map.setBaseLayer(osmLayer); map.setCenter(146.9417, -42.0429); map.setZoom(7); setContent(map); } }
Links
Compatibility
Was this helpful? Need more help?
Leave a comment or a question below. You can also join
the chat on Discord or
ask questions on StackOverflow.
Version
Fixed issue with zoom and center on same location values
- Released
- 2016-02-01
- Maturity
- BETA
- License
- Apache License 2.0
Compatibility
- Framework
- Vaadin 7.6+
- Browser
- Firefox
- Safari
- Google Chrome
- iOS Browser
- Android Browser
- Internet Explorer
- Internet Explorer
OpenLayers 2 Add-on - Vaadin Add-on Directory
OpenLayers 2 add-on for Vaadin 7Issue Tracker
Source Code
Discussion Forum
OpenLayers 2 Add-on version 2.0.0
Initial port of Vaadin 6 add-on
OpenLayers 2 Add-on version 2.0.1
Added Vaadin 7.6 context menus to markers
OpenLayers 2 Add-on version 2.0.2
Fixed issue with zoom and center on same location values
OpenLayers 2 Add-on version 2.0.3
Limit scope of context click event for markers to the markers themselves