Allow setting marker labels

This commit is contained in:
Manuel Thalmann 2024-04-27 00:30:42 +02:00
parent 16d97b8a29
commit c9dd4abb28

View file

@ -6,6 +6,12 @@ let
type = lib.types.nullOr lib.types.str; type = lib.types.nullOr lib.types.str;
default = null; default = null;
}; };
style.label = lib.mkOption {
type = lib.types.nullOr
(lib.types.strMatching "[0-9A-Z]");
default = null;
};
}; };
}; };
@ -31,8 +37,15 @@ in
config = { config = {
users = { users = {
manuel.departure.location = "Switzerland"; manuel.departure = {
ganondorf.departure.location = "Argentinia"; location = "Switzerland";
style.label = "M";
};
ganondorf.departure = {
location = "Argentinia";
style.label = "G";
};
}; };
map = { map = {
@ -54,12 +67,19 @@ in
requestParams = requestParams =
let let
paramsForMarkers = builtins.map paramForMarker =
(marker: "$(${config.scripts.geocode}/bin/geocode ${ marker:
lib.escapeShellArg marker.location})") let
config.map.markers; attributes =
in [ lib.optional (marker.style.label != null)
"markers=\"${lib.concatStringsSep "|" paramsForMarkers}\"" "label:${marker.style.label}"
]; ++ [
"$(${config.scripts.geocode}/bin/geocode ${
lib.escapeShellArg marker.location
})"
];
in
"markers=\"${lib.concatStringsSep "|" attributes}\"";
in builtins.map paramForMarker config.map.markers;
}; };
} }