plot the points
This commit is contained in:
parent
9b4cb45c16
commit
4bdd103bd5
@ -197,7 +197,7 @@ newModel msg model =
|
||||
|
||||
Loaded result ->
|
||||
case result of
|
||||
Ok trk -> { model | track = Debug.log "LOADED" (Present trk) }
|
||||
Ok trk -> { model | track = Present trk }
|
||||
Err (Http.BadBody e) -> { model | track = Debug.log e (Failure "e") }
|
||||
Err e -> { model | track = Debug.log "unknown error" (Failure "e") }
|
||||
|
||||
@ -215,36 +215,28 @@ tileImg zoom tilenumber = img [ width 256,
|
||||
height 256,
|
||||
src (tileUrl tilenumber zoom) ] []
|
||||
|
||||
trackView : List Point -> Svg Msg
|
||||
|
||||
|
||||
trackView track =
|
||||
trackView : List Point -> Int -> Int -> Svg Msg
|
||||
trackView points leftedge topedge =
|
||||
let plot p =
|
||||
let (x, y) = pixelFromCoord (toCoord p.pos.lat p.pos.lon) 13
|
||||
x_ = x - leftedge
|
||||
y_ = y - topedge
|
||||
in circle [ cx (px x_), cy (px y_), r "2" ] []
|
||||
line = List.map plot points
|
||||
in
|
||||
svg
|
||||
[H.style "width" "100%"
|
||||
,H.style "height" "100%"
|
||||
,H.style "position" "absolute"
|
||||
[ H.style "width" "100%"
|
||||
, H.style "height" "100%"
|
||||
, H.style "position" "absolute"
|
||||
]
|
||||
[ g
|
||||
[fill "none"
|
||||
,stroke "blue"
|
||||
,strokeWidth "7"
|
||||
,strokeOpacity "0.5"]
|
||||
[ rect
|
||||
[ x "10"
|
||||
, y "10"
|
||||
, S.width "100"
|
||||
, S.height "100"
|
||||
, rx "15"
|
||||
, ry "15"
|
||||
]
|
||||
[]
|
||||
, circle
|
||||
[ cx "50"
|
||||
, cy "50"
|
||||
, r "50"
|
||||
]
|
||||
[]
|
||||
]]
|
||||
[ fill "none"
|
||||
, stroke "blue"
|
||||
, strokeWidth "7"
|
||||
, strokeOpacity "0.5"]
|
||||
line
|
||||
]
|
||||
|
||||
|
||||
px x = String.fromInt x ++ "px"
|
||||
|
||||
@ -270,7 +262,7 @@ canvas centre zoom width height track =
|
||||
ys = List.range mintile.y maxtile.y
|
||||
epos e = Tuple.mapBoth floor floor e.pointer.clientPos
|
||||
tv = case track of
|
||||
Present t -> trackView t
|
||||
Present t -> trackView t leftedge topedge
|
||||
Failure f -> Debug.log f (div [] [ text "failure", text f])
|
||||
Loading -> div [] [text "loading"]
|
||||
Empty -> div [] [text "no points"]
|
||||
|
Loading…
Reference in New Issue
Block a user