use of ol.source.VectorTile 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);
}
Aggregations