Skip to content

Commit

Permalink
Merge branch 'master' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
Antoviscomi authored Jul 28, 2023
2 parents 10cf3dd + 8cb7603 commit 82e4034
Show file tree
Hide file tree
Showing 21 changed files with 2,117 additions and 1,697 deletions.
13 changes: 11 additions & 2 deletions assets/src/components/OverviewMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,20 @@ export default class OverviewMap extends HTMLElement {

connectedCallback() {

let overviewInCfg = mainLizmap.state.layersAndGroupsCollection.groups
.find(group => group.name.toLowerCase() === 'overview' && group.level === 1);

if (!overviewInCfg) {
return;
}

const overviewLayer = new ImageLayer({
source: new ImageWMS({
url: mainLizmap.serviceURL,
params: { 'LAYERS': 'Overview' },
ratio: 1,
params: {
LAYERS: overviewInCfg.wmsName
},
ratio: 1.1,
serverType: 'qgis',
}),
});
Expand Down
4 changes: 1 addition & 3 deletions assets/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ lizMap.events.on({
window.customElements.define('lizmap-scaleline', Scaleline);
window.customElements.define('lizmap-mouse-position', MousePosition);
window.customElements.define('lizmap-digitizing', Digitizing);
if(mainLizmap.hasOverview){
window.customElements.define('lizmap-overviewmap', OverviewMap);
}
window.customElements.define('lizmap-overviewmap', OverviewMap);
window.customElements.define('lizmap-feature-toolbar', FeatureToolbar);
window.customElements.define('lizmap-reverse-geom', ReverseGeom);
window.customElements.define('lizmap-paste-geom', PasteGeom);
Expand Down
48 changes: 4 additions & 44 deletions assets/src/legacy/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -847,7 +847,7 @@ window.lizMap = function() {

if ( qgisLayerName.toLowerCase() == 'hidden' )
continue;
if ( qgisLayerName == 'Overview' ) {
if ( qgisLayerName.toLowerCase() == 'overview' ) {
config.options.hasOverview = true;
continue;
}
Expand Down 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
4 changes: 0 additions & 4 deletions assets/src/modules/Lizmap.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,6 @@ export default class Lizmap {
return lizUrls.media + '?' + (new URLSearchParams(lizUrls.params).toString());
}

get hasOverview() {
return this._lizmap3.config.layers.hasOwnProperty('Overview');
}

get center() {
const center = this._lizmap3.map.getCenter();
return [center.lon, center.lat];
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
226 changes: 0 additions & 226 deletions tests/end2end/cypress/integration/overview-ghaction.js

This file was deleted.

2 changes: 1 addition & 1 deletion tests/end2end/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default defineConfig({
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 2 : undefined,
workers: process.env.CI ? 1 : undefined,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: 'html',
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
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

0 comments on commit 82e4034

Please sign in to comment.