Closed patrickarlt closed 2 years ago
Dear @patrickarlt and @jwasilgeo
Thank you very much for this fix! I was testing it and these are my findings after apply the fix:
var testIcons = {
'em curso': L.icon({
iconUrl: 'https://esri.github.io/esri-leaflet/img/red-triangle.png',
iconSize: [20, 20],
iconAnchor: [6, 6],
popupAnchor: [-3, -5],
}),
'em resolução': L.icon({
iconUrl: 'https://esri.github.io/esri-leaflet/img/orange-triangle.png',
iconSize: [20, 20],
iconAnchor: [6, 6],
popupAnchor: [-3, -5],
}),
'em conclusão': L.icon({
iconUrl: 'https://esri.github.io/esri-leaflet/img/yellow-triangle.png',
iconSize: [20, 20],
iconAnchor: [6, 6],
popupAnchor: [-3, -5],
}),
};
and then the icon is applied based on an attribute value:
function(geojson, latlng) {
return L.marker(latlng, {
icon: testIcons[geojson.properties.EstadoAgrupado.toLowerCase()]
});
}
The attribute is updated after this fix, but the symbol only changes if I refresh the browser. Sometimes I also see that the symbology changes randomly after some FeatureLayer.refresh()
requests, just like it happened with attributes and geometries before the fix. So it seems to me that the refresh to symbology is somehow missing.
Can you check it in your test case?
Thank you very much! Best regards, Pedro
I can reproduce the invalid symbology after an update and refresh. Below is a slightly modified debug case (starting from the debug code at the top here) that switches between 2 different attributes and symbols during the update operation.
@patrickarlt, your thoughts on commit ef8579b28e3a6470f97b634374a1417661a0b646, if that's the right spot--timing wise--to add a call to redraw()
?
@jwasilgeo It seems to work also in my debug case! Thank you very much!
@PedroVenancio I'm glad to hear it is working for you in your case.
We decided for now not to merge this PR as we need more time to consider the consequences of these changes (that in some cases this would lead to inefficient code and re-rendering on the map, especially with the added call to redraw()
), and then plan how we will improve upon it when using a FeatureServer layer that has editing enabled.
For your situation I recommend that your options are either:
yourLayer.redraw(yourFeatureUniqueID)
after the refresh, if you know the ID of the feature that gets updated.
yourLayer.refresh();
yourLayer.redraw(90210);
Hi @jwasilgeo
I've implemented your first proposal for now. If I see it causes some impact, I will change for the second proposal, but I hope you can check the impact and merge this (or a polished) PR in the meanwhile.
Thank you very much!
@PedroVenancio @jwasilgeo @gavinr I think we should merge this as is with https://github.com/Esri/esri-leaflet/commit/ef8579b28e3a6470f97b634374a1417661a0b646. There might be some performance hit because we will be updating features all the time but I think that is actually the proper behavior.
@patrickarlt @jwasilgeo @gavinr Thank you very much for the fix.
I must say that I've implemented https://github.com/Esri/esri-leaflet/pull/1304/commits/836caa241b9b61b8335ec77f80a5c389da86b5d3 and https://github.com/Esri/esri-leaflet/commit/ef8579b28e3a6470f97b634374a1417661a0b646 in my applications and I'm not seeing any performance hit. Maybe the impact can be greater when editing features, but I also think this is the proper behaviour.
Thanks again for your help!
This fixes
FeatureLayer.refresh()
for layers wheresimplifyFactor
is not set. Originally this was intended to update the geometry when a higher resolution geometry came in from the service but it also means that layers with edited geometries were missed byFeatureLayer.refresh()
Can be reproudced with the following HTML in the
debug
folder (originally from @gavinr):