[openstreetmap/openstreetmap-website] Generate maplibre styles from `layers.yml` (PR #6772)
Tom Hughes
notifications at github.com
Thu Feb 5 18:42:20 UTC 2026
@tomhughes commented on this pull request.
> @@ -20,4 +31,45 @@ def self.embed_definitions(layers_filename)
.select { |entry| entry["canEmbed"] }
.to_h { |entry| [entry["layerId"], entry.slice("leafletOsmId", "leafletOsmDarkId", "apikey").compact] }
end
+
+ def self.style_from_style_url(layer, key)
+ layer[key].sub("{apikey}", layer["apikey"] || "")
+ end
+
+ def self.style_from_tile_url(layer, key)
+ url_template = layer[key]
+ .sub("{r}", "{ratio}")
Why not just use `{ratio}` in the template? You already changed `{z}` to `{zoom}` to avoid having to rename it but then did the same thing again with `{r}`?
> ) => {
if (credit) layerOptions.attribution = makeAttribution(credit);
if (nameId) layerOptions.name = OSM.i18n.t(`javascripts.map.base.${nameId}`);
- if (OSM.isDarkMap() && L.OSM[leafletOsmDarkId]) {
- layerOptions.leafletOsmId = leafletOsmDarkId;
- } else if (L.OSM[leafletOsmId]) {
- layerOptions.leafletOsmId = leafletOsmId;
- } else {
- layerOptions.leafletOsmId = "TileLayer";
- }
-
- const layerConstructor = L.OSM[layerOptions.leafletOsmId];
+ const layerConstructor =
+ (OSM.isDarkMap() && L.OSM[leafletOsmDarkId]) ||
+ L.OSM[leafletOsmId] ||
+ L.OSM.TileLayer;
The back and forth on this is getting a bit silly... IIRC this was originally written as if/then/else then you changed it to an &&/|| chain then the maplibre conversion changed it back to if/then/else and now you're changing it back again...
Personally I have to say that as clever as your version might be I find the other one easier to read and reason about.
--
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/6772#pullrequestreview-3758615734
You are receiving this because you are subscribed to this thread.
Message ID: <openstreetmap/openstreetmap-website/pull/6772/review/3758615734 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20260205/0f0ddc72/attachment.htm>
More information about the rails-dev
mailing list