1 | goog.require('ol.Map');
|
2 | goog.require('ol.View');
|
3 | goog.require('ol.format.MVT');
|
4 | goog.require('ol.layer.VectorTile');
|
5 | goog.require('ol.source.VectorTile');
|
6 | goog.require('ol.style.Fill');
|
7 | goog.require('ol.style.Icon');
|
8 | goog.require('ol.style.Stroke');
|
9 | goog.require('ol.style.Style');
|
10 | goog.require('ol.style.Text');
|
11 |
|
12 |
|
13 | var key = 'pk.eyJ1IjoiYWhvY2V2YXIiLCJhIjoiRk1kMWZaSSJ9.E5BkluenyWQMsBLsuByrmg';
|
14 |
|
15 | var map = new ol.Map({
|
16 | layers: [
|
17 | new ol.layer.VectorTile({
|
18 | declutter: true,
|
19 | source: new ol.source.VectorTile({
|
20 | attributions: '© <a href="https://www.mapbox.com/map-feedback/">Mapbox</a> ' +
|
21 | '© <a href="https://www.openstreetmap.org/copyright">' +
|
22 | 'OpenStreetMap contributors</a>',
|
23 | format: new ol.format.MVT(),
|
24 | url: 'https://{a-d}.tiles.mapbox.com/v4/mapbox.mapbox-streets-v6/' +
|
25 | '{z}/{x}/{y}.vector.pbf?access_token=' + key
|
26 | }),
|
27 | style: createMapboxStreetsV6Style(ol.style.Style, ol.style.Fill, ol.style.Stroke, ol.style.Icon, ol.style.Text)
|
28 | })
|
29 | ],
|
30 | target: 'map',
|
31 | view: new ol.View({
|
32 | center: [0, 0],
|
33 | zoom: 2
|
34 | })
|
35 | });
|