Change marker icon on click leaflet -
original-markericon = leaflet/images/marker-icon-2x.png current-markericon = leaflet/images/map-marker.png
i have many markers , want change marker icon of current clicked marker.if click again on marker change marker icon original marker , current marker current icon.
i have label attached each marker. when click on current icon want change label of marker or remove label.
how can achieve ?
thank you. image marker visible original-markericon
edit-1
l.icon.change = l.icon.default.extend({ options: { iconurl: 'leaflet/images/map-marker.png', iconsize: new l.point(150, 75), } }); var changeicon = new l.icon.change(); l.icon.original = l.icon.default.extend({ options: { iconurl: 'leaflet/images/marker-icon-2x.png', iconsize: new l.point(45, 81), } }); var originalicon = new l.icon.original(); marker.on('click',function(e){ for(var = 0 ; < $scope.markers.length ; i++){ $scope.markers[i].seticon(originalicon); } }) // marker click event show center pano $scope.markers[index].on('click',function(e){ $scope.markers[index].seticon(changeicon); });
if not mistaking there function named "eachlayer" in map. think when create marker, leaflet gives automatic id that. have give id in "eachlayer" function. , when finds appropriate marker, there should function "popupclose". add better if show code...!
wiki
Comments
Post a Comment