function createDynamicLayers() { map.DynamicLayer_17 = new ol.layer.Vector({ style: map.getDynamicFeatureStyle, name: "dynamic_17", dynamic: 1, isDB: 0, visible: false, declutter: false, source: new ol.source.Vector({ loader: function (extent, resolution, projection) { if(ASMulti == null) ASMulti = {}; var params = { tm: 'v' + mapTimeFrom.UTCISOtoday() + mapTimeTo.UTCISOtoday(true), dummy: new Date().getTime(), layerID: 17 }; AJAXAPI.send('getGJ.php?' + AJAXAPI.prepareParams(params, ds_gj, true), null, function (resp) { resp = AJAXAPI.prepareResponse(resp, ds_as); if (isVarNonempty(resp)) { var formatGEOJSON = new ol.format.GeoJSON({ featureProjection: "EPSG:3857" }); map.DynamicLayer_17.getSource().addFeatures(formatGEOJSON.readFeatures(resp)); if (typeof resp == "string") { try { resp = JSON.parse(resp); } catch (Exception) { resp = null; } } if (isVarNonempty(resp) && isVarNonempty(resp.multi) && !isVarNonempty(resp.multi.length)) { ASMulti = $.extend(true, {}, ASMulti, resp.multi) map.setMultiFeaturesData(); } } }, function () { AJAXAPI.commError(); }, null, false, 240000); } }) }); map.dynamicLayersList.push({ layer: map.DynamicLayer_17, isBase: 1, isWMTS: 0, isWFS: 0, isWMS: 0, url: '', options: {} }); map.DynamicLayer_16 = new ol.layer.Tile({ style: map.getDynamicFeatureStyle, name: "dynamic_16", opacity: 0.75, maxResolution: map.map.getView().getResolutionForZoom(10.9000), visible: true, dynamic: 1, isDB: 0, declutter: false, source: new ol.source.TileWMS({ crossOrigin: 'anonymous', url: 'https://aimgis.rlp.cz/server/services/HOPs/MapServer/WMSServer', params: {'LAYERS': '1,2', 'TILED': 'false', 'TRANSPARENT': 'true'}, projection: 'EPSG:3857' }) }); var WMSobject = { layer: map.DynamicLayer_16, isHTML: false, WFSURL: "" }; map.WMSLayersList.push(WMSobject); map.dynamicLayersList.push({ layer: map.DynamicLayer_16, isBase: 1, isWMTS: 0, isWFS: 0, isWMS: 1, url: 'https://aimgis.rlp.cz/server/services/HOPs/MapServer/WMSServer', options: {} }); map.DynamicLayer_15 = new ol.layer.Tile({ style: map.getDynamicFeatureStyle, name: "dynamic_15", opacity: 0.5, visible: true, dynamic: 1, isDB: 0, declutter: false, source: new ol.source.TileWMS({ crossOrigin: 'anonymous', url: 'https://aimgis.rlp.cz/server/services/energeticka_sit/MapServer/WMSServer', params: {'LAYERS': '0,1', 'TILED': 'false', 'TRANSPARENT': 'true'}, projection: 'EPSG:3857' }) }); var WMSobject = { layer: map.DynamicLayer_15, isHTML: false, WFSURL: "" }; map.WMSLayersList.push(WMSobject); map.dynamicLayersList.push({ layer: map.DynamicLayer_15, isBase: 1, isWMTS: 0, isWFS: 0, isWMS: 1, url: 'https://aimgis.rlp.cz/server/services/energeticka_sit/MapServer/WMSServer', options: {} }); map.DynamicLayer_14 = new ol.layer.Tile({ style: map.getDynamicFeatureStyle, name: "dynamic_14", opacity: 0.75, visible: true, dynamic: 1, isDB: 0, declutter: false, source: new ol.source.TileWMS({ crossOrigin: 'anonymous', url: 'https://aimgis.rlp.cz/server/services/zdroje_vody/MapServer/WMSServer', params: {'LAYERS': '0', 'TILED': 'false', 'TRANSPARENT': 'true'}, projection: 'EPSG:3857' }) }); var WMSobject = { layer: map.DynamicLayer_14, isHTML: false, WFSURL: "" }; map.WMSLayersList.push(WMSobject); map.dynamicLayersList.push({ layer: map.DynamicLayer_14, isBase: 1, isWMTS: 0, isWFS: 0, isWMS: 1, url: 'https://aimgis.rlp.cz/server/services/zdroje_vody/MapServer/WMSServer', options: {} }); map.DynamicLayer_13 = new ol.layer.Tile({ style: map.getDynamicFeatureStyle, name: "dynamic_13", opacity: 0.5, visible: true, dynamic: 1, isDB: 0, declutter: false, source: new ol.source.TileWMS({ crossOrigin: 'anonymous', url: 'https://aimgis.rlp.cz/server/services/Zeleznice/MapServer/WMSServer', params: {'LAYERS': '0,1', 'TILED': 'false', 'TRANSPARENT': 'true'}, projection: 'EPSG:3857' }) }); var WMSobject = { layer: map.DynamicLayer_13, isHTML: false, WFSURL: "" }; map.WMSLayersList.push(WMSobject); map.dynamicLayersList.push({ layer: map.DynamicLayer_13, isBase: 1, isWMTS: 0, isWFS: 0, isWMS: 1, url: 'https://aimgis.rlp.cz/server/services/Zeleznice/MapServer/WMSServer', options: {} }); map.DynamicLayer_12 = new ol.layer.Tile({ style: map.getDynamicFeatureStyle, name: "dynamic_12", opacity: 0.5, maxResolution: map.map.getView().getResolutionForZoom(8.9000), visible: true, dynamic: 1, isDB: 0, declutter: false, source: new ol.source.TileWMS({ crossOrigin: 'anonymous', url: 'https://aimgis.rlp.cz/server/services/silnicni_sit/MapServer/WMSServer', params: {'LAYERS': '0,1', 'TILED': 'false', 'TRANSPARENT': 'true'}, projection: 'EPSG:3857' }) }); var WMSobject = { layer: map.DynamicLayer_12, isHTML: false, WFSURL: "" }; map.WMSLayersList.push(WMSobject); map.dynamicLayersList.push({ layer: map.DynamicLayer_12, isBase: 1, isWMTS: 0, isWFS: 0, isWMS: 1, url: 'https://aimgis.rlp.cz/server/services/silnicni_sit/MapServer/WMSServer', options: {} }); map.DynamicLayer_7 = new ol.layer.Tile({ style: map.getDynamicFeatureStyle, name: "dynamic_7", opacity: 0.4, visible: true, dynamic: 1, isDB: 0, declutter: false, source: new ol.source.TileWMS({ crossOrigin: 'anonymous', url: 'https://aimgis.rlp.cz/server/services/chranena_uzemi/MapServer/WMSServer', params: {'LAYERS': '0,1,2,3', 'TILED': 'false', 'TRANSPARENT': 'true'}, projection: 'EPSG:3857' }) }); var WMSobject = { layer: map.DynamicLayer_7, isHTML: false, WFSURL: "" }; map.WMSLayersList.push(WMSobject); map.dynamicLayersList.push({ layer: map.DynamicLayer_7, isBase: 1, isWMTS: 0, isWFS: 0, isWMS: 1, url: 'https://aimgis.rlp.cz/server/services/chranena_uzemi/MapServer/WMSServer', options: {} }); map.DynamicLayer_10 = new ol.layer.Vector({ style: map.getDynamicFeatureStyle, name: "dynamic_10", dynamic: 1, isDB: 0, visible: false, declutter: false, source: new ol.source.Vector({ loader: function (extent, resolution, projection) { if(ASMulti == null) ASMulti = {}; var params = { tm: 'v' + mapTimeFrom.UTCISOtoday() + mapTimeTo.UTCISOtoday(true), dummy: new Date().getTime(), layerID: 10 }; AJAXAPI.send('getGJ.php?' + AJAXAPI.prepareParams(params, ds_gj, true), null, function (resp) { resp = AJAXAPI.prepareResponse(resp, ds_as); if (isVarNonempty(resp)) { var formatGEOJSON = new ol.format.GeoJSON({ featureProjection: "EPSG:3857" }); map.DynamicLayer_10.getSource().addFeatures(formatGEOJSON.readFeatures(resp)); if (typeof resp == "string") { try { resp = JSON.parse(resp); } catch (Exception) { resp = null; } } if (isVarNonempty(resp) && isVarNonempty(resp.multi) && !isVarNonempty(resp.multi.length)) { ASMulti = $.extend(true, {}, ASMulti, resp.multi) map.setMultiFeaturesData(); } } }, function () { AJAXAPI.commError(); }, null, false, 240000); }, format: new ol.format.GeoJSON }) }); map.dynamicLayersList.push({ layer: map.DynamicLayer_10, isBase: 0, isWMTS: 0, isWFS: 0, isWMS: 0, url: '', options: {} }); map.DynamicLayer_5 = new ol.layer.Vector({ style: map.getDynamicFeatureStyle, name: "dynamic_5", dynamic: 1, isDB: 0, visible: false, declutter: false, source: new ol.source.Vector({ loader: function (extent, resolution, projection) { if(ASMulti == null) ASMulti = {}; var params = { tm: 'v' + mapTimeFrom.UTCISOtoday() + mapTimeTo.UTCISOtoday(true), dummy: new Date().getTime(), layerID: 5 }; AJAXAPI.send('getGJ.php?' + AJAXAPI.prepareParams(params, ds_gj, true), null, function (resp) { resp = AJAXAPI.prepareResponse(resp, ds_as); if (isVarNonempty(resp)) { var formatGEOJSON = new ol.format.GeoJSON({ featureProjection: "EPSG:3857" }); map.DynamicLayer_5.getSource().addFeatures(formatGEOJSON.readFeatures(resp)); if (typeof resp == "string") { try { resp = JSON.parse(resp); } catch (Exception) { resp = null; } } if (isVarNonempty(resp) && isVarNonempty(resp.multi) && !isVarNonempty(resp.multi.length)) { ASMulti = $.extend(true, {}, ASMulti, resp.multi) map.setMultiFeaturesData(); } } }, function () { AJAXAPI.commError(); }, null, false, 240000); }, format: new ol.format.GeoJSON }) }); map.dynamicLayersList.push({ layer: map.DynamicLayer_5, isBase: 0, isWMTS: 0, isWFS: 0, isWMS: 0, url: '', options: {} }); map.DynamicLayer_8 = new ol.layer.Image({ style: map.getDynamicFeatureStyle, name: "dynamic_8", opacity: 0.4, visible: true, dynamic: 1, isDB: 0, declutter: false, source: new ol.source.ImageWMS({ crossOrigin: 'anonymous', url: 'https://aimgis.rlp.cz/server/services/Gridy/MapServer/WMSServer', params: {'LAYERS': '0,1', 'TILED': 'false', 'TRANSPARENT': 'true'}, projection: 'EPSG:3857' }) }); var WMSobject = { layer: map.DynamicLayer_8, isHTML: false, WFSURL: "" }; map.WMSLayersList.push(WMSobject); map.dynamicLayersList.push({ layer: map.DynamicLayer_8, isBase: 0, isWMTS: 0, isWFS: 0, isWMS: 0, url: 'https://aimgis.rlp.cz/server/services/Gridy/MapServer/WMSServer', options: {} }); map.DynamicLayer_9 = new ol.layer.Vector({ style: map.getDynamicFeatureStyle, name: "dynamic_9", dynamic: 1, isDB: 0, visible: false, declutter: false, source: new ol.source.Vector({ loader: function (extent, resolution, projection) { if(ASMulti == null) ASMulti = {}; var params = { tm: 'v' + mapTimeFrom.UTCISOtoday() + mapTimeTo.UTCISOtoday(true), dummy: new Date().getTime(), layerID: 9 }; AJAXAPI.send('getGJ.php?' + AJAXAPI.prepareParams(params, ds_gj, true), null, function (resp) { resp = AJAXAPI.prepareResponse(resp, ds_as); if (isVarNonempty(resp)) { var formatGEOJSON = new ol.format.GeoJSON({ featureProjection: "EPSG:3857" }); map.DynamicLayer_9.getSource().addFeatures(formatGEOJSON.readFeatures(resp)); if (typeof resp == "string") { try { resp = JSON.parse(resp); } catch (Exception) { resp = null; } } if (isVarNonempty(resp) && isVarNonempty(resp.multi) && !isVarNonempty(resp.multi.length)) { ASMulti = $.extend(true, {}, ASMulti, resp.multi) map.setMultiFeaturesData(); } } }, function () { AJAXAPI.commError(); }, null, false, 240000); }, format: new ol.format.GeoJSON }) }); map.dynamicLayersList.push({ layer: map.DynamicLayer_9, isBase: 0, isWMTS: 0, isWFS: 0, isWMS: 0, url: '', options: {} }); map.DynamicLayer_11 = new ol.layer.Vector({ style: map.getDynamicFeatureStyle, name: "dynamic_11", dynamic: 1, isDB: 0, visible: false, declutter: false, source: new ol.source.Vector({ loader: function (extent, resolution, projection) { if(ASMulti == null) ASMulti = {}; var params = { tm: 'v' + mapTimeFrom.UTCISOtoday() + mapTimeTo.UTCISOtoday(true), dummy: new Date().getTime(), layerID: 11 }; AJAXAPI.send('getGJ.php?' + AJAXAPI.prepareParams(params, ds_gj, true), null, function (resp) { resp = AJAXAPI.prepareResponse(resp, ds_as); if (isVarNonempty(resp)) { var formatGEOJSON = new ol.format.GeoJSON({ featureProjection: "EPSG:3857" }); map.DynamicLayer_11.getSource().addFeatures(formatGEOJSON.readFeatures(resp)); if (typeof resp == "string") { try { resp = JSON.parse(resp); } catch (Exception) { resp = null; } } if (isVarNonempty(resp) && isVarNonempty(resp.multi) && !isVarNonempty(resp.multi.length)) { ASMulti = $.extend(true, {}, ASMulti, resp.multi) map.setMultiFeaturesData(); } } }, function () { AJAXAPI.commError(); }, null, false, 240000); }, format: new ol.format.GeoJSON }) }); map.dynamicLayersList.push({ layer: map.DynamicLayer_11, isBase: 0, isWMTS: 0, isWFS: 0, isWMS: 0, url: '', options: {} }); map.DynamicLayer_18 = new ol.layer.Tile({ name: "dynamic_18", visible: false, dynamic: 1, isDB: 0, declutter: false, source: new ol.source.TileWMS({ crossOrigin: 'anonymous', url: 'https://aimgis.rlp.cz/server/services/zony/MapServer/WMSServer', params: {'LAYERS': '0', 'TILED': 'false', 'TRANSPARENT': 'true'}, projection: 'EPSG:3857' }) }); var WMSobject = { layer: map.DynamicLayer_18, isHTML: false, WFSURL: "" }; map.WMSLayersList.push(WMSobject); map.dynamicLayersList.push({ layer: map.DynamicLayer_18, isBase: 0, isWMTS: 0, isWFS: 0, isWMS: 1, url: 'https://aimgis.rlp.cz/server/services/zony/MapServer/WMSServer', options: {} }); } function addDynamicLayers(isBase) { $.each(map.dynamicLayersList, function( index, layer ) { if((isBase && layer.isBase != 1) || (!isBase && layer.isBase != 0)) return; map.map.addLayer(layer.layer); if(layer.isWMTS == 1) { const parser = new ol.format.WMTSCapabilities(); fetch(layer.url) .then(function (response) { return response.text(); }) .then(function (text) { const result = parser.read(text); var options = ol.source.WMTS.optionsFromCapabilities(result, layer.options); layer.setSource(new ol.source.WMTS(options)); }); } }); }