UNPKG

openlayers

Version:

Build tools and sources for developing OpenLayers based mapping applications

43 lines (37 loc) 1.32 kB
/* eslint-disable openlayers-internal/no-unused-requires */ 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'); goog.require('ol.tilegrid'); var key = 'pk.eyJ1IjoiYWhvY2V2YXIiLCJhIjoiRk1kMWZaSSJ9.E5BkluenyWQMsBLsuByrmg'; var map = new ol.Map({ layers: [ new ol.layer.VectorTile({ 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(), tileGrid: ol.tilegrid.createXYZ({maxZoom: 22}), tilePixelRatio: 16, url: 'https://{a-d}.tiles.mapbox.com/v4/mapbox.mapbox-streets-v6/' + '{z}/{x}/{y}.vector.pbf?access_token=' + key }), style: createMapboxStreetsV6Style() }) ], target: 'map', view: new ol.View({ center: [0, 0], zoom: 2 }) }); // ol.style.Fill, ol.style.Icon, ol.style.Stroke, ol.style.Style and // ol.style.Text are required for createMapboxStreetsV6Style()