javascript - Changing marker-color in mapbox when markerLayer loaded through loadURL function -
i'm loading markerlayer using mapbox loadurl function. works fine , i'm able access marker properties, doesn't seem work changing color of markers.
var markerlayer = l.mapbox.markerlayer(); markerlayer.loadurl('geojson.php?lat='+lat+'&lng='+lng) .addto(map); markerlayer.on('click',function(e) { e.layer.unbindpopup(); var feature = e.layer.feature; var info = '<h2>' + feature.properties.name + '</h2>' + '<p>' + feature.properties.description + '</p>'; document.getelementbyid('info').innerhtml = info; feature.properties['old-color'] = feature.properties['marker-color']; feature.properties['marker-color'] = '#000'; });
why not work , how go changing color of marker using geojson data loaded url? posted example depends on geojson data wasn't loaded using loadurl. suspect has reason why marker colors not change.
changing properties of feature can't automatically change icon - you'll need call seticon
, like:
e.layer.seticon(l.mapbox.marker.icon(feature.properties));
Comments
Post a Comment