Skip to content
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

Requiring OSM attribution at runtime #9228

Open
opk12 opened this issue Jan 24, 2024 · 9 comments
Open

Requiring OSM attribution at runtime #9228

opk12 opened this issue Jan 24, 2024 · 9 comments

Comments

@opk12
Copy link

opk12 commented Jan 24, 2024

Motivation

The Quick Start is explicit that the OpenStreetMap attribution is mandatory. In the common case that OSM's official tile server is used, the lib can check at runtime to provide an attribution, to benefit the developer and OSM.

Suggested solution

What about providing a default attribution, or giving an error, if the domain is any of tile.openstreetmap.org or tile.osm.org and the attribution is absent?

Additional context

I am an OSM contributor and hear cases of missing attribution with the OSM official tile server every now and then; so many that a repo was recently set up to keep track of them, and this includes cases where Leaflet is used.

@opk12 opk12 added feature needs triage Triage pending labels Jan 24, 2024
@mourner
Copy link
Member

mourner commented Jan 24, 2024

Actually, providing a default OSM attribution when none is provided and tile.openstreetmap.org is used sounds like a neat idea. It's a common pitfall and this seems rather harmless — people who need the attribution to be empty for whatever reason (e.g. attribution is on a different visible part of the page) can do so explicitly by passing attribution: ''. This can be considered a breaking change though. @jonkoops @Falke-Design @IvanSanchez what do you guys think?

@mourner mourner added needs discussion and removed needs triage Triage pending labels Jan 24, 2024
@IvanSanchez
Copy link
Member

@mourner Given the sheer amount of Leaflet users that (a) are newbies and (b) use OSM tiles, this seems like a nice idea indeed. The cost in terms of codebase size is negligible IMO.

(There is an alternative, which I can call "The OpenLayers Way": provide a L.TileLayer.OSM, a la leaflet-providers. But I think it goes against Leaflet tradition of tile URL templates all around)

Disclaimer: I have been in the OSMF (loooong ago), so I'm understandably biased in favour of OSM.

@matkoniecz
Copy link
Contributor

matkoniecz commented Jan 25, 2024

tile.openstreetmap.org or tile.osm.org

likely the same for a.tile.openstreetmap.org / b.tile.openstreetmap.org / c.tile.openstreetmap.org deprecated addressing ( openstreetmap/operations#737 )

Disclaimer: I am really active in OSM community

@jonkoops
Copy link
Collaborator

jonkoops commented Jan 25, 2024

I think we could parse the URL of the tile-server in general and match it against a couple of known domains:

const url = new URL('https://tile.openstreetmap.org/{z}/{x}/{y}.png');
const osmHosts = ['tile.openstreetmap.org', 'tile.osm.org'];
const isOsmUrl = osmHosts.some((host) => url.hostname.endsWith(host));

@Falke-Design
Copy link
Member

I think adding the attribution automatically can be our part to the OSM Community.

This can be considered a breaking change though

Let us add it in v2 and then it is no problem.

const url = new URL('https://tile.openstreetmap.org/{z}/{x}/{y}.png');

Instead of creating a URL object, we could just check if the url-string contains the hosts. Maybe we should create a performance test. If the URL is faster or only slightly slower, let us use the URL object because it is cleaner.

I would suggest to label it as accepted and good first issue Good for newcomers

@IvanSanchez
Copy link
Member

Instead of creating a URL object, we could just check if the url-string contains the hosts. Maybe we should create a performance test.

It's a one-off check (when a L.TileLayer is instantiated), so I wouldn't worry about perf issues.

I say URL() plus regexp.

@jieter
Copy link
Contributor

jieter commented Jan 31, 2024

I understand the importance of attribution, but I think adding attribution in the leaflet attribution control is not required. It can also be attributed in another part of the page right?

Would a Leaflet user be able to do that if this change is added?

@matkoniecz
Copy link
Contributor

people who need the attribution to be empty for whatever reason (e.g. attribution is on a different visible part of the page) can do so explicitly by passing attribution: ''.

#9228 (comment)

@opk12
Copy link
Author

opk12 commented Feb 1, 2024

I understand the importance of attribution, but I think adding attribution in the leaflet attribution control is not required. It can also be attributed in another part of the page right?

Sure, the official OSMF attribution guidelines make it clear that, by the time the user sees the map, she must have already been exposed to the attribution, as we can infer from this:

The base requirement in ODbL is attribution that is “…reasonably calculated to make any Person that uses, views, accesses, interacts with, or is otherwise exposed to the Produced Work aware that Content was obtained from [OpenStreetMap] …”.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants