add support for vector sources specified by url (#566)
This commit is contained in:
parent
b6955cf187
commit
46a1a61138
1 changed files with 16 additions and 4 deletions
|
|
@ -264,15 +264,27 @@ BR.LayersConfig = L.Class.extend({
|
||||||
_replaceMvtTileKey: function (style) {
|
_replaceMvtTileKey: function (style) {
|
||||||
if (!style) return;
|
if (!style) return;
|
||||||
|
|
||||||
|
// Sources can be specified by `url` (string) or `tiles` (array), we handle
|
||||||
|
// both variants here.
|
||||||
|
// see specification:
|
||||||
|
// https://maplibre.org/maplibre-gl-js-docs/style-spec/sources/
|
||||||
for (const source of Object.values(style.sources)) {
|
for (const source of Object.values(style.sources)) {
|
||||||
|
if (source.url) {
|
||||||
|
let keyObj = this.getKeyName(source.url);
|
||||||
|
if (keyObj && BR.keys[keyObj.name]) {
|
||||||
|
source.url = source.url.replace(`{${keyObj.urlVar}}`, BR.keys[keyObj.name]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (source.tiles) {
|
||||||
const tiles = source.tiles;
|
const tiles = source.tiles;
|
||||||
for (const [i, url] of tiles?.entries()) {
|
for (const [i, url] of tiles?.entries()) {
|
||||||
var keyObj = this.getKeyName(url);
|
let keyObj = this.getKeyName(url);
|
||||||
if (keyObj && BR.keys[keyObj.name]) {
|
if (keyObj && BR.keys[keyObj.name]) {
|
||||||
tiles[i] = url.replace(`{${keyObj.urlVar}}`, BR.keys[keyObj.name]);
|
tiles[i] = url.replace(`{${keyObj.urlVar}}`, BR.keys[keyObj.name]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
createLayer: function (layerData) {
|
createLayer: function (layerData) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue