Add a button to the minimap to export the current view as an image (#219) #226
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This contains what's essentially a rewrite of the
leaflet-imageplugin. That plugin mostly worked, but didn't handle fractional zooms and some of the transforms that (newer versions of?)Leafletuses.Note that this only exports the map tile layer and the overlay layer. Markers are not exported. They're html markers that contain
svgelements, which don't seem to be easy to render to a canvas. I can probably figure out how to include them in the future, but this seemed like a good start.TileLayerto provide the ability to render to a canvasMapto composite any tile layers and overlays as canvasesmap.exportToCanvasto get an canvas representation of the current viewport. This will save asexport.pngwhen no save is loaded, or as<save name>.pngif there is a saveSCIMobject, which seems strange to access from a control installed byGameMapThis addresses the core functionality of #219. There's a lot more I could do here to enable automation of multiple save games, etc, but I figured this was a good starting point.
A screenshot (captured with the OS screenshot tool) of the test map with some random zooms/pans applied after loading:
Note the new button!
The exported image of the same viewport, created by clicking the new button:
Note about the above images: I captured the first screenshot on a Mac with a retina display, so it's "upscaled" . The display size of both images is actually identical on the device itself.