Examples of L.divIcon Usage?

1,068 views
Skip to first unread message

Arnie Shore

unread,
Aug 28, 2012, 7:31:26 AM8/28/12
to leafl...@googlegroups.com
I'll appreciate any examples or JS snippets of divIcon usage. The
documentation seems pretty sparse on that, and it looks very useful to
my project. Thanks, all.

AS

William Fendler

unread,
Aug 29, 2012, 12:07:38 AM8/29/12
to leafl...@googlegroups.com
This snippet esists in a $.each loop going through some JSON data. The object gets a different class depending on the category it has, it also gets a class with an id so I can later associate other objects in the DOM with that placemarker to call .openPopup() on it and whatnot.

if(iCategory === 'cocktails') {
    var myIcon = L.divIcon({className: 'placemark placemark-cocktails id-' + theId});
} else if(iCategory === 'coffee') {
    var myIcon = L.divIcon({className: 'placemark placemark-coffee id-' + theId});
}
var marker = new L.Marker(latLng, {icon: myIcon});

map.addLayer(marker);

Hope this helps!
Reply all
Reply to author
Forward
0 new messages