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

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -