-1

I need to generate a javascript alert with State name text (or store it in a variable) when user mouseover on interactive choropleth map poligons (like this map) http://leafletjs.com/examples/choropleth.html

i try to store content of div class="info leaflet-control" but without success

thanks a lot!


I create this jquery code thanks to this post

$(".info.leaflet-control").bind("DOMSubtreeModified", function() { console.log($(".info.leaflet-control").find( "b" ).text()); });

and works!

Community
  • 1
  • 1
Marco Scarselli
  • 1,154
  • 2
  • 11
  • 27
  • I create this jquery code and work! `$(".info.leaflet-control").bind("DOMSubtreeModified", function() { console.log($(".info.leaflet-control").find( "b" ).text()); });` – Marco Scarselli Jun 10 '16 at 11:53

1 Answers1

1

Forget about jQuery, and use Leaflet event handling, to attach an event handler to the mouseover event on the features you want to watch. The event received will hold all properties of the features that triggered the event.

See http://playground-leaflet.rhcloud.com/buh/edit?html,output

IvanSanchez
  • 18,272
  • 3
  • 30
  • 45