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

fixed method "resetLayer" in terms of deleting layer labels #770

Closed
wants to merge 1 commit into from

Conversation

viatkinviatkin
Copy link
Contributor

@viatkinviatkin viatkinviatkin commented Jun 21, 2023

Changing the layer settings triggers the base-layer/leafletOptionsDidChange handler, which executes
_resetLayer->_destroyLayer->_removeLayerFromLeafletContainer,
removing the previous leafletLayer instance from the leafletContainer

this.get('_labelsLayer') of labels is a linked separate layer with this.get('_leafletObject')
and will be removed only when this.get('labelSettings.signMapObjects') === true

But this.get('labelSettings.signMapObjects') can be changed BEFORE _resetLayer, which will leave this.get('_labelsLayer') in the leafletContainer.

It is necessary to remove this.get('_labelsLayer') from the leafletContainer whenever _removeLayerFromLeafletContainer is called

@sonarcloud
Copy link

sonarcloud bot commented Jun 21, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

if (this.get('labelSettings.signMapObjects') && !Ember.isNone(this.get('_labelsLayer')) &&
leafletContainer.hasLayer(this.get('_labelsLayer'))) {
leafletContainer.removeLayer(this.get('_labelsLayer'));
let labelsLayer = this.get('_labelsLayer');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Так, ну во-первых, если уж мы озаботились удалением надписей при изменении флага signMapObjects, то как минимум надо это сделать и для additionalZoomLabel (см. выше)

При этом, у нас есть еще и отдельный метод _removeLabelsFromLeafletContainer.
Возможно, разумнее логику по скрытию надписей перенести в него, полностью убрав из _removeLayerFromLeafletContainer. А в метод _destroyLayer добавить вызов _removeLabelsFromLeafletContainer
Возможно нужен какой-то параметр, ибо оба метода _remove... вызываются еще и при отключении видимости слоя. и при включении видимости мы хотим снова увидеть объекты и надписи, которые уже были на карте. Но ты слой не просто убираешь с карты, ты его очищаешь (проверь этот момент, но по-моему надписи обратно не включатся с твоим изменением, если они не в additionalZoomLabel были)

@@ -1069,7 +1069,7 @@ export default BaseLayer.extend({
leafletObject.clearLayers();

if (this.get('labelSettings.signMapObjects') && !Ember.isNone(this.get('_labelsLayer')) &&
!Ember.isNone(this.get('_leafletObject._labelsLayeri'))) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

тут опечатка была просто?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Да

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

Successfully merging this pull request may close these issues.

None yet

2 participants