From b40892ec5e316a294bcd70f8f00151ff3c1eb92e Mon Sep 17 00:00:00 2001 From: dbauszus-glx Date: Wed, 1 Nov 2023 12:22:20 +0000 Subject: [PATCH 1/2] Provide format:tiles source param --- lib/layer/format/tiles.mjs | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/lib/layer/format/tiles.mjs b/lib/layer/format/tiles.mjs index d76d1cba5..b37e2110e 100644 --- a/lib/layer/format/tiles.mjs +++ b/lib/layer/format/tiles.mjs @@ -1,11 +1,22 @@ +const sources = { + OSM: layer => new ol.source.OSM({ + url: decodeURIComponent(layer.URI), + opaque: false, + transition: 0, + }), + XYZ: layer => new ol.source.OSM({ + url: decodeURIComponent(layer.URI), + opaque: false, + transition: 0, + }) +} + export default layer => { + layer.source ??= 'OSM' + layer.L = new ol.layer.Tile({ - source: new ol.source.OSM({ - url: decodeURIComponent(layer.URI), - opaque: false, - transition: 0, - }), + source: sources[layer.source](layer), layer: layer, zIndex: layer.style?.zIndex || 0 }) From 3ac8f06c1d16d0c5ba7a4999fff315fc410432fa Mon Sep 17 00:00:00 2001 From: dbauszus-glx Date: Thu, 2 Nov 2023 11:39:15 +0000 Subject: [PATCH 2/2] optional source and projection param for tile layer. --- lib/layer/format/tiles.mjs | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/lib/layer/format/tiles.mjs b/lib/layer/format/tiles.mjs index b37e2110e..62af5a7bc 100644 --- a/lib/layer/format/tiles.mjs +++ b/lib/layer/format/tiles.mjs @@ -1,22 +1,15 @@ -const sources = { - OSM: layer => new ol.source.OSM({ - url: decodeURIComponent(layer.URI), - opaque: false, - transition: 0, - }), - XYZ: layer => new ol.source.OSM({ - url: decodeURIComponent(layer.URI), - opaque: false, - transition: 0, - }) -} - export default layer => { layer.source ??= 'OSM' + layer.projection ??= 'EPSG:3857' + layer.L = new ol.layer.Tile({ - source: sources[layer.source](layer), + source: new ol.source[layer.source]({ + projection: layer.projection, + url: decodeURIComponent(layer.URI), + transition: 0 + }), layer: layer, zIndex: layer.style?.zIndex || 0 })