-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.js
32 lines (28 loc) · 1.07 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
var $ = require('jquery')
var mapboxgl = require('mapbox-gl')
mapboxgl.accessToken = 'NOT-REQUIRED-WITH-YOUR-VECTOR-TILES-DATA'
var rootURL = window.location.origin + window.location.pathname
var baseURL = window.location.origin + window.location.search.slice(1)
var style = require('./pub/osm-liberty/style.json')
style.sprite = rootURL + '/osm-liberty/sprites/osm-liberty'
style.glyphs = rootURL + '/font-glyphs/glyphs/{fontstack}/{range}.pbf'
style.sources.natural_earth_shaded_relief.tiles = [
rootURL + '/naturalearthtiles/tiles/natural_earth_2_shaded_relief.raster/{z}/{x}/{y}.png'
]
$.getJSON(baseURL + '/metadata.json', function (metadata) {
metadata.type = 'vector'
metadata.profile = 'mercator'
metadata.scheme = 'xyz'
metadata.tilejson = '2.0.0'
metadata.tiles = [baseURL + '/{z}/{x}/{y}.pbf']
metadata.minzoom = parseInt(metadata.minzoom, 10)
metadata.maxzoom = parseInt(metadata.maxzoom, 10)
style.sources.openmaptiles = metadata
window.map = new mapboxgl.Map({
container: 'map',
style: style,
zoom: 1,
center: [0, 0],
hash: true
})
})