Leaflet.VectorGrid icon indicating copy to clipboard operation
Leaflet.VectorGrid copied to clipboard

Adding labels instead of circle markers for place

Open albanm opened this issue 8 years ago • 5 comments

Hello,

I can't find this in the documentation. Is it possible to add points with some textual property as leaflet labels (or small texts of anykind) instead of markers ?

I guess it should be possible to use the style function to add an item in a label layer instead of returning a style. But I don't see a way to access the coordinates of the point in this function.

Thanks a lot for this awesome project !

albanm avatar Jan 31 '17 13:01 albanm

Hi @albanm, this is not currently possible - points can be styled as CircleMarkers or Icons, nothing else.

Doing what you propose would be somewhat tricky: VectorGrid uses tiles with SVG or Canvas rendering, and naively adding labels to those would most certainly clip them in an undesirable way. Adding them as normal Leaflet layers would, on the other hand, change much of how VectorGrid basic design (a tile grid).

What I think we could do, is exposing something similar to L.GeoJSON's oneachfeature option, to allow users to hook on any logic they want; for that, we would also need a mechanism so that users can also clean up when features in tiles are removed.

perliedman avatar Jan 31 '17 13:01 perliedman

@perliedman If a point can be styled with an Icon, can a DivIcon be used instead? If so, there's the text labels.

IvanSanchez avatar Jan 31 '17 13:01 IvanSanchez

@IvanSanchez no, at the moment we just take the icon image and draw it onto the canvas (or use an SVG image), so we're not even handling shadows or so...

I perceive VectorGrid's primary use case as "render a lot of things with decent performance", and adding one or more DOM elements per feature seems to go against this. But I realize there might be other reasons for using VectorGrid as well.

perliedman avatar Jan 31 '17 13:01 perliedman

Vector tiles are sure great for rendering lots of features. But what I am interested in mostly is client side styling and intelligent simplification. Anyway even with lots of features not all layers are equally dense, for example the 'place' or 'poi' layers in osm tiles are ok.

Providing a hook to let the client add whatever it wants on top of the features in the tiles would be great !

I am willing to work on a PR for this.

albanm avatar Jan 31 '17 13:01 albanm

Was a workaround for this ever implemented? I'd like to use it if so.

JulieGoldberg avatar Aug 20 '19 22:08 JulieGoldberg