Search in sources :

Example 6 with KeyboardPan

use of ol.interaction.KeyboardPan in project gwt-ol3 by TDesjardins.

the class WmsExample method show.

/* (non-Javadoc)
     * @see de.desjardins.ol3.demo.client.example.Example#show()
     */
@Override
public void show(String exampleId) {
    ImageWmsParams imageWMSParams = OLFactory.createOptions();
    imageWMSParams.setLayers("ch.swisstopo.geologie-geotechnik-gk500-gesteinsklassierung,ch.bafu.schutzgebiete-paerke_nationaler_bedeutung");
    ImageWmsOptions imageWMSOptions = OLFactory.createOptions();
    imageWMSOptions.setUrl("http://wms.geo.admin.ch/");
    imageWMSOptions.setParams(imageWMSParams);
    imageWMSOptions.setRatio(1.5f);
    ImageWms imageWMSSource = new ImageWms(imageWMSOptions);
    LayerOptions layerOptions = OLFactory.createOptions();
    layerOptions.setSource(imageWMSSource);
    Image wmsLayer = new Image(layerOptions);
    // create a projection
    ProjectionOptions projectionOptions = OLFactory.createOptions();
    projectionOptions.setCode("EPSG:21781");
    projectionOptions.setUnits("m");
    Projection projection = new Projection(projectionOptions);
    // create a view
    ViewOptions viewOptions = OLFactory.createOptions();
    viewOptions.setProjection(projection);
    View view = new View(viewOptions);
    Coordinate centerCoordinate = new Coordinate(660000, 190000);
    view.setCenter(centerCoordinate);
    view.setZoom(9);
    // create the map
    MapOptions mapOptions = OLFactory.createOptions();
    mapOptions.setTarget(exampleId);
    mapOptions.setView(view);
    Map map = new Map(mapOptions);
    map.addLayer(wmsLayer);
    // add some controls
    map.addControl(new ScaleLine());
    DemoUtils.addDefaultControls(map.getControls());
    // add some interactions
    map.addInteraction(new KeyboardPan());
    map.addInteraction(new KeyboardZoom());
    map.addControl(new Rotate());
}
Also used : ScaleLine(ol.control.ScaleLine) KeyboardPan(ol.interaction.KeyboardPan) ImageWmsOptions(ol.source.ImageWmsOptions) Rotate(ol.control.Rotate) MapOptions(ol.MapOptions) ViewOptions(ol.ViewOptions) Projection(ol.proj.Projection) Image(ol.layer.Image) LayerOptions(ol.layer.LayerOptions) View(ol.View) Coordinate(ol.Coordinate) KeyboardZoom(ol.interaction.KeyboardZoom) ImageWmsParams(ol.source.ImageWmsParams) ProjectionOptions(ol.proj.ProjectionOptions) Map(ol.Map) ImageWms(ol.source.ImageWms)

Example 7 with KeyboardPan

use of ol.interaction.KeyboardPan in project gwt-ol3 by TDesjardins.

the class MapEventsExample 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 = new Coordinate(-0.1275, 51.507222);
    Coordinate transformedCenterCoordinate = Projection.transform(centerCoordinate, DemoConstants.EPSG_4326, DemoConstants.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(new ScaleLine());
    DemoUtils.addDefaultControls(map.getControls());
    Attribution attribution = new Attribution();
    attribution.setCollapsed(true);
    map.addControl(attribution);
    // clear default interactions
    map.getInteractions().clear();
    // add some interactions
    map.addInteraction(new DragPan());
    map.addInteraction(new KeyboardPan());
    map.addInteraction(new KeyboardZoom());
    map.addInteraction(new MouseWheelZoom());
    // add event handlers
    map.addDoubleClickListener(evt -> Window.alert("double click at " + evt.getCoordinate().getX() + ", " + evt.getCoordinate().getX()));
    map.addMapZoomListener(evt -> GWT.log("onZoom"));
    map.addMapZoomEndListener(evt -> GWT.log("onMapZoomEnd"));
}
Also used : XyzOptions(ol.source.XyzOptions) ScaleLine(ol.control.ScaleLine) KeyboardPan(ol.interaction.KeyboardPan) MapOptions(ol.MapOptions) Osm(ol.source.Osm) Tile(ol.layer.Tile) LayerOptions(ol.layer.LayerOptions) View(ol.View) Attribution(ol.control.Attribution) Coordinate(ol.Coordinate) KeyboardZoom(ol.interaction.KeyboardZoom) MouseWheelZoom(ol.interaction.MouseWheelZoom) Map(ol.Map) DragPan(ol.interaction.DragPan)

Example 8 with KeyboardPan

use of ol.interaction.KeyboardPan in project gwt-ol3 by TDesjardins.

the class MeasureExample 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 = OLFactory.createView();
    Coordinate centerCoordinate = new Coordinate(-0.1275, 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(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());
    // add measurement functionality to the map
    final Measure measure = new Measure(map);
    // start measuring immediately
    measure.startMeasureLength(new MeasureListener() {

        @Override
        public void onMeasure(MeasureEvent evt) {
            // log the measured length
            GWT.log("measure: " + evt.getMeasure());
        }
    }, true, true);
}
Also used : XyzOptions(ol.source.XyzOptions) ScaleLine(ol.control.ScaleLine) KeyboardPan(ol.interaction.KeyboardPan) MapOptions(ol.MapOptions) Osm(ol.source.Osm) Tile(ol.layer.Tile) LayerOptions(ol.layer.LayerOptions) View(ol.View) Attribution(ol.control.Attribution) MeasureListener(ol.event.MeasureListener) Coordinate(ol.Coordinate) KeyboardZoom(ol.interaction.KeyboardZoom) Measure(ol.gwt.Measure) MeasureEvent(ol.event.MeasureEvent) Map(ol.Map)

Example 9 with KeyboardPan

use of ol.interaction.KeyboardPan in project gwt-ol3 by TDesjardins.

the class WmtsExample method show.

/* (non-Javadoc)
     * @see de.desjardins.ol3.demo.client.example.Example#show()
     */
@Override
public void show(String exampleId) {
    // create a projection
    Projection projection = Projection.get(DemoConstants.EPSG_3857);
    // 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);
    WmtsOptions wmtsOptions = OLFactory.createOptions();
    wmtsOptions.setUrl("https://services.arcgisonline.com/arcgis/rest/services/Demographics/USA_Population_Density/MapServer/WMTS/");
    wmtsOptions.setLayer("0");
    wmtsOptions.setFormat("image/png");
    wmtsOptions.setMatrixSet(DemoConstants.EPSG_3857);
    wmtsOptions.setStyle("default");
    wmtsOptions.setProjection(projection);
    wmtsOptions.setWrapX(true);
    wmtsOptions.setTileGrid(this.createWmtsTileGrid(projection));
    // create attribution
    wmtsOptions.setAttributions("Tiles &copy; <a href=\"http://services.arcgisonline.com/arcgis/rest/services/Demographics/USA_Population_Density/MapServer/\">ArcGIS</a>");
    Wmts wmtsSource = new Wmts(wmtsOptions);
    LayerOptions wmtsLayerOptions = OLFactory.createOptions();
    wmtsLayerOptions.setSource(wmtsSource);
    Tile wmtsLayer = new Tile(wmtsLayerOptions);
    wmtsLayer.setOpacity(0.7);
    // create a view
    ViewOptions viewOptions = OLFactory.createOptions();
    viewOptions.setProjection(projection);
    View view = new View(viewOptions);
    Coordinate centerCoordinate = new Coordinate(-11158582, 4813697);
    view.setCenter(centerCoordinate);
    view.setZoom(4);
    // create the map
    MapOptions mapOptions = OLFactory.createOptions();
    mapOptions.setTarget(exampleId);
    mapOptions.setView(view);
    Map map = new Map(mapOptions);
    // add layers
    map.addLayer(osmLayer);
    map.addLayer(wmtsLayer);
    // add some controls
    map.addControl(new ScaleLine());
    DemoUtils.addDefaultControls(map.getControls());
    // add some interactions
    map.addInteraction(new KeyboardPan());
    map.addInteraction(new KeyboardZoom());
    map.addControl(new Rotate());
}
Also used : XyzOptions(ol.source.XyzOptions) ScaleLine(ol.control.ScaleLine) KeyboardPan(ol.interaction.KeyboardPan) Rotate(ol.control.Rotate) MapOptions(ol.MapOptions) ViewOptions(ol.ViewOptions) Osm(ol.source.Osm) Projection(ol.proj.Projection) Tile(ol.layer.Tile) LayerOptions(ol.layer.LayerOptions) View(ol.View) WmtsOptions(ol.source.WmtsOptions) Coordinate(ol.Coordinate) KeyboardZoom(ol.interaction.KeyboardZoom) Wmts(ol.source.Wmts) Map(ol.Map)

Example 10 with KeyboardPan

use of ol.interaction.KeyboardPan in project gwt-ol3 by TDesjardins.

the class ArcGISExample method show.

/* (non-Javadoc)
     * @see de.desjardins.ol3.demo.client.example.Example#show() */
@Override
public void show(String exampleId) {
    ImageArcGisRestParams params = new ImageArcGisRestParams();
    params.showLayers("2");
    ImageArcGisRestOptions options = new ImageArcGisRestOptions();
    options.setUrl("https://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StateCityHighway_USA/MapServer");
    options.setParams(params);
    options.setRatio(1f);
    ImageArcGisRest source = new ImageArcGisRest(options);
    LayerOptions layerOptions = OLFactory.createOptions();
    layerOptions.setSource(source);
    Image layer = new Image(layerOptions);
    // create a view
    View view = new View();
    Coordinate center = OLFactory.createCoordinate(-10997148, 4569099);
    view.setCenter(center);
    view.setZoom(4);
    // create the map
    MapOptions mapOptions = OLFactory.createOptions();
    mapOptions.setTarget(exampleId);
    mapOptions.setView(view);
    Map map = new Map(mapOptions);
    map.addLayer(layer);
    // add some controls
    map.addControl(new ScaleLine());
    DemoUtils.addDefaultControls(map.getControls());
    // add some interactions
    map.addInteraction(new KeyboardPan());
    map.addInteraction(new KeyboardZoom());
    map.addControl(new Rotate());
}
Also used : ImageArcGisRest(ol.source.ImageArcGisRest) ScaleLine(ol.control.ScaleLine) KeyboardPan(ol.interaction.KeyboardPan) Rotate(ol.control.Rotate) MapOptions(ol.MapOptions) Image(ol.layer.Image) LayerOptions(ol.layer.LayerOptions) View(ol.View) Coordinate(ol.Coordinate) KeyboardZoom(ol.interaction.KeyboardZoom) ImageArcGisRestParams(ol.source.ImageArcGisRestParams) Map(ol.Map) ImageArcGisRestOptions(ol.source.ImageArcGisRestOptions)

Aggregations

Coordinate (ol.Coordinate)13 Map (ol.Map)13 MapOptions (ol.MapOptions)13 View (ol.View)13 KeyboardPan (ol.interaction.KeyboardPan)13 KeyboardZoom (ol.interaction.KeyboardZoom)13 ScaleLine (ol.control.ScaleLine)12 LayerOptions (ol.layer.LayerOptions)12 Tile (ol.layer.Tile)10 Rotate (ol.control.Rotate)9 Osm (ol.source.Osm)8 XyzOptions (ol.source.XyzOptions)7 Attribution (ol.control.Attribution)5 Collection (ol.Collection)4 Base (ol.layer.Base)4 VectorLayerOptions (ol.layer.VectorLayerOptions)4 VectorOptions (ol.source.VectorOptions)4 Feature (ol.Feature)3 FeatureOptions (ol.FeatureOptions)3 ViewOptions (ol.ViewOptions)3