Hello All, I need help on solving problem regarding Line Of Sight Widget's lines. I was using ArcGIS Javascript 4.33. And I was using the Line Of Sight widget on my code, like:
Solved! Go to Solution.
Hi @JuanMarvinW
I was able to replicate the problem with another dataset I had, but it is something we cannot quickly fix.
The problem occurs when creating the line-of-sight with clicks on datasets with big extents, e.g. where lot of buildings are grouped into one feature.
Why?
It occurs because of a mechanism that makes the analysis more stable in case of changing LODs (e.g. when one zooms in and out in the scene). When the line-of-sight is created with clicks, the widget automatically saves a feature property to the observer and each target classes. This is an ID of the clicked building/feature to exclude it from the intersection tests. This mechanism of course assumes that each building is a separate feature - which is not the case in this data set.
Workaround
A workaround is to set the feature = null. Here's the app showing this:
https://codepen.io/gsoosalu/pen/GgpZvYB
The app loads a line-of-sight layer with an analysis I had created with clicks, and connects the widget to it. You can see an incomplete visualization similar to your report. If you click the two buttons at the bottom left, the visualization becomes complete. Those buttons set the feature = null. But if you now create a new line-of-sight with the widget, the problem will show up again. This is because, whenever creating new observer/targets, automatically the feature property gets set again. So your app should watch the observer and targets array for changes and make sure the feature gets cleared.
Let me know if this helps you.
Best regards,
Grete
PS: here's a simpler app that doesn't use the already existing line-of-sight layer/analysis. This shows that the same workaround also functions for cases where the line-of-sight is created only with the widget:
https://codepen.io/gsoosalu/pen/vENKJNy
Hi @JuanMarvinW
Thanks for reaching out! Could you maybe share the apps or the layer with me (either here or via direct message) so that we can look more into this?
Is there a chance that all these buildings are one feature? Also, what I didn't 100% understand - did you create the lines of sight in the EB also by clicking in the scene/map?
Hi @GreteSoosalu ,
Thank you for your reply. As you expected, all of these buildings are one feature, with Scene Layer Type = 3DObject. When I select one building, all buildings are selected.
Also, when I created the lines of sight in the EB, I also did the same thing as the Javascript :
- Created the observer point by clicking the side of a building
- Created target points by clicking the scene/map at locations behind a building.
Hi again,
Thanks for the additional infos! We'll investigate this further - there are some limitation for 3DObject features with big extents but I wonder why you get different results in JS-app vs Experience Builder.
Hi @JuanMarvinW
I was able to replicate the problem with another dataset I had, but it is something we cannot quickly fix.
The problem occurs when creating the line-of-sight with clicks on datasets with big extents, e.g. where lot of buildings are grouped into one feature.
Why?
It occurs because of a mechanism that makes the analysis more stable in case of changing LODs (e.g. when one zooms in and out in the scene). When the line-of-sight is created with clicks, the widget automatically saves a feature property to the observer and each target classes. This is an ID of the clicked building/feature to exclude it from the intersection tests. This mechanism of course assumes that each building is a separate feature - which is not the case in this data set.
Workaround
A workaround is to set the feature = null. Here's the app showing this:
https://codepen.io/gsoosalu/pen/GgpZvYB
The app loads a line-of-sight layer with an analysis I had created with clicks, and connects the widget to it. You can see an incomplete visualization similar to your report. If you click the two buttons at the bottom left, the visualization becomes complete. Those buttons set the feature = null. But if you now create a new line-of-sight with the widget, the problem will show up again. This is because, whenever creating new observer/targets, automatically the feature property gets set again. So your app should watch the observer and targets array for changes and make sure the feature gets cleared.
Let me know if this helps you.
Best regards,
Grete
PS: here's a simpler app that doesn't use the already existing line-of-sight layer/analysis. This shows that the same workaround also functions for cases where the line-of-sight is created only with the widget:
https://codepen.io/gsoosalu/pen/vENKJNy
Hi @GreteSoosalu ,
This is a great and working workaround. I can use your solution for now. Thank you so much for your help.
For others, please note that the observer and target classes exist in both: viewModel AND viewModel.analysis. Use the classes in viewModel.analysis.
Regards,
Marvin