Skip to content

Commit 830a749

Browse files
committed
Auto-regenerate query links when format dropdown changes
When users change info/image format dropdowns while Query is enabled, automatically regenerate the query link to reflect the new format. This prevents confusion and matches the behavior of toggling the Query checkbox. - WMTS: Add info format dropdown listener to update query links - ESRI MapServer: Update image format listener to regenerate queries - ESRI ImageServer: Update image format listener to regenerate queries - WMS: Already had this functionality implemented
1 parent ac8d962 commit 830a749

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

src/script/main.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -964,6 +964,29 @@ function displayWMTSInfo(info, source, url) {
964964
}
965965
});
966966
}
967+
968+
// Add event listener to info format dropdown
969+
const formatSelect = document.getElementById('format-' + index);
970+
if (formatSelect) {
971+
formatSelect.addEventListener('change', function(e) {
972+
const layerCheckbox = document.getElementById('layer-' + index);
973+
const queryCheckbox = document.getElementById('query-' + index);
974+
if (layerCheckbox.checked && queryCheckbox.checked) {
975+
const styleSelect = document.getElementById('style-' + index);
976+
const selectedStyle = styleSelect ? styleSelect.value : (layer.styles[0] ? layer.styles[0].name : 'default');
977+
const imgFormatSelect = document.getElementById('img-format-' + index);
978+
const selectedImgFormat = imgFormatSelect ? imgFormatSelect.value : (layer.formats[0] || 'image/png');
979+
const projectionSelect = document.getElementById('projection-' + index);
980+
const selectedProjection = projectionSelect ? projectionSelect.value : 'OSMTILE';
981+
982+
// Find the tile matrix set for the selected projection
983+
const tileMatrixSet = layer.supportedTileMatrixSets.find(tms => tms.projection === selectedProjection);
984+
985+
// Update query link with new format
986+
updateWMTSQueryInViewer(index, layer, tileMatrixSet, true, e.target.value, selectedStyle, selectedImgFormat);
987+
}
988+
});
989+
}
967990
}
968991

969992
const boundsCheckbox = document.getElementById('bounds-' + index);
@@ -1797,6 +1820,11 @@ function displayESRIMapServerInfo(info, source, url) {
17971820
const boundsEnabled = boundsCheckbox ? boundsCheckbox.checked : true;
17981821
removeViewerForLayer(index);
17991822
createViewerForESRIMapServerLayer(index, layer, info, queryEnabled, imgFormatSelect.value, exportMode, boundsEnabled);
1823+
1824+
// Also update query if it's enabled
1825+
if (queryEnabled) {
1826+
updateESRIMapServerQueryInViewer(index, layer, info, true, imgFormatSelect.value);
1827+
}
18001828
}
18011829
});
18021830
}
@@ -1951,6 +1979,11 @@ function displayESRIImageServerInfo(info, source, url) {
19511979
const boundsEnabled = boundsCheckbox ? boundsCheckbox.checked : true;
19521980
removeViewerForLayer(0);
19531981
createViewerForESRIImageServerLayer(0, layer, info, queryEnabled, imgFormatSelect.value, boundsEnabled);
1982+
1983+
// Also update query if it's enabled
1984+
if (queryEnabled) {
1985+
updateESRIImageServerQueryInViewer(0, layer.name, true, info, imgFormatSelect.value);
1986+
}
19541987
}
19551988
});
19561989
}

0 commit comments

Comments
 (0)