I have modified the leaflet.js to return the visible layers information when it is queried along with the view center point issue because I'd like to rerender the map with new information (using a htmlwidgets::onRender(...), which in my instance, does not work via leafletProxy. However, I'd like keep the same view both in terms of location and visible layers. The problem is the list of visible layers does not update when different layers are selected on the control, but only when the map is zoomed upon or moved by the mouse. So if I changed some information to rerender the map, but did not move/zoom the map between changing the initial render, and rerender, but DID change the visible layers, this information can't be captured.
Here is what I changed in the leaflet.js:
function updateBounds(map) {
var id = map.getContainer().id;
var bounds = map.getBounds();
var throwaway = Math.random();
_shiny2.default.onInputChange(id + "_bounds", {
north: bounds.getNorthEast().lat,
east: bounds.getNorthEast().lng,
south: bounds.getSouthWest().lat,
west: bounds.getSouthWest().lng
});
_shiny2.default.onInputChange(id + "_center", {
lng: map.getCenter().lng,
lat: map.getCenter().lat,
layer: map.layerManager.getVisibleGroups() //added this to get layer info in '_center' return
});
_shiny2.default.onInputChange(id + "_zoom", map.getZoom());
}
This issue demonstrates what was described here. I added js code to get layer information, but that information doesn't update dynamically with layer selection, only with map movements and zooms.
I have modified the leaflet.js to return the visible layers information when it is queried along with the view center point issue because I'd like to rerender the map with new information (using a
htmlwidgets::onRender(...)
, which in my instance, does not work via leafletProxy. However, I'd like keep the same view both in terms of location and visible layers. The problem is the list of visible layers does not update when different layers are selected on the control, but only when the map is zoomed upon or moved by the mouse. So if I changed some information to rerender the map, but did not move/zoom the map between changing the initial render, and rerender, but DID change the visible layers, this information can't be captured.Here is what I changed in the leaflet.js:
Here is a reproducible example:
Here I walk through what I see and what the console prints after hitting the 'print map info' button.
initial map (all visible)
tiles 1 and 3 visible
tiles 1 and 3 visible, zoomed in by one mag.
tiles 1 set visible, no zooming or map movement
tiles 1 set visible, move map slightly
Any help would be appreciated to update the map whenever layers are changed.