walkerke / mapgl

R interface to Mapbox GL JS v3 and Maplibre GL JS
https://walker-data.com/mapgl
Other
91 stars 5 forks source link

More new feature requests :) -- synced maps and save static image button #11

Open kmcd39 opened 4 months ago

kmcd39 commented 4 months ago

Requesting some other new features that seem implementable in maplibre/mapbox js gl!

Thanks for the "before_id" addition based on the other issue :) this is getting cool, fast.

walkerke commented 4 months ago

I think all of those will be possible at some point. The compare() function (tracking in #1) does sync maps, but doesn't show them side-by-side; I'll probably try at some point to include an option to swipe between maps or sync them.

The print button is a little trickier as I'd need to code that from scratch; I don't see a plugin for it. But it'd be useful to have at some point!

CIOData commented 2 months ago

Are there any updates on image saving? I have recoded an application we host to do all of its mapping in mapgl, but I'm not going to be able to deploy it without having some way for individuals to download images of the map. I wonder if it is possible to co-opt the orca() function from plotly to do this?

CIOData commented 2 months ago

Are there any updates on image saving? I have recoded an application we host to do all of its mapping in mapgl, but I'm not going to be able to deploy it without having some way for individuals to download images of the map. I wonder if it is possible to co-opt the orca() function from plotly to do this?

Actually, I believe I have solved this. By passing the parameter, preserveDrawingBuffer = TRUE to the mapboxgl() function, I was able to download images of the map using the capture() package. I have not tried it with any others yet (e.g. shinyscreenshot()).

CIOData commented 2 months ago

Just to update, this also works with the shinyscreenshot package, but there seems to be a little loss of fidelity (some pixels missing) and it places the image on a white background even when there is no background on the map. I'm not sure if this is typical of shinyscreenshot or not because I don't generally use this package.

With capture

cif_map

With shinyscreenshot

shinyscreenshot

walkerke commented 2 months ago

Thanks! I like the look of capture(). I wonder if something similar to this could be integrated into the package with a print button.

CIOData commented 2 months ago

Probably. They're just using html2canvas. There are a handful of functions like that on GitHub. But the key is the preserveDrawingBuffer so that the graphics layer renders.

Sent via the Samsung Galaxy S22 Ultra 5G, an AT&T 5G smartphone Get Outlook for Androidhttps://aka.ms/AAb9ysg


From: Kyle Walker @.> Sent: Saturday, September 21, 2024 1:20:39 PM To: walkerke/mapgl @.> Cc: CIO Data @.>; Comment @.> Subject: Re: [walkerke/mapgl] More new feature requests :) -- synced maps and save static image button (Issue #11)

CAUTION: External Sender

Thanks! I like the look of capture(). I wonder if something similar to this could be integrated into the package with a print button.

— Reply to this email directly, view it on GitHubhttps://github.com/walkerke/mapgl/issues/11#issuecomment-2365259249, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AV63ITZ327BXCACNQ2QVYQTZXWTGPAVCNFSM6AAAAABKKGTBA2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNRVGI2TSMRUHE. You are receiving this because you commented.Message ID: @.***>