Search in sources :

Example 6 with Projection

use of ol.proj.Projection in project gwt-ol3 by TDesjardins.

the class MousePositionTest method testMousePositionWithOptions.

public void testMousePositionWithOptions() {
    injectUrlAndTest(() -> {
        Projection projection = Projection.get("EPSG:4326");
        String undefinedHtml = "no coordinates";
        MousePositionOptions mousePositionOptions = OLFactory.createOptions();
        mousePositionOptions.setCoordinateFormat(Coordinate.createStringXY(5));
        mousePositionOptions.setProjection(projection);
        mousePositionOptions.setUndefinedHTML(undefinedHtml);
        MousePosition mousePosition = new MousePosition(mousePositionOptions);
        assertNotNull(mousePosition);
        assertTrue(mousePosition instanceof Object);
        assertTrue(mousePosition instanceof Control);
        assertNotNull(mousePosition.getProjection());
        assertEquals(projection, mousePosition.getProjection());
    });
}
Also used : Projection(ol.proj.Projection) Object(ol.Object)

Example 7 with Projection

use of ol.proj.Projection 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 8 with Projection

use of ol.proj.Projection 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 9 with Projection

use of ol.proj.Projection in project gwt-ol3 by TDesjardins.

the class StaticImageExample method show.

/* (non-Javadoc)
     * @see de.desjardins.ol3.demo.client.example.Example#show()
     */
@Override
public void show(String exampleId) {
    ProjectionOptions projectionOptions = OLFactory.createOptions();
    Extent imageExtent = new Extent(0, 0, 1024, 968);
    projectionOptions.setCode("pixel");
    projectionOptions.setExtent(imageExtent);
    projectionOptions.setUnits("pixels");
    Projection projection = new Projection(projectionOptions);
    ImageStaticOptions imageStaticOptions = OLFactory.createOptions();
    imageStaticOptions.setUrl("http://imgs.xkcd.com/comics/online_communities.png");
    imageStaticOptions.setImageSize(new Size(1024, 968));
    imageStaticOptions.setImageExtent(imageExtent);
    imageStaticOptions.setProjection(projection);
    // create attribution
    imageStaticOptions.setAttributions("&copy; <a href=\"http://xkcd.com/license.html\">xkcd</a>");
    ImageStatic imageStatic = new ImageStatic(imageStaticOptions);
    LayerOptions layerOptions = OLFactory.createOptions();
    layerOptions.setSource(imageStatic);
    Image image = new Image(layerOptions);
    Collection<Base> layers = new Collection<Base>();
    layers.push(image);
    ViewOptions viewOptions = OLFactory.createOptions();
    viewOptions.setCenter(new Coordinate(500, 500));
    viewOptions.setProjection(projection);
    viewOptions.setZoom(2);
    View view = new View(viewOptions);
    MapOptions mapOptions = OLFactory.createOptions();
    mapOptions.setTarget(exampleId);
    mapOptions.setView(view);
    mapOptions.setLayers(layers);
    Map map = new Map(mapOptions);
    // add some controls
    DemoUtils.addDefaultControls(map.getControls());
    ol.control.Attribution attributionControl = new ol.control.Attribution();
    attributionControl.setCollapsed(false);
    map.addControl(attributionControl);
}
Also used : ImageStatic(ol.source.ImageStatic) Extent(ol.Extent) MapOptions(ol.MapOptions) Size(ol.Size) ViewOptions(ol.ViewOptions) Projection(ol.proj.Projection) Image(ol.layer.Image) LayerOptions(ol.layer.LayerOptions) View(ol.View) Base(ol.layer.Base) Coordinate(ol.Coordinate) Collection(ol.Collection) ProjectionOptions(ol.proj.ProjectionOptions) ImageStaticOptions(ol.source.ImageStaticOptions) Map(ol.Map)

Aggregations

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