Page MenuHomePhabricator

Set correct text color for Kartographer markers in Wikivoyage mode
Closed, ResolvedPublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

  • At the English Wikivoyage: Look for a listing template, for instance in the Aalst article in the Understand section. Edit it without saving by adding the parameter | type = gold to this template and preview it. A gold background occurs but the text writing is white (and not black).
  • At the German Wikivoyage: Take an article with a religious institution, for instance the article of Wettin to the "Kirchen" (churches) section. The marker backgrounds are orange and the text color is black by a user Lua script. With the browser's inspector click on such a marker. Go to the a.mw-kartographer-maplink tag and unmark the rule: .mw-parser-output .listing-map-inverse .mw-kartographer-maplink: color: #000 !important; The the text color will become white instead of black.
  • The magenta pushpin marker as created and stored by the Wikimedia's map server is maybe wrong. The text color should be black, not white, see for instance: https://de.wikivoyage.org/wiki/Modul:Marker_utilities/Groups/Doku#Group_overview.

What happens?:

  • In any case, the text color of Wikivoyage markers is white. This is done by CSS rules setting the link text color to white.

What should have happened instead?:

  • Depending on the background color, the text color should be black or white like the text color of the pushpin markers on the maps. The color should not be changed by mouse hover actions.

Other information (browser name/version, screenshots, etc.):

Proposed solution

  • Add not only the background color, but also the text color to a.mw-kartographer-autostyled (see MapLinkAttributeGenerator.php, lines 52-55)
  • You have to calculate the relative luminance of the background color, see for instance Makizushi’s code for markers. Above a definite threshold the text color should be black.

What's the definite threshold?

  • A good question, because it is handled in the Kartographer script and on the Wikimedia's map server in different ways. Makizushi and adamwight proposed a value of about 0.211 . But on the map server at which the map-marker icons are created and stored there seems to be a higher threshold.
  • See for instance on https://de.wikivoyage.org/wiki/Modul:Marker_utilities/Groups. The first icon on the map is a magenta icon (#FF00FF). Due to Makizushi et al the text color should be black but it is white. That's why I was setting the Wikivoyage's threshold to 0.2848 (relative luminance of magenta) so the text color keeps to be white.

Event Timeline

The addition of the text color to a.mw-kartographer-autostyled tag would solve the problem of some 100,000 false positives as described in task T369282.

Aklapper renamed this task from Set corect text color for Kartographer markers in Wikivoyage mode to Set correct text color for Kartographer markers in Wikivoyage mode.Jul 7 2024, 1:54 PM
Aklapper removed a project: WMDE-GeoInfo-FocusArea.

(Not sure why an archived project tag was added here?)

Change #1193546 had a related patch set uploaded (by Thiemo Kreuz (WMDE); author: Thiemo Kreuz (WMDE)):

[mediawiki/extensions/Kartographer@master] Expose pin foreground color for WCAG compliance

https://gerrit.wikimedia.org/r/1193546

Change #1193546 merged by jenkins-bot:

[mediawiki/extensions/Kartographer@master] Expose pin foreground color for WCAG compliance

https://gerrit.wikimedia.org/r/1193546

I think we should propose something for the TechNews. It should say something like: On Wikivoyage wikis (the feature doesn't exist anywhere else) colored <maplink> in the article will be shown with their correct text color, instead of only their background color. The community can remove local TemplateStyles and such that currently work around the problem. However, it might be better to do this 1 month later after the relevant caches expired.

Here is a minimal example you can try on Wikivoyage to see the problem:

<maplink latitude=10 longitude=20 zoom=13>[
{
	"type": "Feature",
	"geometry": {
		"type": "Point",
		"coordinates": [-122, 37]
	},
	"properties": {
		"marker-symbol": "-letter",
		"marker-color": "#ee0"
	}
}
]</maplink>

In this demo the marker is almost invisible because it is white on yellow.

Screenshot from 2025-10-14 10-17-27.png (82×188 px, 1 KB)

This is because the old code exported only the background: … color.

Screenshot from 2025-10-14 10-18-55.png (140×901 px, 41 KB)

Unfortunately the feature is not enabled on any of the beta cluster wikis. It can only be demoed on a dev machine or later on live Wikivoyage.

Checking in; is this change ready for Tech News? If yes how do we word it?

Change #1201735 had a related patch set uploaded (by Thiemo Kreuz (WMDE); author: Thiemo Kreuz (WMDE)):

[mediawiki/extensions/Kartographer@master] Remove obsolete white text color from autostyled markers

https://gerrit.wikimedia.org/r/1201735

@STei-WMF, yes, this is ready. Maybe something like this?

Wikivoyage wikis can use colored map markers in the article text (see https://www.mediawiki.org/wiki/Help:Extension:Kartographer#Markers_and_counters). These will now be shown with their correctly matching black or white text color, instead of always white. Local hacks that worked around the problem can be removed.

Change #1201735 merged by jenkins-bot:

[mediawiki/extensions/Kartographer@master] Remove obsolete white text color from autostyled markers

https://gerrit.wikimedia.org/r/1201735

@STei-WMF, yes, this is ready. Maybe something like this?

Wikivoyage wikis can use colored map markers in the article text (see https://www.mediawiki.org/wiki/Help:Extension:Kartographer#Markers_and_counters). These will now be shown with their correctly matching black or white text color, instead of always white. Local hacks that worked around the problem can be removed.

I added it to https://meta.wikimedia.org/wiki/Tech/News/2025/46, feel free to edit it.