tmap
tmap copied to clipboard
Prevent opening new tab for each viewed map
tmap in view mode opens a new tab for each viewed map. Eventually I get annoyed and have to click-close forty tabs...
Could a method be implemented so that maps showed in the same tab? I don't think its possible from R to cause a current existing browser tab to open a new URL or refresh its current URL (not in an easy cross-platform multi-browser way) so instead I think you have to write the HTML to the same location and the user would have to manually refresh unless the HTML contained one of those clever auto-refresh javascripts...
This could be part of a new "mode", tmap_mode(mode="server")
, which saves the HTML to a location, starts a local server on a high port and then opens the browser to that URL. Subsequent maps overwrite at that location and the browser would refresh (with an auto-refresh script).
Having multiple servers open would be even better - like having multiple graphics devices - with the opportunity to send a map to one or another via the tm_server()
function.
Looking at the code it doesn't look too simple since tmap:::tmap_print
ends up in htmlwidgets
print method which prints to a new temp file every time with no possibility of control, but I think some intervention in tmap_print
to grab the HTML and stash it in a known location if mode=="server"
could do it.
I'll fork it and think about it - but does it sound like a good idea?
@barryrowlingson we use something like you suggest in mapview::startWatching. This uses servr::httw
watch a index.html
file. IIRC, I needed to adjust the print
method to work with this. Not sure if this is of any help, but may be a starting point
@barryrowlingson feel free to reopen the issue if you made any progress