Search in sources :

Example 1 with ViewOptions

use of ol.ViewOptions 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 2 with ViewOptions

use of ol.ViewOptions 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 3 with ViewOptions

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

the class ViewTest method getTestView.

private View getTestView() {
    ProjectionOptions projectionOptions = new ProjectionOptions();
    projectionOptions.setCode("EPSG:21781");
    projectionOptions.setUnits("m");
    assertNotNull(projectionOptions);
    Projection projection = new Projection(projectionOptions);
    assertNotNull(projection);
    ViewOptions viewOptions = new ViewOptions();
    viewOptions.setProjection(projection);
    View view = new View(viewOptions);
    Coordinate centerCoordinate = new Coordinate(660000, 190000);
    view.setCenter(centerCoordinate);
    view.setZoom(9);
    return view;
}
Also used : ViewOptions(ol.ViewOptions) Projection(ol.proj.Projection) ProjectionOptions(ol.proj.ProjectionOptions) View(ol.View)

Example 4 with ViewOptions

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

the class MapTest method testMapCreation.

public void testMapCreation() {
    injectUrlAndTest(() -> {
        ProjectionOptions projectionOptions = new ProjectionOptions();
        projectionOptions.setCode("EPSG:21781");
        projectionOptions.setUnits("m");
        Projection projection = new Projection(projectionOptions);
        ViewOptions viewOptions = new ViewOptions();
        viewOptions.setProjection(projection);
        View view = new View(viewOptions);
        Coordinate centerCoordinate = new Coordinate(660000, 190000);
        view.setCenter(centerCoordinate);
        view.setZoom(9);
        final MapOptions mapOptions = new MapOptions();
        mapOptions.setTarget("map");
        mapOptions.setView(view);
        mapOptions.setLoadTilesWhileAnimating(true);
        mapOptions.setLoadTilesWhileInteracting(true);
        Map map = new Map(mapOptions);
        assertNotNull(map);
    });
}
Also used : MapOptions(ol.MapOptions) ViewOptions(ol.ViewOptions) Projection(ol.proj.Projection) ProjectionOptions(ol.proj.ProjectionOptions) View(ol.View)

Example 5 with ViewOptions

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

Aggregations

View (ol.View)7 ViewOptions (ol.ViewOptions)7 MapOptions (ol.MapOptions)6 Projection (ol.proj.Projection)6 Coordinate (ol.Coordinate)5 Map (ol.Map)5 LayerOptions (ol.layer.LayerOptions)5 ProjectionOptions (ol.proj.ProjectionOptions)4 Rotate (ol.control.Rotate)3 ScaleLine (ol.control.ScaleLine)3 KeyboardPan (ol.interaction.KeyboardPan)3 KeyboardZoom (ol.interaction.KeyboardZoom)3 Image (ol.layer.Image)3 Collection (ol.Collection)2 Extent (ol.Extent)2 Base (ol.layer.Base)2 Tile (ol.layer.Tile)2 XyzOptions (ol.source.XyzOptions)2 Size (ol.Size)1 MousePosition (ol.control.MousePosition)1