tangrams / heightmapper

interactive heightmaps from terrain data
http://tangrams.github.io/heightmapper
MIT License
404 stars 118 forks source link

Add Export Renderer #32

Closed AndrewMcShane closed 2 years ago

AndrewMcShane commented 2 years ago

This PR is to add in the ability to render at higher resolutions than the screen by stitching together many smaller renders, satisfying the 2nd TODO item.

meetar commented 2 years ago

Wow @AndrewMcShane, this is very cool! I like the solution you came up with here – unfortunately so far I'm not getting the results from this that I would expect, I think fitBounds() may not be doing what it's supposed to in all circumstances? For instance with a multiplier of 2 I'm not seeing the zoom level change at all... I'll be able to take a closer look at this later this week, it's completely possible it's some quirk of my setup. But either way – Thank you!

AndrewMcShane commented 2 years ago

I was having some issues with this, and I had to make sure to reload the page before rendering. I'll take another whack at it later this week and clean it up.

AndrewMcShane commented 2 years ago

I discovered two issues upon some debugging:

The first was calculating latitude and longitude using layerPointToLatLng, but I needed to be using containerPointToLatLng. This was causing the map to jump around if you moved it before a render.

The second issue I've left as a gotcha in the readme for the time being; when the view is larger than the bounds of the map (showing white background), the renderer will struggle because it's trying to convert screen pixels to coordinates that are outside the map. Luckily the mercator projection is a 1.65 aspect ratio where the average monitor is 1.77, so one can at least render the whole map 😄

meetar commented 2 years ago

Looks good, thanks again @AndrewMcShane!