ol-mapbox-style
Advanced tools
Comparing version 2.6.5 to 2.6.6
25
index.js
@@ -218,3 +218,3 @@ /* | ||
function processStyle(glStyle, map, baseUrl, path, accessToken) { | ||
function processStyle(glStyle, map, baseUrl, host, path, accessToken) { | ||
var view = map.getView(); | ||
@@ -233,4 +233,8 @@ if ('center' in glStyle && !view.getCenter()) { | ||
} | ||
if (glStyle.sprite && glStyle.sprite.indexOf('mapbox://') == 0) { | ||
glStyle.sprite = baseUrl + '/sprite' + accessToken; | ||
if (glStyle.sprite) { | ||
if (glStyle.sprite.indexOf('mapbox://') == 0) { | ||
glStyle.sprite = baseUrl + '/sprite' + accessToken; | ||
} else if (glStyle.sprite.indexOf('http') != 0) { | ||
glStyle.sprite = host + path + glStyle.sprite + accessToken; | ||
} | ||
} | ||
@@ -310,2 +314,10 @@ | ||
if (tilejson.getState() == 'ready') { | ||
var tileJSONDoc = tilejson.getTileJSON(); | ||
var tiles = Array.isArray(tileJSONDoc.tiles) ? tileJSONDoc.tiles : [tileJSONDoc.tiles]; | ||
for (var i = 0, ii = tiles.length; i < ii; ++i) { | ||
var tile = tiles[i]; | ||
if (tile.indexOf('http' != 0)) { | ||
tiles[i] = glSource.url + tile; | ||
} | ||
} | ||
layer.setSource(new VectorTileSource({ | ||
@@ -315,3 +327,3 @@ attributions: tilejson.getAttributions(), | ||
tileGrid: tilejson.getTileGrid(), | ||
tileUrlFunction: tilejson.getTileUrlFunction() | ||
urls: tiles | ||
})); | ||
@@ -395,3 +407,3 @@ Observable.unByKey(key); | ||
var accessToken, baseUrl, path; | ||
var accessToken, baseUrl, host, path; | ||
@@ -415,5 +427,6 @@ if (!(map instanceof Map)) { | ||
path = a.pathname.split('/').slice(0, -1).join('/') + '/'; | ||
host = style.substr(0, style.indexOf(path)); | ||
xhr.addEventListener('load', function() { | ||
var glStyle = JSON.parse(xhr.responseText); | ||
processStyle(glStyle, map, baseUrl, path, accessToken); | ||
processStyle(glStyle, map, baseUrl, host, path, accessToken); | ||
}); | ||
@@ -420,0 +433,0 @@ xhr.addEventListener('error', function() { |
{ | ||
"name": "ol-mapbox-style", | ||
"version": "2.6.5", | ||
"version": "2.6.6", | ||
"description": "Create OpenLayers maps from Mapbox Style objects", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2965031
65428