MediaWiki talk:Gadget-maps.js

From the AARoads Wiki: Read about the road before you go
Jump to navigation Jump to search

Attribution

The code on this page was originally published by Minh Nguyen on the OpenStreetMap wiki, and is used here under CC-BY-SA 2.0. —Scott5114 [EXACT CHANGE ONLY] 22:27, 19 July 2023 (EDT)

USRD layer configuration

To use the USRD color scheme being developed in [1], a couple changes are needed towards the top of MediaWiki:Gadget-maps.js:

  1. ext.gadget.maps.scriptServer was reverted by accident in Special:Diff/75577, but it needs to be set to wiki.aaroads.com or the shields won't load:
    mw.config.set("ext.gadget.maps.scriptServer", "//wiki.aaroads.com");
    
  2. Add this entry for the USRD layer to the same object that currently defines other layers like americana, around line 42:
    	usrd: {
    		style: "https://1ec5.github.io/openstreetmap-americana/style.json",
    		afterLoad: ["installShields"],
    	},
    

Once that's in place, {{map}} should default |data-layer= to usrd rather than americana.

 – Minh Nguyễn 💬 02:40, 24 July 2023 (EDT)

Multiple GeoJSON overlays

BMACS1002: Thanks for implementing the multiple GeoJSON overlays in Special:Diff/77656/129030. Unfortunately, I think this only adds the map data file with the first title alphabetically to the map. Also, if this project intends to be accessible to screen readers, then it's problematic to stuff raw JSON source code as plain text in the wiki page, even if we use CSS to hide it.

I took an alternative approach in [2] and [3]: each numbered parameter inserts an empty placeholder <span> inside the placeholder <div containing additional attributes about an overlay. No text nodes are added, so this should be fine for accessibility. In the future, we'll be able to add more parameters about a particular overlay as attributes on these spans. Meanwhile, the OSM Wiki version of the gadget now iterates over all the returned JSON files and adds each one as a separate source and layer.

In general, I think editors should strongly consider consolidating the data they want to overlay into a single file and uploading that to Commons. This multiple overlay support may be useful for getting around the file size limit on Commons, but it's unclear to me if the API will allow downloading that much more data at one time anyways. It would be better to focus on simplifying the GeoJSON data. Long-term, I think we'd probably want to use the Overpass API plus osmtogeojson for the most complex data needs, but simplified GeoJSON on Commons is still the way to go for large amounts of data that isn't likely to change often.

 – Minh Nguyễn 💬 05:18, 11 August 2023 (EDT)

Update Historic stylesheet URL

@BMACS1002: Can you apply OSM:Special:Diff/2716578 to this gadget? OHM moved the stylesheet to a less weird URL yesterday, but this broke a few OHM-based maps on this wiki, like the one at Fort Washington Way. – Minh Nguyễn 💬 19:33, 5 June 2024 (EDT)

Fix shield loading

Can an administrator implement these changes to fix shields on the map? Thanks! – Minh Nguyễn 💬 04:28, 9 June 2024 (EDT)

Done! —Scott5114 [EXACT CHANGE ONLY] 04:41, 9 June 2024 (EDT)

Update OHM stylesheet URLs

Can an administrator apply OSM:Special:Diff/2717631/2720497 to this gadget? OHM moved the stylesheets yet again, hopefully for the last time. The previous URLs work but serve up outdated tiles, and the tiles are entirely missing at high zoom levels. – Minh Nguyễn 💬 21:29, 18 June 2024 (EDT)

Desaturate road colors when overlay is present

GeoJSON overlays often clash with the AARW basemap because there isn’t enough contrast between the road colors in the stylesheet and the road colors in the GeoJSON. Of the two, the GeoJSON should have the bolder colors, but the stylesheet already chooses very saturated colors. This gadget could use the runtime styling API to find each the line layer based on the transportation tile layer and modify its line-color property to be less saturated. The style specification has several color-related expression operators, though I’m unsure if it’s enough for us to generically desaturate colors without having to hard-code specific colors. As an alternative, the stylesheet itself could come with alternative, desaturated layers that are hidden by default. – Minh Nguyễn 💬 11:58, 15 July 2024 (EDT)