简体   繁体   中英

Leaflet id properties

How do I assign id tags to leaflet polylines so that I can show/hide or do other operations on them later? I'll have around 100+ polylines. Is there a way I can set an id property to it?

Also I noticed the leaflet module has a leaflet-src.js file in it. Can I add the property to the L.Polyline using this.ident and add it while constructing the polyline in the html file?

When you create a new L.Polyline , you can add a id key to the options hash which you can then operate on/inspect later while looping through the featureGroup or other more vanilla JavaScript grouping that contains it.

http://leafletjs.com/reference.html#polyline-l.polyline

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM