Skip to content

Commit bf92fae

Browse files
committed
Support radius property
1 parent 410a334 commit bf92fae

2 files changed

Lines changed: 14 additions & 11 deletions

File tree

src/Client/Client.fs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,12 @@ type PropertyDef =
4949
| VectorProperty of CircleProps
5050

5151
let grey = "#848484"
52-
let propertiesDef = Map.ofSeq [
53-
"edgeColorGrey", EdgeProperty (PolylineProps.Color grey)
54-
"nodeColorGrey", VectorProperty (CircleProps.Color grey)
55-
]
52+
let mkProperties = List.choose (fun (s: string) -> s.Split '=' |> Array.toList |> function
53+
| ["edgeColorGrey"; ""] -> EdgeProperty (PolylineProps.Color grey) |> Some
54+
| ["nodeColorGrey"; ""] -> VectorProperty (CircleProps.Color grey) |> Some
55+
| ["radius"; r] -> VectorProperty (CircleProps.Radius (float r)) |> Some
56+
| _ -> None)
57+
5658

5759
let nl = System.Environment.NewLine
5860
let tryInt (s: string) = let (r,x) = System.Int32.TryParse s in if r then Some x else None
@@ -268,17 +270,18 @@ let view model dispatch =
268270
|> Seq.map (fun x ->
269271
let extraProps =
270272
x.Properties
271-
|> List.choose (fun p -> Map.tryFind p propertiesDef)
273+
|> mkProperties
272274
|> List.choose (function | VectorProperty p -> Some p | _ -> None)
273-
ReactLeaflet.circle ([
275+
ReactLeaflet.circle (extraProps @ [
274276
CircleProps.Custom ("center", (!^ (x.Longitude, x.Latitude):Leaflet.LatLngExpression))
275-
CircleProps.Radius (zoomDynSize (onScaleSqrt 200. 800. (getNumberOfLinesFactor x)))
277+
if extraProps |> Seq.exists (function | CircleProps.Radius _ -> true | _ -> false) |> not then
278+
CircleProps.Radius (zoomDynSize (onScaleSqrt 200. 800. (getNumberOfLinesFactor x)))
276279
CircleProps.Color (getColor x.Weight)
277280
CircleProps.Opacity (opacity x)
278281
// MarkerProps.Title x.Title
279282
//CircleProps.OnMouseOver (fun _ -> printfn "hover %s" x.Title)
280283
//CircleProps.OnMouseOut (fun _ -> printfn "hover off %s" x.Title)
281-
] @ extraProps) [ ReactLeaflet.popup [] [getTitle x.Title]; ReactLeaflet.tooltip [TooltipProps.Sticky true] [getTitle x.Title] ]
284+
]) [ ReactLeaflet.popup [] [getTitle x.Title]; ReactLeaflet.tooltip [TooltipProps.Sticky true] [getTitle x.Title] ]
282285
)
283286
let edges =
284287
let opacity (x,y) = (opacity x + opacity y) / 2.
@@ -288,7 +291,7 @@ let view model dispatch =
288291
let opacity = PolylineProps.Opacity (opacity (x,y))
289292
let extraProps =
290293
x.Properties @ y.Properties
291-
|> List.choose (fun p -> Map.tryFind p propertiesDef)
294+
|> mkProperties
292295
|> List.choose (function | EdgeProperty p -> Some p | _ -> None)
293296
let line =
294297
ReactLeaflet.polyline ([
@@ -359,7 +362,7 @@ let view model dispatch =
359362
let loadDataView() =
360363
Columns.columns [] [
361364
Column.column [] [
362-
str "Data format (delimeter TAB): location | GPS(lat,lng) | year | name | note | type"
365+
str "Data format (delimeter TAB): location | GPS(lat,lng) | year | name | note | type | properties"
363366
textarea [
364367
DefaultValue model.RawData
365368
OnChange (fun ev -> (!!ev.target?value) |> SetRawData |> dispatch)

src/Client/Data.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module MarkersData
2-
let data = "Jarov 49.946944, 14.0675 1882 Vojtěch Skopový narození
2+
let data = "Jarov 49.946944, 14.0675 1882 Vojtěch Skopový narození radius=1000
33
Vosůvek 49.85, 14.091389 1841 Vojtěch Skopový narození edgeColorGrey
44
Vosov 49.85, 14.083333 1841 Vojtěch Skopový o
55
Vosůvek 49.85, 14.091389 1817 Josef Skopový narození

0 commit comments

Comments
 (0)