Search in sources :

Example 1 with VectorTileOptions

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

the class MvtExample method show.

/* (non-Javadoc)
     * @see de.desjardins.ol3.demo.client.example.Example#show()
     */
@Override
public void show(String exampleId) {
    VectorTileOptions vectorTileOptions = new VectorTileOptions();
    vectorTileOptions.setFormat(new Mvt());
    vectorTileOptions.setUrl("https://{a-d}.tiles.mapbox.com/v4/mapbox.mapbox-streets-v6/{z}/{x}/{y}.vector.pbf?access_token=" + ACCESS_TOKEN);
    vectorTileOptions.setAttributions("© <a href=\"https://www.mapbox.com/map-feedback/\">Mapbox</a> © <a href=\"https://www.openstreetmap.org/copyright\">OpenStreetMap contributors</a>'");
    VectorTile vectorTile = new VectorTile(vectorTileOptions);
    VectorTileLayerOptions tileLayerOptions = new VectorTileLayerOptions();
    tileLayerOptions.setSource(vectorTile);
    ol.layer.VectorTile mvtLayer = new ol.layer.VectorTile(tileLayerOptions);
    // 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);
    Map map = new Map(mapOptions);
    ol.control.Attribution attributionControl = new ol.control.Attribution();
    attributionControl.setCollapsed(false);
    map.addControl(attributionControl);
    map.addControl(new MousePosition());
    map.addControl(DemoUtils.createMapboxLogo());
    map.addLayer(mvtLayer);
}
Also used : MapOptions(ol.MapOptions) Mvt(ol.format.Mvt) VectorTileOptions(ol.source.VectorTileOptions) VectorTileLayerOptions(ol.layer.VectorTileLayerOptions) View(ol.View) MousePosition(ol.control.MousePosition) Coordinate(ol.Coordinate) VectorTile(ol.source.VectorTile) Map(ol.Map)

Aggregations

Coordinate (ol.Coordinate)1 Map (ol.Map)1 MapOptions (ol.MapOptions)1 View (ol.View)1 MousePosition (ol.control.MousePosition)1 Mvt (ol.format.Mvt)1 VectorTileLayerOptions (ol.layer.VectorTileLayerOptions)1 VectorTile (ol.source.VectorTile)1 VectorTileOptions (ol.source.VectorTileOptions)1