Search in sources :

Example 1 with TileDebug

use of ol.source.TileDebug in project gwt-ol3 by TDesjardins.

the class OsmExample 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 debug layer
    TileDebugOptions tileDebugOptions = OLFactory.createOptions();
    tileDebugOptions.setProjection("EPSG:3857");
    tileDebugOptions.setTileGrid(osmSource.getTileGrid());
    TileDebug tileDebugSource = new TileDebug(tileDebugOptions);
    LayerOptions tileDebugLayerOptions = OLFactory.createOptions();
    tileDebugLayerOptions.setSource(tileDebugSource);
    Tile tileDebugLayer = new Tile(tileDebugLayerOptions);
    // create a view
    View view = new View();
    Coordinate centerCoordinate = OLFactory.createCoordinate(-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);
    map.addLayer(tileDebugLayer);
    // 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(new KeyboardPan());
    map.addInteraction(new KeyboardZoom());
}
Also used : XyzOptions(ol.source.XyzOptions) 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) TileDebug(ol.source.TileDebug) Coordinate(ol.Coordinate) KeyboardZoom(ol.interaction.KeyboardZoom) TileDebugOptions(ol.source.TileDebugOptions) Map(ol.Map)

Aggregations

Coordinate (ol.Coordinate)1 Map (ol.Map)1 MapOptions (ol.MapOptions)1 View (ol.View)1 Attribution (ol.control.Attribution)1 KeyboardPan (ol.interaction.KeyboardPan)1 KeyboardZoom (ol.interaction.KeyboardZoom)1 LayerOptions (ol.layer.LayerOptions)1 Tile (ol.layer.Tile)1 Osm (ol.source.Osm)1 TileDebug (ol.source.TileDebug)1 TileDebugOptions (ol.source.TileDebugOptions)1 XyzOptions (ol.source.XyzOptions)1