-
-
Notifications
You must be signed in to change notification settings - Fork 126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Maplibre adapter should pass along attribution #247
Comments
I'm a bit torn on this because the size of metadata is unbounded. This is not a theoretical concern - tippecanoe automatically produces a |
Yes, that's unfortunate. For some numbers:
On the one hand, fetching the first 64 KiB should therefore allow reading the complete metadata in many situations. On the other hand, the current spec and implementation only fetch the first 16 KiB in order to read the header and root. So this could be achieved by increasing the length of this initial read. (The metadata could also be treated as a potentially-truncated JSON document to find the attribution, but that seems foolhardy.) |
Manipulating the attribution of the maplibre source after it has loaded is … sort of possible but feels hacky. If maplibre had native pmtiles support it would be more plausible for the source to quickly read the root to determine the extents and format, and then lazily fetch the metadata. |
@jleedev the 16kb was intentionally chosen to be conservative - we can expand this to 32kb or 64kb if we discover that's a better default, while remaining backwards compatible with old archives for "free". The reverse is not true (if we started with a 32kb fetch, and later changed it to be 16kb, we'd have to add logic and extra requests to deal with old archives) However, I don't think making predictions on metadata size to include them in the first 64kb is reliable. @acalcutt needs That would give you automatic attribution in the case you pass |
Regarding the API design, a hash parameter would be better than a query parameter ( Or we could add options to the |
Is your goal to make attribution appear automatically for all archives within a given application, or for a specific one? The Protocol constructor would work globally, the hash parameter would be specific to one (but could support all if it's a URL template) |
That's the question, isn't it. I think anyone who is loading some sort of dynamic data, or implementing an inspect control, would prefer to see the metadata. In alltheplaces we've encoded the build date into the attribution string; Americana has the planetiler replication timestamp in the metadata (at least in principle); an inspect control would like to get at the vector_layers array. Anyone who is using this protocol as a basemap for something else probably does not require it. For instance, they would hardcode the attribution string alongside the URL to their tiles, in their map style. This adapter currently has no options. Being able to specify options both globally and on a per-source basis sounds reasonable to me and would meet unanticipated use cases. It appears that passing along the |
Here's what it would look like for Adding a API surface to |
Also related to #239 |
Nice, I think that looks pretty sensible. |
Looks nice, can't wait to try it :-) I honestly hadn't even thought of the attribution. I include a datastamp in my generated files too, since it helps to just look and see a new map generated that day. |
TODO: confirm that the above works with non-remote URL sources, like a local FileSource. |
* pass metadata: true to new Protocol() to make an extra request and populate attribution + vector_layers
I changed my mind and will make it a protocol level option: #461 This means you cannot control the loading of metadata/attribution per source. That required using a It seems like the applications that are "inspectors" like https://github.com/maplibre/maplibre-gl-inspect will want to use Required for maplibre/maputnik#807 |
* simplify examples * update leaflet and maplibre versions * add maplibre_headers.html example for custom headers [#397]
Released in 3.2.0. See example: https://github.com/protomaps/PMTiles/blob/main/js/examples/maplibre.html#L23 |
PMTiles/js/adapters.ts
Lines 129 to 134 in 17583ae
Should also include:
attribution: m.attribution,
, wherem
is the result ofinstance.getMetadata()
. Or the TileJSON could be the entire metadata verbatim, plus the fields from the header.Maplibre would then be able to show the attribution automatically.
The text was updated successfully, but these errors were encountered: