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

Labels removed when features move outside of view and back. #1193

Closed
freewheelCarto opened this issue Apr 10, 2020 · 6 comments
Closed

Labels removed when features move outside of view and back. #1193

freewheelCarto opened this issue Apr 10, 2020 · 6 comments

Comments

@freewheelCarto
Copy link

Using the code given for the Labeling Features example (and in the example itself), labels are sometimes removed when the features move out of the viewport and back in.

It seems related to the removefeature events. In some cases (but not always), when the features move out of the viewport, I was able to see that the removefeature event is fired (related to this functionality?). In the example code, the labels are removed from the map on this event. I do see that addfeature is fired when the map is panned and features make it back into view, but it doesn't add the labels.

I'm trying to figure out a solution for my current project. If I can figure something out, it will probably be more of a work around than a permanent solution. Maybe someone will be able to address this in a more permanent way for the example on the Esri Leaflet docs.

Here is a screenshot from the Esri Leaflet example page that shows missing labels.

image

@jwasilgeo
Copy link
Contributor

That's an interesting catch, thanks for pointing this out.

I haven't had focused time yet to debug what is going on the way that sample was written and in your linked issue #408 comment thread, but according to the API docs all of this should work as-is.

I created a remixed codepen of the sample page in question using a different approach. It is just a quick trial and exploration, and admittedly it may be a bit heavy-handed doing the label removing/adding on map move events. Check out the console statements to see that at first glance there should be just enough label <div>s hanging out in the DOM for the features currently displayed.

https://codepen.io/jwasilgeo/pen/xxwbEXP

(I had used the move event for a different visualization purpose in an earlier codepen.)

@freewheelCarto
Copy link
Author

Thanks for the quick response and quick solution, which seems like it should do the trick in the meantime.

@jwasilgeo
Copy link
Contributor

There's also Geovation/labelgun. Would be interesting to compare/contrast and give it a whirl. They've a live demo with esri-leaflet and here's the source.

Ah, and there's an existing conversation that touches on labelgun over in #916.

@jwasilgeo
Copy link
Contributor

@freewheelCarto, I think this has been fixed with the latest release of v2.4.0. Can you double-check, please, at the original labeling docs demo page? I'm thinking it still may be useful to point to a 3rd party library like labelgun on that demo page to help folks find their way to dynamic labeling solutions.

@jwasilgeo
Copy link
Contributor

Closing. Believe to have been fixed in the release of v2.4.0.

@freewheelCarto
Copy link
Author

Sorry I never tested this out again - ended up going a different direction with that project. But when I have time I'll verify the fix. Thanks!

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

No branches or pull requests

2 participants