Search in sources :

Example 1 with StamenOptions

use of ol.source.StamenOptions in project gwt-ol3 by TDesjardins.

the class TileExample method show.

/* (non-Javadoc)
     * @see de.desjardins.ol3.demo.client.example.Example#show()
     */
@Override
public void show(String exampleId) {
    LayerOptions stamenLayerOptions = OLFactory.createOptions();
    // create a Stamen-layer
    StamenOptions stamenOptions = OLFactory.createOptions();
    stamenOptions.setLayer("watercolor");
    Stamen stamenSource = new Stamen(stamenOptions);
    stamenLayerOptions.setSource(stamenSource);
    Tile stamenLayer = new Tile(stamenLayerOptions);
    // create a view
    View view = new View();
    Coordinate centerCoordinate = OLFactory.createCoordinate(1490463, 6894388);
    view.setCenter(centerCoordinate);
    view.setZoom(10);
    // create the map
    MapOptions mapOptions = OLFactory.createOptions();
    mapOptions.setTarget(exampleId);
    mapOptions.setView(view);
    Map map = new Map(mapOptions);
    stamenLayer.setOpacity(0.5f);
    // add some controls
    map.addControl(new ScaleLine());
    DemoUtils.addDefaultControls(map.getControls());
    Attribution attribution = new Attribution();
    attribution.setCollapsed(true);
    map.addControl(attribution);
    // add some interactions
    map.addInteraction(new KeyboardPan());
    map.addInteraction(new KeyboardZoom());
    DragAndDrop dragAndDrop = new DragAndDrop();
    map.addInteraction(dragAndDrop);
    EventListener<DragAndDrop.Event> eventListener = new EventListener<DragAndDrop.Event>() {

        @Override
        public void onEvent(DragAndDrop.Event event) {
            Window.alert(String.valueOf(event.getFeatures().length));
            Window.alert(event.getProjection().getUnits());
            Window.alert(String.valueOf(event.getProjection().getMetersPerUnit()));
        }
    };
    dragAndDrop.on("addfeatures", eventListener);
    map.addControl(new Rotate());
    map.getLayers().push(stamenLayer);
}
Also used : ScaleLine(ol.control.ScaleLine) KeyboardPan(ol.interaction.KeyboardPan) Stamen(ol.source.Stamen) Rotate(ol.control.Rotate) MapOptions(ol.MapOptions) Tile(ol.layer.Tile) LayerOptions(ol.layer.LayerOptions) View(ol.View) Attribution(ol.control.Attribution) StamenOptions(ol.source.StamenOptions) DragAndDrop(ol.interaction.DragAndDrop) Coordinate(ol.Coordinate) KeyboardZoom(ol.interaction.KeyboardZoom) EventListener(ol.event.EventListener) Map(ol.Map)

Aggregations

Coordinate (ol.Coordinate)1 Map (ol.Map)1 MapOptions (ol.MapOptions)1 View (ol.View)1 Attribution (ol.control.Attribution)1 Rotate (ol.control.Rotate)1 ScaleLine (ol.control.ScaleLine)1 EventListener (ol.event.EventListener)1 DragAndDrop (ol.interaction.DragAndDrop)1 KeyboardPan (ol.interaction.KeyboardPan)1 KeyboardZoom (ol.interaction.KeyboardZoom)1 LayerOptions (ol.layer.LayerOptions)1 Tile (ol.layer.Tile)1 Stamen (ol.source.Stamen)1 StamenOptions (ol.source.StamenOptions)1