Icon(s) set by array

149 views
Skip to first unread message

Tom Leadbetter

unread,
Jun 25, 2013, 3:46:45 PM6/25/13
to leafl...@googlegroups.com
Hello. Having some issues setting a custom icon. Example here http://jsfiddle.net/X6RKK/

The array has a pin/location 'type' and this will drive the icon image.

The issue is when I try and set it at icon: iconType

it results in the an error
TypeError: t.icon.createIcon is not a function

Any ideas? If I change this to become 
icon: activity

then pins are plotted, so I think LeafIcon declaration is correct.

Thank you

Tom

Tom Leadbetter

unread,
Jun 25, 2013, 3:52:00 PM6/25/13
to leafl...@googlegroups.com
Also, I can't change the array setup. My task is to change the map from Google maps and I have no control over the data.

Though if I did, I suppose it should be like this?

Thanks

Tom Leadbetter

unread,
Jun 25, 2013, 3:55:14 PM6/25/13
to leafl...@googlegroups.com
And I can get around it with this


                {title: title, icon: new LeafIcon({iconUrl: 'path/images/icon-map-' + iconType + '.png'})})

But that doesn't 'feel' quite right, setting a new LeafIcon each time. The map could have dozens of pins.

R D

unread,
Jul 3, 2013, 6:35:00 PM7/3/13
to leafl...@googlegroups.com
When you were setting the types in the array you used strings instead of the actual variable name. 

    var locations = [
        {"title": "Activity title", "location":{"lat":51.5,"lng":-0.09}, "type": "activity"},
        {"title": "Location title", "location":{"lat":51.495,"lng":-0.083}, "type": "accommodation"}
    ]

removing the quotes worked for me :)

-RD
Reply all
Reply to author
Forward
0 new messages