Closed dracos closed 3 years ago
This is so classy. Thank for you this.
I think this can be taken further. I love the Google Maps Static API - https://developers.google.com/maps/documentation/maps-static/overview - both for covering non-JavaScript cases and because it's a much more efficient way to drop a simple map on a page without loading a JavaScript library.
It strikes me that a very simple version of that - where you pass a size, bounding box and maybe even a marker or two - could be supported by this plugin. Loading a few tiles from SQLite, stitching them together into a new image using Pillow and serving the result feels like it might not be a big push.
And then people could serve their own version of the static maps API using their own tiles!
Your https://datasette-tiles-demo.datasette.io/-/tiles/japan-toner page has all the information needed (ie. a lat/lon) to output some tile URLs directly so that a map is shown rather than a blank screen if JS does not function for whatever reason. For example, https://www.fixmystreet.com/around?zoom=2&lat=51.38488&lon=-2.36197 without JavaScript still loads a map that you can pan and zoom. You can see the utility functions that provide latlon/tile conversions at https://github.com/mysociety/fixmystreet/blob/08a1469538/perllib/FixMyStreet/Map/OSM.pm#L133-L200