Skip to content
This repository was archived by the owner on Sep 20, 2019. It is now read-only.

ui-leaflet analog for bindLabel functionality? #359

Closed
CodeWarrior-Hawaii opened this issue Oct 24, 2018 · 1 comment
Closed

ui-leaflet analog for bindLabel functionality? #359

CodeWarrior-Hawaii opened this issue Oct 24, 2018 · 1 comment

Comments

@CodeWarrior-Hawaii
Copy link

CodeWarrior-Hawaii commented Oct 24, 2018

I am porting a map project over to ui-leaflet from "vanilla" leaflet. I have come too far to turn back now. I cannot for the life of me figure out how one is supposed to modify marker labels.

In this case, I am trying to change the marker labels so that they are mouseOver popups with custom styling:
OLD CODE
https://pastebin.com/1jCWzPND

The above code is switching on a string type name for the marker items to determine what styling is going to go on them.

NEW CODE
Init Map
https://pastebin.com/T6vXRgRj

Get Points
https://pastebin.com/T3KN9qTf

In this new project using ui-leaflet, I am getting json data from a database and setting the title, lat lng and so forth, as well as the group (by name).

How do I set the label in the way that the bindLabel call above did?

@CodeWarrior-Hawaii
Copy link
Author

I have worked around this in the following way:

leafletData.getMap().then(function(map){ map.on("layeradd", function(layer){ if(layer.layer.dragging){//Its a marker layer.layer.bindTooltip(layer.layer.options.PointName,{ direction: 'bottom', offset: L.point(0, 15) }) } }); });

This gets the Leaflet map object, then iterates through the layers (this includes L.Markers which are derived from L.Layer). For each Marker (by checking the existence of the "dragging" property, I call bindTooltip, give it the text and options.

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

No branches or pull requests

1 participant