Reputation: 2230
Does anyone know how to add ids to g:path elements in a leaflet Version >= 0.7? This is a example found on leaflet's site. I want to add an ID to the polygons being rendered here.
I have tried this:
var svg = d3.select(map.getPanes().overlayPane).append("svg"),
g = svg.append("g").attr("id", "my_id");
And another question related to this was asked here: Leaflet path: how can I set a css class? And this question did not receive a correct answer. Does anyone have any ideas? It seems like a trivial thing i hate to ask the community about it, but i can't find a way to do it without completely ripping apart me existing code and rebuilding it with this.
Thank you in advance.
Upvotes: 1
Views: 2901
Reputation: 2230
@AmeliaBR You were correct, thanks so much. This code:
buildMapData(statesData);
d3.select(map.getPanes().overlayPane).selectAll("g").attr("class", "my_class");
Thanks also to @Lars Kotthoff for recommending the above code that works when placed after the code that builds the map. This issue was order of execution.
Upvotes: 1