Cannot change badges / colors of markers in file cabinet

I am manipulating here an example of a marker field radius:

https://www.mapbox.com/mapbox.js/example/v1.0.0/marker-radius-search/

to try to change the color / icon of the markers within a certain radius of a random point, but the colors do not change, despite the fact that the properties are registered as changed. Here is my code:

clusterLayer = L.mapbox.featureLayer('examples.map-h61e8o8e').on('ready', function(e) {
    clusterGroup = new L.MarkerClusterGroup({
      showCoverageOnHover: false,
      animateAddingMarkers: true
    });

    e.target.eachLayer(function(layer) {
        clusterGroup.addLayer(layer);
        layerArray.push(layer);
    });
    map.addLayer(clusterGroup);
});

window.setTimeout(eventFunction,eventTiming);

function eventFunction(){
  clusterLayer.setFilter(affectMarker);
}

function affectMarker(feature) {
  var fLat = feature.geometry.coordinates[1];
  var fLng = feature.geometry.coordinates[0];
  var fPt = L.latLng(fLat,fLng);
  var dist = eventPt.distanceTo(fPt);
  if (dist < eventRadius){
    feature.properties['marker-color'] = eventColorNegative;
    feature.properties['marker-symbol'] = 'danger';
  }
}

Why is this not working? I checked that it returns valid points.

Please note that the used MakiMarkers markers

+4
source share
1 answer

, , , , . -, setFilter eachLayer:

clusterLayer.eachLayer(affectMarker);

, setIcon:

layer.feature.properties['marker-color'] = eventColorNegative; layer.feature.properties['marker-symbol'] = 'danger'; layer.setIcon(L.mapbox.marker.icon(layer.feature.properties));

, MakiMarkers (, , Mapbox):

https://github.com/jseppi/Leaflet.MakiMarkers

:

layer.setIcon(L.MakiMarkers.icon({icon: "danger", color: eventColorNegative}));

+1

Source: https://habr.com/ru/post/1606425/


All Articles