[openstreetmap/openstreetmap-website] Improve Open Graph previews (#2965)

Minh Nguyễn notifications at github.com
Sun Jul 16 00:04:34 UTC 2023


> As for maps - we could get creative. For example, we could include a tile that has the node on it, even if the node isn't centered. Or we can make our own internal static maps, by grabbing adjacent tiles and stitching them together and cropping the region of interest. That's how most scalable static map services work anyway.

> The fundamental problem is that unlike tiles every single usage of this is unique, so any caching is limited to that specific use because even if a second person tries to share roughly the same map they're not going to choose exactly the same area.

One way to avoid stitching – and the need for generating a new image – is to only return one existing tile image. If the tile identified by the URL is close enough to the center of the tile, return that tile. Otherwise, return the containing tile one zoom level out. The downside is that different features are visible at a lower zoom level, but this is more about giving a rough idea of the page’s contents anyways.

This still leaves another technical hurdle that I haven’t seen mentioned here yet. Most people are going to share a URL that expresses the x/y/z coordinates in the URL fragment (hash), not a real URL query string. This hash is normally interpreted by the site’s JavaScript. Open Graph clients don’t execute JavaScript, so it’s up to the server to come up with an image URL, but the server will never see the URL fragment. There is [an alternative syntax](https://www.openstreetmap.org/?zoom=10&lat=30&lon=-90) that predates the current website design, which uses the `zoom`, `lat`, and `lon` query parameters. However, nothing seems to use that syntax anymore, not even the share panel when you add a marker.

#2007 seems more feasible to me, because a URL to an element or changeset will contain the ID as part of the URL’s path, which the server does have access to.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/issues/2965#issuecomment-1636921971
You are receiving this because you are subscribed to this thread.

Message ID: <openstreetmap/openstreetmap-website/issues/2965/1636921971 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20230715/a9b43b08/attachment-0001.htm>


More information about the rails-dev mailing list