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

Selection from a popup feature geometry not working #70

Open
gioman opened this issue Feb 27, 2024 · 11 comments
Open

Selection from a popup feature geometry not working #70

gioman opened this issue Feb 27, 2024 · 11 comments

Comments

@gioman
Copy link
Contributor

gioman commented Feb 27, 2024

I believe that my test project is ok, configured as explaine in the script readme. Using QGIS Server/Desktop 3.28.15 and LMWC 3.6.10

When clicking on the icon/star in the feature popup (to trigger the selection on the other layers) the dev console shows this:

Uncaught TypeError: lizMap.mainLizmap.digitizing.drawLayer.getSource is not a function
    popupSelectionButtonClickHandler getMedia:86
    addSelectionButton getMedia:32
    lizmappopupdisplayed getMedia:178
    lizmappopupdisplayed getMedia:154
    triggerEvent OpenLayers.js:255
    Z map.js:2679
    getfeatureinfo map.js:3440
    triggerEvent OpenLayers.js:255
    triggerGetFeatureInfo OpenLayers.js:1692
    handleResponse OpenLayers.js:1693
    callback OpenLayers.js:1689
    bind OpenLayers.js:77
    runCallbacks OpenLayers.js:1563
    onreadystatechange OpenLayers.js:1559
    dispatchEvent OpenLayers.js:1593
    fReadyStateChange OpenLayers.js:1596
    onreadystatechange OpenLayers.js:1579
    open OpenLayers.js:1574
    issue OpenLayers.js:1558
    GET OpenLayers.js:1564
    request OpenLayers.js:1691
    getInfoForClick OpenLayers.js:1683
    callback OpenLayers.js:718
    delayedCall OpenLayers.js:1384
    bind OpenLayers.js:77
    setTimeout handler*queuePotentialClick OpenLayers.js:1380
    handleSingle OpenLayers.js:1380
    click OpenLayers.js:1377
    triggerEvent OpenLayers.js:255
    handleBrowserEvent OpenLayers.js:261
    bindAsEventListener OpenLayers.js:77
    observe OpenLayers.js:238
    attachToElement OpenLayers.js:247
    initialize OpenLayers.js:244
    initialize OpenLayers.js:300
    init map.js:1362
    init map.js:6282
[getMedia:86:44](https:/***/lizmap/www/index.php/view/media/getMedia?repository=qgisserverdemos&project=teste&mtime=1709052737&path=media%2Fjs%2Fdefault%2FselectionFromPopupGeometry.js)

​
@altheaFeu
Copy link
Contributor

altheaFeu commented Mar 1, 2024

Hi gioman,
Your error indicates that getSource does not exist for your object. This method doesn't work with LMWC 3.6 but works with LMWC 3.7. I believe this is because version 3.7 removed code from OpenLayers 2.
You can test lizMap.mainLizmap.digitizing.drawLayer.getSource().clear() in the JS console for both of these projects to see the difference:

LMWC 3.6 Projects
LMWC 3.7 Project

@gioman gioman changed the title Selection from a popup feature geometrynot working Selection from a popup feature geometry not working Mar 1, 2024
@gioman
Copy link
Contributor Author

gioman commented Mar 1, 2024

Your error indicates that getSource does not exist for your object. This method doesn't work with LMWC 3.6 but works with LMWC 3.7. I believe this is because version 3.7 removed code from OpenLayers 2.

@altheaFeu thanks for the reply. The script is 2 years old, with no recent changes, so does not seems to be the case(?).

You can test lizMap.mainLizmap.digitizing.drawLayer.getSource().clear() in the JS console for both of these projects to see the difference:

LMWC 3.6 Projects LMWC 3.7 Project

unclear to me what I should test. The first link does not point to a specific project, the second one points to a project that has no selection tool available.

@altheaFeu
Copy link
Contributor

altheaFeu commented Mar 1, 2024

The first link does not point to a specific project

You can choose any project you want for the first one. They are all using LMWC 3.6.

unclear to me what I should test.

I expressed myself poorly. If you type lizMap.mainLizmap.digitizing.drawLayer.getSource().clear() in the JS console of this project (LMWC 3.6), you will encounter an error,

Uncaught TypeError: lizMap.mainLizmap.digitizing.drawLayer.getSource is not a function

You won't face an error if you do the same thing with LMWC 3.7 project.

I suspect that the issue originates from the version of your LMWC.

@gioman
Copy link
Contributor Author

gioman commented Mar 1, 2024

I expressed myself poorly. If you type lizMap.mainLizmap.digitizing.drawLayer.getSource().clear() in the JS console of this project (LMWC 3.6), you will encounter an error,

@altheaFeu but the js code is 2 years old with no changes in the meantime, this means that it has been created as it is long before LM 3.7.

@altheaFeu
Copy link
Contributor

@gioman Indeed, in this case, I wouldn't be able to tell where the error comes from.

@gioman
Copy link
Contributor Author

gioman commented Mar 1, 2024

@altheaFeu thanks anyway!

@altheaFeu
Copy link
Contributor

Hi @gioman
I needed this tool for my own project, so I rectified the script.
I also translated the native JavaScript functions into jQuery.
You can find the correction here, and it successfully operated on my project with LMWC 3.5.10.

@gioman
Copy link
Contributor Author

gioman commented Mar 30, 2024

@altheaFeu thanks!

@Gustry
Copy link
Member

Gustry commented Apr 4, 2024

You can find the correction #78, and it successfully operated on my project with LMWC 3.5.10.

Thanks @altheaFeu for all contributions ! Very appreciated. I didn't get time last week to review (I was in Grenoble for the QGIS user conf where I met some of your company :) )

Sorry, but did you have a instance with LWC 3.7 running ?
For now, Javascript files do not have metadata about which LWC versions they are targeting. I'm bit reluctant to merge files if it's targeting LWC 3.5, as this version is already not maintained by us.

Of course, if your files are on API that didn't change in LWC 3.7, there is no issue, but I will need to ask my colleagues for the review (@nboisteault mainly)

@altheaFeu
Copy link
Contributor

altheaFeu commented Apr 4, 2024

Thanks @altheaFeu for all contributions !

@Gustry You're welcome ! I'm currently working on Lizmap projectsat the place where I'm doing my apprenticeship. We're developing JS tools, and since we're using an open-source solutions, it seems only natural to share my work as open source (It's afterall one of the primary objective of open-source).

Sorry, but did you have a instance with LWC 3.7 running ?

Unfortunately, I'm using an LWC 3.5 instance. But I'll try to install a 3.7 version on my personal computer if I find the time outside of my classes and my apprenticeship hours (so it's not guaranteed).

@gioman
Copy link
Contributor Author

gioman commented Apr 5, 2024

If the PR makes the script work on LM 3.6 is well worth the merge, many are holding on the move to LMWC 3,7.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants