Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove legacy OL2 baselayers code #3812

Merged
merged 1 commit into from
Jul 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 3 additions & 43 deletions assets/src/legacy/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -1819,26 +1819,16 @@ window.lizMap = function() {

// get the baselayer select content
// and adding baselayers to the map
var select = [];
baselayers.reverse();
for (var i=0,len=baselayers.length; i<len; i++) {
var baselayer = baselayers[i]
for (const baselayer of baselayers) {
baselayer.units = projection.proj.units;
// Update singleTile layers
if( removeSingleTile && (baselayer instanceof OpenLayers.Layer.WMS) && baselayer.singleTile ) {
baselayer.addOptions({singleTile:false, tileSize: replaceSingleTileSize});
}
try{ // because google maps layer can be created but not added
map.addLayer(baselayer);
var qgisName = baselayer.name;
if ( baselayer.name in cleanNameMap )
qgisName = getLayerNameByCleanName(baselayer.name);
var blConfig = config.layers[qgisName];
if (blConfig)
select += '<option value="'+baselayer.name+'">'+blConfig.title+'</option>';
else
select += '<option value="'+baselayer.name+'">'+baselayer.name+'</option>';

map.baseLayer.setVisibility(false);
} catch(e) {
var qgisName = baselayer.name;
if ( baselayer.name in cleanNameMap )
Expand All @@ -1847,37 +1837,7 @@ window.lizMap = function() {
}
}

if (baselayers.length!=0) {
// active the select element for baselayers
$('#switcher-baselayer-select').append(select);
$('#switcher-baselayer-select')
.change(function() {
var val = $(this).val();
var blName = map.getLayersByName(val)[0];
map.setBaseLayer( blName );

// Trigger event
lizMap.events.triggerEvent("lizmapbaselayerchanged",
{ 'layer': blName}
);

$(this).blur();
});
// Hide switcher-baselayer if only one base layer inside
if (baselayers.length==1){
$('#switcher-baselayer').hide();
}
else if ( 'startupBaselayer' in config.options ) {
var startupBaselayer = config.options['startupBaselayer'];
if ( startupBaselayer in startupBaselayersReplacement )
startupBaselayer = startupBaselayersReplacement[startupBaselayer];
else if ( startupBaselayer in config.layers )
startupBaselayer = cleanName(startupBaselayer);

if ( $('#switcher-baselayer-select option[value="'+startupBaselayer+'"]').length != 0)
$('#switcher-baselayer-select').val(startupBaselayer).change();
}
} else {
if (baselayers.length === 0) {
// hide elements for baselayers
map.addLayer(new OpenLayers.Layer.Vector('baselayer',{
maxExtent:map.maxExtent
Expand Down
2 changes: 1 addition & 1 deletion tests/end2end/playwright/base-layers.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ test.describe('Base layers', () => {
});

test('Base layers list', async ({ page }) => {
await expect(page.locator('lizmap-base-layers select option')).toHaveCount(11);
await expect(page.locator('lizmap-base-layers select option')).toHaveCount(12);
await expect(page.locator('lizmap-base-layers select')).toHaveValue('osm-mapnik');
await page.locator('lizmap-base-layers select').selectOption('empty');
await expect(page.locator('lizmap-base-layers select')).toHaveValue('empty');
Expand Down
Loading
Loading