Search in sources :

Example 1 with OverlayOptions

use of ol.OverlayOptions in project gwt-ol3 by TDesjardins.

the class OverlayExample method show.

/* (non-Javadoc)
     * @see de.desjardins.ol3.demo.client.example.Example#show()
     */
@Override
public void show(String exampleId) {
    // create a OSM-layer
    XyzOptions osmSourceOptions = OLFactory.createOptions();
    Osm osmSource = new Osm(osmSourceOptions);
    LayerOptions osmLayerOptions = OLFactory.createOptions();
    osmLayerOptions.setSource(osmSource);
    Tile osmLayer = new Tile(osmLayerOptions);
    // create a view
    View view = new View();
    Coordinate centerCoordinate = OLFactory.createCoordinate(2.3, 51.507222);
    Coordinate transformedCenterCoordinate = Projection.transform(centerCoordinate, "EPSG:4326", "EPSG:3857");
    view.setCenter(transformedCenterCoordinate);
    view.setZoom(10);
    // create the map
    MapOptions mapOptions = OLFactory.createOptions();
    mapOptions.setTarget(exampleId);
    mapOptions.setView(view);
    Map map = new Map(mapOptions);
    map.addLayer(osmLayer);
    // add some controls
    map.addControl(OLFactory.createScaleLine());
    DemoUtils.addDefaultControls(map.getControls());
    Attribution attribution = new Attribution();
    attribution.setCollapsed(true);
    map.addControl(attribution);
    // add some interactions
    map.addInteraction(OLFactory.createKeyboardPan());
    map.addInteraction(OLFactory.createKeyboardZoom());
    DivElement overlay = Document.get().createDivElement();
    overlay.setClassName("overlay-font");
    overlay.setInnerText("Created with GWT SDK " + GWT.getVersion());
    OverlayOptions overlayOptions = OLFactory.createOptions();
    overlayOptions.setElement(overlay);
    overlayOptions.setPosition(transformedCenterCoordinate);
    overlayOptions.setOffset(OLFactory.createPixel(-300, 0));
    map.addOverlay(new Overlay(overlayOptions));
}
Also used : XyzOptions(ol.source.XyzOptions) DivElement(com.google.gwt.dom.client.DivElement) Coordinate(ol.Coordinate) MapOptions(ol.MapOptions) OverlayOptions(ol.OverlayOptions) Osm(ol.source.Osm) Tile(ol.layer.Tile) Overlay(ol.Overlay) LayerOptions(ol.layer.LayerOptions) View(ol.View) Map(ol.Map) Attribution(ol.control.Attribution)

Aggregations

DivElement (com.google.gwt.dom.client.DivElement)1 Coordinate (ol.Coordinate)1 Map (ol.Map)1 MapOptions (ol.MapOptions)1 Overlay (ol.Overlay)1 OverlayOptions (ol.OverlayOptions)1 View (ol.View)1 Attribution (ol.control.Attribution)1 LayerOptions (ol.layer.LayerOptions)1 Tile (ol.layer.Tile)1 Osm (ol.source.Osm)1 XyzOptions (ol.source.XyzOptions)1