Makin-Things / bom-radar-card

A rain radar card using the new tiled images from the Australian BOM
https://github.com/makin-things/bom-radar-card
MIT License
98 stars 9 forks source link

Add option to set aspect ratio or pixel height of map #10

Closed teleksterling closed 3 years ago

teleksterling commented 3 years ago

Is your feature request related to a problem? Please describe. I find that the card looks great when the columns are wide, but on narrow columns the map is very tall, and because the zoom controls seem to be based on the height of the map, the sides of the map are cropped from the frame. This means I have a narrower view of approaching weather from the west.

Describe the solution you'd like I'd like an option to set the map aspect ratio. Then as the column is narrowed, the map would shrink in height too, retaining the same map view extents, shrinking the map.

Describe alternatives you've considered

Additional context Here is the view of the card when I have a full screen browser window: image

And this is the less preferable view, created by changing the browser window width: image

In writing this I've also realised that my suggestion may conflict with the way the input is defined by zoom level and the map loaded as a bitmap - the card isn't doing any scaling currently, and if you do so, the image won't be as crisp. Would you need to dynamically switch between zoom levels? I'm not sure!

theOzzieRat commented 3 years ago

This is a tricky one and there probably isn't a good solution. The loading of the map tiles is managed by the leaflet.js library, it gets passed the window size and zoom level it then figures out what to download an display (cropping the tiles as needed). The whole concept of using tiles is that they are available at varying zoom levels so that scaling of the images is not required (that also results in crappy images as per the old radar card that scaled a 512px wide image to fit in a 500px column). II will think about it more, but at this stage the only option I can think of is to add an option that you can set that would decrease the starting zoom level by 1 when a narrow column is detected.

teleksterling commented 3 years ago

That may be the case!

Thinking about it some more, I think either way I'd still want to be able to set the aspect ratio so that I don't get the tall skinny maps.

I haven't tested, but I guess the opposite could happen if you chose panel mode - you could get a very wide map, but be unable to make it taller.

Actually, now I have: image

theOzzieRat commented 3 years ago

Fixed in 1.30b (pre-release). Will do a production release later this week.