From 4ee0dfae75fda3a8b6347d55c728b50ce5c210d9 Mon Sep 17 00:00:00 2001 From: Joris Date: Sun, 26 Jul 2020 18:16:59 +0200 Subject: Allow to customize icons --- src/View/Map/Icon.ml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/View/Map/Icon.ml (limited to 'src/View/Map/Icon.ml') diff --git a/src/View/Map/Icon.ml b/src/View/Map/Icon.ml new file mode 100644 index 0000000..9b1f40a --- /dev/null +++ b/src/View/Map/Icon.ml @@ -0,0 +1,32 @@ +let create name color = + let c = Color.from_raw color in + let crBlack = Color.contrast_ratio { r = 0.; g = 0.; b = 0. } c in + let crWhite = Color.contrast_ratio { r = 255.; g = 255.; b = 255. } c in + let textCol = if crBlack > crWhite then "black" else "white" in + Leaflet.div_icon + { className = "marker-parent" + ; popupAnchor = [| 0.; -34. |] + ; html = + H.div + [| |] + [| H.div + [| HA.class_ "marker-round" + ; HA.style ("background-color: " ^ color) + |] + [| |] + ; H.div [| HA.class_ "marker-peak-border" |] [| |] + ; H.div + [| HA.class_ "marker-peak-inner" + ; HA.style ("border-top-color: " ^ color) + |] + [| |] + ; H.div + [| HA.class_ "marker-icon" |] + [| H.i + [| HA.class_ ("fa fa-" ^ name) + ; HA.style ("color: " ^ textCol) + |] + [| |] + |] + |] + } -- cgit v1.2.3