javascript - Mapbox single marker change color onclick -


iam wondering how change marker color using onclick function. im trying achieve in way: wrong...can me??

var testmarker = l.marker([74.18, -15.56], {       icon: l.mapbox.marker.icon({         'marker-color': '#9c89cc'       })     })     .bindpopup(testmarker)     .addto(map); testmarker.on('click', function(e) { l.marker(setcolor('red'));  

use seticon method of l.marker in click handler set new icon:

changes marker icon.

http://leafletjs.com/reference.html#marker-seticon

testmarker.on('click', function() {     this.seticon(         l.mapbox.marker.icon({             'marker-color': 'red'         })     ); }); 

Comments

Popular posts from this blog

c - How to retrieve a variable from the Apache configuration inside the module? -

c# - Constructor arguments cannot be passed for interface mocks -

python - malformed header from script index.py Bad header -