pass lat/lon/zoom to draw-onto-map-surface
this removes dependency on global state and will make it simpler to generate map for arbitrary co-ordinates
This commit is contained in:
parent
beca254bf6
commit
0b22a7e538
@ -180,9 +180,8 @@ label.readout {
|
||||
|
||||
(var map-surface nil)
|
||||
|
||||
(fn draw-onto-map-surface [surface]
|
||||
(let [{ : lat : lon : zoom } app-state
|
||||
{ : num-tiles-x : num-tiles-y &as bounds } (map-bounds lat lon zoom)
|
||||
(fn draw-onto-map-surface [surface lat lon zoom]
|
||||
(let [{ : num-tiles-x : num-tiles-y &as bounds } (map-bounds lat lon zoom)
|
||||
road-width 14
|
||||
lines []]
|
||||
|
||||
@ -237,14 +236,15 @@ label.readout {
|
||||
offset-x (- (* tile-size (- tile-x bounds.min.x)) (/ map-width 2))
|
||||
offset-y (- (* tile-size (- tile-y bounds.min.y)) (/ map-height 2))]
|
||||
(when (not map-surface)
|
||||
(let [window (widget:get_window)]
|
||||
(let [window (widget:get_window)
|
||||
{ : lat : lon : zoom } app-state]
|
||||
(set map-surface
|
||||
(doto
|
||||
(window:create_similar_surface
|
||||
cairo.Content.COLOR
|
||||
(* tile-size bounds.num-tiles-x)
|
||||
(* tile-size bounds.num-tiles-y))
|
||||
draw-onto-map-surface))))
|
||||
(draw-onto-map-surface lat lon zoom)))))
|
||||
|
||||
(g:set_source_surface map-surface (- offset-x) (- offset-y))
|
||||
(g:set_operator cairo.Operator.SOURCE)
|
||||
|
Loading…
Reference in New Issue
Block a user