OSM's usage policy states (https://operations.osmfoundation.org/policies/tiles/):
"Recommended: Do not hardcode any URL to tile.openstreetmap.org as doing so will limit your ability to react if the service is disrupted or blocked. In particular, switching should be possible without requiring a software update."
I am wondering 1) what is referred to in this passage and 2) how to avoid it.
I am guessing something like the following would be considered "hardcoding a URL to tile.openstreetmap.org".
var map = L.map('mapid', {
center: [39.3, -76.60],
zoom: 11,
minZoom: 3,
maxZoom: 15,
layers: [
L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
attribution:
'© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
})
]
});
If so, what's the proper alternative in this case?
This mainly means that the tiles provided by the OSMF may cease to be served (in general or for you) at any time, be it because of technical reasons or policy reasons or capacity reasons.
Now as a software developer you should be able to therefore switch the tile provider at any time.
Several examples:
By the way, the TileLayerURL should be
https://tile.openstreetmap.org/{z}/{x}/{y}.png
as the OSMF is trying to get away from the (a|b|c) subdomains. And here you already see the problem: if you would have used your old TileLayerURL and the OSMF would start to stop serving requests against (a|b|c).tile.osm.org, you wouldn't get a map anymore.