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

Can set the opacity of a null icon #6609

Closed
charlie67 opened this issue Apr 18, 2019 · 1 comment
Closed

Can set the opacity of a null icon #6609

charlie67 opened this issue Apr 18, 2019 · 1 comment

Comments

@charlie67
Copy link
Contributor

charlie67 commented Apr 18, 2019

Steps to reproduce
Steps to reproduce the behavior:
Difficult to reproduce, and our code can't be shared online.

Expected behavior
Not setting the opacity when the icon is null.

Current behavior
This occurs when using ember-leaflet-marker-cluster alongside leaflet and the way ember-leaflet-marker-cluster is being used ithe opacity of a null icon tries to be set which results in this exception:
Uncaught TypeError: Cannot read property 'style' of null at setOpacity (leaflet-src.js:2368) at NewClass._updateOpacity (leaflet-src.js:7694) at NewClass.setOpacity (leaflet-src.js:7684) at NewClass.clusterShow (leaflet.markercluster.js:2) at leaflet.markercluster.js:2 at NewClass._recursively (leaflet.markercluster.js:2) at NewClass._recursivelyRemoveChildrenFromMap (leaflet.markercluster.js:2) at NewClass._moveEnd (leaflet.markercluster.js:2) at NewClass._mergeSplitClusters (leaflet.markercluster.js:2) at NewClass._zoomEnd (leaflet.markercluster.js:2)

Environment

  • Leaflet version: 1.4.0
  • Browser (with version): Firefox 66.0.2, Chrome 73.0.3683.103
  • OS/Platform (with version): Ubuntu 18.04.1

Additional context
Managed to fix this locally by changing the _updateOpacity method in src/layer/marker/Marker.js file and changing it to check if the icon is set before updating the opacity change it from:
DomUtil.setOpacity(this._icon, opacity)
to
if (this._icon) { DomUtil.setOpacity(this._icon, opacity); }

This seems like a very small change so shouldn't break anything and it would help us out loads.
I'll add in a pull request with the change I mentioned

Minimal example reproducing the issue
As I mentioned it's difficult to reproduce and we can't share our code online. If the code needs to be reproduced call the _removeIcon method, then call the _updateOpacity method.

@mourner
Copy link
Member

mourner commented Apr 22, 2019

Fixed by #6610

@mourner mourner closed this as completed Apr 22, 2019
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

2 participants