UNPKG

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