Allow setting marker labels
This commit is contained in:
parent
16d97b8a29
commit
c9dd4abb28
1 changed files with 29 additions and 9 deletions
38
marker.nix
38
marker.nix
|
@ -6,6 +6,12 @@ let
|
|||
type = lib.types.nullOr lib.types.str;
|
||||
default = null;
|
||||
};
|
||||
|
||||
style.label = lib.mkOption {
|
||||
type = lib.types.nullOr
|
||||
(lib.types.strMatching "[0-9A-Z]");
|
||||
default = null;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -31,8 +37,15 @@ in
|
|||
|
||||
config = {
|
||||
users = {
|
||||
manuel.departure.location = "Switzerland";
|
||||
ganondorf.departure.location = "Argentinia";
|
||||
manuel.departure = {
|
||||
location = "Switzerland";
|
||||
style.label = "M";
|
||||
};
|
||||
|
||||
ganondorf.departure = {
|
||||
location = "Argentinia";
|
||||
style.label = "G";
|
||||
};
|
||||
};
|
||||
|
||||
map = {
|
||||
|
@ -54,12 +67,19 @@ in
|
|||
|
||||
requestParams =
|
||||
let
|
||||
paramsForMarkers = builtins.map
|
||||
(marker: "$(${config.scripts.geocode}/bin/geocode ${
|
||||
lib.escapeShellArg marker.location})")
|
||||
config.map.markers;
|
||||
in [
|
||||
"markers=\"${lib.concatStringsSep "|" paramsForMarkers}\""
|
||||
];
|
||||
paramForMarker =
|
||||
marker:
|
||||
let
|
||||
attributes =
|
||||
lib.optional (marker.style.label != null)
|
||||
"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;
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue