Search in sources :

Example 1 with KeyboardZoom

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

the class GeoJsonExample method show.

/* (non-Javadoc)
     * @see de.desjardins.ol3.demo.client.example.Example#show() */
@Override
public void show(String exampleId) {
    // create linestring
    Coordinate coordinate1 = new Coordinate(4e6, 2e6);
    Coordinate coordinate2 = new Coordinate(8e6, -2e6);
    Coordinate[] coordinates = { coordinate1, coordinate2 };
    LineString lineString = new LineString(coordinates);
    // create feature
    FeatureOptions featureOptions = new FeatureOptions();
    featureOptions.setGeometry(lineString);
    Feature feature = new Feature(featureOptions);
    // convert feature to GeoJSON
    GeoJson geoJsonFormat = new GeoJson();
    java.lang.Object geoJson = geoJsonFormat.writeFeatureObject(feature, null);
    // convert features from GeoJSON
    Feature featureGeoJson = geoJsonFormat.readFeature(geoJson, null);
    // show converted features
    Collection<Feature> lstFeatures = new Collection<Feature>();
    lstFeatures.push(featureGeoJson);
    VectorOptions vectorSourceOptions = new VectorOptions();
    vectorSourceOptions.setFeatures(lstFeatures);
    Vector vectorSource = new Vector(vectorSourceOptions);
    VectorLayerOptions vectorLayerOptions = new VectorLayerOptions();
    vectorLayerOptions.setSource(vectorSource);
    ol.layer.Vector vectorLayer = new ol.layer.Vector(vectorLayerOptions);
    // create a OSM-layer
    XyzOptions osmSourceOptions = new XyzOptions();
    Osm osmSource = new Osm(osmSourceOptions);
    LayerOptions osmLayerOptions = new LayerOptions();
    osmLayerOptions.setSource(osmSource);
    Tile osmLayer = new Tile(osmLayerOptions);
    // create a view
    View view = new View();
    Coordinate centerCoordinate = new Coordinate(0, 0);
    view.setCenter(centerCoordinate);
    view.setZoom(2);
    // create the map
    MapOptions mapOptions = new MapOptions();
    mapOptions.setTarget(exampleId);
    mapOptions.setView(view);
    Collection<Base> lstLayer = new Collection<Base>();
    lstLayer.push(osmLayer);
    lstLayer.push(vectorLayer);
    mapOptions.setLayers(lstLayer);
    Map map = new Map(mapOptions);
    // 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) GeoJson(ol.format.GeoJson) Feature(ol.Feature) LayerOptions(ol.layer.LayerOptions) VectorLayerOptions(ol.layer.VectorLayerOptions) FeatureOptions(ol.FeatureOptions) Vector(ol.source.Vector) Osm(ol.source.Osm) Tile(ol.layer.Tile) View(ol.View) Base(ol.layer.Base) VectorLayerOptions(ol.layer.VectorLayerOptions) Coordinate(ol.Coordinate) LineString(ol.geom.LineString) KeyboardZoom(ol.interaction.KeyboardZoom) Collection(ol.Collection) Map(ol.Map) VectorOptions(ol.source.VectorOptions)

Example 2 with KeyboardZoom

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

the class MapGuideExample 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("EPSG:4326");
    // create a MapGuide params
    ImageMapGuideParams imageMapGuideParams = new ImageMapGuideParams();
    imageMapGuideParams.setFormat("PNG");
    imageMapGuideParams.setMapDefinition("Library://Public/Samples/Sheboygan/Maps/Sheboygan.MapDefinition");
    imageMapGuideParams.setUserName("OpenLayers");
    imageMapGuideParams.setPassword("OpenLayers");
    // create a MapGuide image
    ImageMapGuideOptions imageMapGuideOptions = new ImageMapGuideOptions();
    imageMapGuideOptions.setParams(imageMapGuideParams);
    imageMapGuideOptions.setUrl("http://www.buoyshark.com/mapguide/mapagent/mapagent.fcgi?");
    imageMapGuideOptions.setUseOverlay(false);
    imageMapGuideOptions.setMetersPerUnit(111319.4908d);
    imageMapGuideOptions.setRatio(2.0f);
    ImageMapGuide imageMapGuideSource = new ImageMapGuide(imageMapGuideOptions);
    LayerOptions layerOptions = new LayerOptions();
    Extent bounds = new Extent(-87.865114442365922d, 43.665065564837931d, -87.595394059497067d, 43.823852564430069d);
    layerOptions.setExtent(bounds);
    layerOptions.setSource(imageMapGuideSource);
    Image mapGuideLayer = new Image(layerOptions);
    // create a view
    ViewOptions viewOptions = new ViewOptions();
    viewOptions.setProjection(projection);
    viewOptions.setZoom(12.0d);
    Coordinate centerCoordinate = new Coordinate(-87.7302542509315d, 43.744459064634d);
    viewOptions.setCenter(centerCoordinate);
    View view = new View(viewOptions);
    // create the map
    MapOptions mapOptions = new MapOptions();
    mapOptions.setTarget(exampleId);
    mapOptions.setView(view);
    Collection<Base> lstLayer = new Collection<Base>();
    lstLayer.push(mapGuideLayer);
    mapOptions.setLayers(lstLayer);
    Map map = new Map(mapOptions);
    // 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) Rotate(ol.control.Rotate) Extent(ol.Extent) MapOptions(ol.MapOptions) ViewOptions(ol.ViewOptions) Projection(ol.proj.Projection) Image(ol.layer.Image) LayerOptions(ol.layer.LayerOptions) View(ol.View) ImageMapGuideParams(ol.source.ImageMapGuideParams) Base(ol.layer.Base) ImageMapGuideOptions(ol.source.ImageMapGuideOptions) ImageMapGuide(ol.source.ImageMapGuide) Coordinate(ol.Coordinate) KeyboardZoom(ol.interaction.KeyboardZoom) Collection(ol.Collection) Map(ol.Map)

Example 3 with KeyboardZoom

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

the class MarkerExample method show.

/* (non-Javadoc)
     * @see de.desjardins.ol3.demo.client.example.Example#show() */
@Override
public void show(String exampleId) {
    // create a point
    Coordinate coordinate1 = OLFactory.createCoordinate(4e6, 2e6);
    Point point1 = new Point(coordinate1);
    // create feature
    FeatureOptions featureOptions = OLFactory.createOptions();
    featureOptions.setGeometry(point1);
    Feature feature = new Feature(featureOptions);
    Collection<Feature> features = new Collection<Feature>();
    features.push(feature);
    // create source
    VectorOptions vectorSourceOptions = OLFactory.createOptions();
    vectorSourceOptions.setFeatures(features);
    Vector vectorSource = new Vector(vectorSourceOptions);
    // create style
    StyleOptions styleOptions = new StyleOptions();
    IconOptions iconOptions = new IconOptions();
    iconOptions.setSrc("https://openlayers.org/en/v3.20.1/examples/data/icon.png");
    Icon icon = new Icon(iconOptions);
    styleOptions.setImage(icon);
    Style style = new Style(styleOptions);
    VectorLayerOptions vectorLayerOptions = OLFactory.createOptions();
    vectorLayerOptions.setSource(vectorSource);
    vectorLayerOptions.setStyle(style);
    ol.layer.Vector vectorLayer = new ol.layer.Vector(vectorLayerOptions);
    // 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(0, 0);
    view.setCenter(centerCoordinate);
    view.setZoom(2);
    // create the map
    MapOptions mapOptions = new MapOptions();
    mapOptions.setTarget(exampleId);
    mapOptions.setView(view);
    Collection<Base> lstLayer = new Collection<Base>();
    lstLayer.push(osmLayer);
    lstLayer.push(vectorLayer);
    mapOptions.setLayers(lstLayer);
    Map map = new Map(mapOptions);
    // 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) Feature(ol.Feature) LayerOptions(ol.layer.LayerOptions) VectorLayerOptions(ol.layer.VectorLayerOptions) FeatureOptions(ol.FeatureOptions) IconOptions(ol.style.IconOptions) Style(ol.style.Style) Vector(ol.source.Vector) Osm(ol.source.Osm) StyleOptions(ol.style.StyleOptions) Tile(ol.layer.Tile) Point(ol.geom.Point) View(ol.View) Base(ol.layer.Base) VectorLayerOptions(ol.layer.VectorLayerOptions) Coordinate(ol.Coordinate) KeyboardZoom(ol.interaction.KeyboardZoom) Collection(ol.Collection) Icon(ol.style.Icon) Map(ol.Map) VectorOptions(ol.source.VectorOptions)

Example 4 with KeyboardZoom

use of ol.interaction.KeyboardZoom 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)

Example 5 with KeyboardZoom

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

the class TileWmsExample method show.

/*
	 * (non-Javadoc)
	 * 
	 * @see de.desjardins.ol3.demo.client.example.Example#show()
	 */
@Override
public void show(String exampleId) {
    TileWmsParams params = new TileWmsParams();
    params.setLayers("topp:states");
    params.setTiled(true);
    TileWmsOptions options = new TileWmsOptions();
    options.setUrl("https://ahocevar.com/geoserver/wms");
    options.setParams(params);
    options.setServerType(WmsServerType.GEOSERVER);
    TileWms source = new TileWms(options);
    Extent extent = new Extent(-13884991, 2870341, -7455066, 6338219);
    Tile layer = new Tile();
    layer.setExtent(extent);
    layer.setSource(source);
    Coordinate centerCoordinate = new Coordinate(-10997148, 4569099);
    View view = new View();
    view.setCenter(centerCoordinate);
    view.setZoom(4);
    // create the map
    MapOptions mapOptions = new MapOptions();
    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 : TileWmsOptions(ol.source.TileWmsOptions) ScaleLine(ol.control.ScaleLine) KeyboardPan(ol.interaction.KeyboardPan) Rotate(ol.control.Rotate) Extent(ol.Extent) MapOptions(ol.MapOptions) Tile(ol.layer.Tile) View(ol.View) Coordinate(ol.Coordinate) TileWms(ol.source.TileWms) KeyboardZoom(ol.interaction.KeyboardZoom) TileWmsParams(ol.source.TileWmsParams) Map(ol.Map)

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