36 lines
1.1 KiB
JavaScript
36 lines
1.1 KiB
JavaScript
goog.require('ol.Map');
|
|
goog.require('ol.View');
|
|
goog.require('ol.format.MVT');
|
|
goog.require('ol.layer.VectorTile');
|
|
goog.require('ol.source.VectorTile');
|
|
goog.require('ol.style.Fill');
|
|
goog.require('ol.style.Icon');
|
|
goog.require('ol.style.Stroke');
|
|
goog.require('ol.style.Style');
|
|
goog.require('ol.style.Text');
|
|
|
|
|
|
var key = 'pk.eyJ1IjoiYWhvY2V2YXIiLCJhIjoiRk1kMWZaSSJ9.E5BkluenyWQMsBLsuByrmg';
|
|
|
|
var map = new ol.Map({
|
|
layers: [
|
|
new ol.layer.VectorTile({
|
|
declutter: true,
|
|
source: new ol.source.VectorTile({
|
|
attributions: '© <a href="https://www.mapbox.com/map-feedback/">Mapbox</a> ' +
|
|
'© <a href="https://www.openstreetmap.org/copyright">' +
|
|
'OpenStreetMap contributors</a>',
|
|
format: new ol.format.MVT(),
|
|
url: 'https://{a-d}.tiles.mapbox.com/v4/mapbox.mapbox-streets-v6/' +
|
|
'{z}/{x}/{y}.vector.pbf?access_token=' + key
|
|
}),
|
|
style: createMapboxStreetsV6Style(ol.style.Style, ol.style.Fill, ol.style.Stroke, ol.style.Icon, ol.style.Text)
|
|
})
|
|
],
|
|
target: 'map',
|
|
view: new ol.View({
|
|
center: [0, 0],
|
|
zoom: 2
|
|
})
|
|
});
|