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++ - llvm function pass ReplaceInstWithInst malloc -

Cross-Compiling Linux Kernel for Raspberry Pi - ${CCPREFIX}gcc -v does not work -

java.lang.NoClassDefFoundError When Creating New Android Project -