Open gioman opened 8 months ago
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:
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:
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.
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.
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.
@gioman Indeed, in this case, I wouldn't be able to tell where the error comes from.
@altheaFeu thanks anyway!
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.
@altheaFeu thanks!
You can find the correction https://github.com/3liz/lizmap-javascript-scripts/pull/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)
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).
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.
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: