UNPKG

1.12 kBJavaScriptView Raw
1goog.require('ol.Map');
2goog.require('ol.View');
3goog.require('ol.format.MVT');
4goog.require('ol.layer.VectorTile');
5goog.require('ol.source.VectorTile');
6goog.require('ol.style.Fill');
7goog.require('ol.style.Icon');
8goog.require('ol.style.Stroke');
9goog.require('ol.style.Style');
10goog.require('ol.style.Text');
11
12
13var key = 'pk.eyJ1IjoiYWhvY2V2YXIiLCJhIjoiRk1kMWZaSSJ9.E5BkluenyWQMsBLsuByrmg';
14
15var 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});