Search in sources :

Example 11 with Tile

use of ol.layer.Tile 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 12 with Tile

use of ol.layer.Tile in project gwt-ol3 by TDesjardins.

the class OverlayExample 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 = OLFactory.createCoordinate(2.3, 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(OLFactory.createScaleLine());
    DemoUtils.addDefaultControls(map.getControls());
    Attribution attribution = new Attribution();
    attribution.setCollapsed(true);
    map.addControl(attribution);
    // add some interactions
    map.addInteraction(OLFactory.createKeyboardPan());
    map.addInteraction(OLFactory.createKeyboardZoom());
    DivElement overlay = Document.get().createDivElement();
    overlay.setClassName("overlay-font");
    overlay.setInnerText("Created with GWT SDK " + GWT.getVersion());
    OverlayOptions overlayOptions = OLFactory.createOptions();
    overlayOptions.setElement(overlay);
    overlayOptions.setPosition(transformedCenterCoordinate);
    overlayOptions.setOffset(OLFactory.createPixel(-300, 0));
    map.addOverlay(new Overlay(overlayOptions));
}
Also used : XyzOptions(ol.source.XyzOptions) DivElement(com.google.gwt.dom.client.DivElement) Coordinate(ol.Coordinate) MapOptions(ol.MapOptions) OverlayOptions(ol.OverlayOptions) Osm(ol.source.Osm) Tile(ol.layer.Tile) Overlay(ol.Overlay) LayerOptions(ol.layer.LayerOptions) View(ol.View) Map(ol.Map) Attribution(ol.control.Attribution)

Example 13 with Tile

use of ol.layer.Tile 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 14 with Tile

use of ol.layer.Tile in project gwt-ol3 by TDesjardins.

the class DemoUtils method createOsmLayer.

public static Base createOsmLayer() {
    XyzOptions osmSourceOptions = OLFactory.createOptions();
    Osm osmSource = new Osm(osmSourceOptions);
    LayerOptions osmLayerOptions = OLFactory.createOptions();
    osmLayerOptions.setSource(osmSource);
    return new Tile(osmLayerOptions);
}
Also used : XyzOptions(ol.source.XyzOptions) Osm(ol.source.Osm) Tile(ol.layer.Tile) LayerOptions(ol.layer.LayerOptions)

Example 15 with Tile

use of ol.layer.Tile in project gwt-ol3 by TDesjardins.

the class ConstrainedViewExample method show.

/* (non-Javadoc)
     * @see de.desjardins.ol3.demo.client.example.Example#show()
     */
@Override
public void show(String exampleId) {
    XyzOptions xyzOptions = OLFactory.createOptions();
    xyzOptions.setUrl("http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{z}/{y}/{x}");
    xyzOptions.setAttributions("Tiles &copy; <a href=\"http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer\">ArcGIS</a>");
    Xyz xyzSource = new Xyz(xyzOptions);
    LayerOptions xyzLayerOptions = OLFactory.createOptions();
    xyzLayerOptions.setSource(xyzSource);
    Tile xyzLayer = new Tile(xyzLayerOptions);
    // create a view
    View view = new View();
    Coordinate centerCoordinate = new Coordinate(-121.1, 47.5);
    Coordinate transformedCenterCoordinate = Projection.transform(centerCoordinate, "EPSG:4326", "EPSG:3857");
    view.setCenter(transformedCenterCoordinate);
    view.setZoom(12);
    // restrict zoom
    view.setMinZoom(11);
    view.setMaxZoom(14);
    // create the map
    MapOptions mapOptions = OLFactory.createOptions();
    mapOptions.setTarget(exampleId);
    mapOptions.setView(view);
    Map map = new Map(mapOptions);
    // restrict extent
    ViewOptions viewOptions = new ViewOptions();
    viewOptions.setCenter(map.getView().getCenter());
    viewOptions.setExtent(map.getView().calculateExtent(map.getSize()));
    viewOptions.setZoom(map.getView().getZoom());
    viewOptions.setMinZoom(map.getView().getMinZoom());
    viewOptions.setMaxZoom(map.getView().getMaxZoom());
    View restrictedView = new View(viewOptions);
    map.setView(restrictedView);
    ol.control.Attribution attributionControl = new ol.control.Attribution();
    attributionControl.setCollapsed(false);
    map.addControl(attributionControl);
    MousePosition mousePosition = new MousePosition();
    mousePosition.setCoordinateFormat(Coordinate.createStringXY(2));
    map.addControl(mousePosition);
    map.addLayer(xyzLayer);
}
Also used : XyzOptions(ol.source.XyzOptions) MapOptions(ol.MapOptions) ViewOptions(ol.ViewOptions) Tile(ol.layer.Tile) LayerOptions(ol.layer.LayerOptions) View(ol.View) MousePosition(ol.control.MousePosition) Coordinate(ol.Coordinate) Xyz(ol.source.Xyz) Map(ol.Map)

Aggregations

Tile (ol.layer.Tile)19 Coordinate (ol.Coordinate)18 Map (ol.Map)18 MapOptions (ol.MapOptions)18 View (ol.View)18 LayerOptions (ol.layer.LayerOptions)18 XyzOptions (ol.source.XyzOptions)16 Osm (ol.source.Osm)14 ScaleLine (ol.control.ScaleLine)11 KeyboardPan (ol.interaction.KeyboardPan)10 KeyboardZoom (ol.interaction.KeyboardZoom)10 Collection (ol.Collection)6 Attribution (ol.control.Attribution)6 MousePosition (ol.control.MousePosition)6 Rotate (ol.control.Rotate)6 Base (ol.layer.Base)6 VectorLayerOptions (ol.layer.VectorLayerOptions)5 VectorOptions (ol.source.VectorOptions)5 Feature (ol.Feature)4 FeatureOptions (ol.FeatureOptions)4