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)
|
(var map-surface nil)
|
||||||
|
|
||||||
(fn draw-onto-map-surface [surface]
|
(fn draw-onto-map-surface [surface lat lon zoom]
|
||||||
(let [{ : lat : lon : zoom } app-state
|
(let [{ : num-tiles-x : num-tiles-y &as bounds } (map-bounds lat lon zoom)
|
||||||
{ : num-tiles-x : num-tiles-y &as bounds } (map-bounds lat lon zoom)
|
|
||||||
road-width 14
|
road-width 14
|
||||||
lines []]
|
lines []]
|
||||||
|
|
||||||
@ -237,14 +236,15 @@ label.readout {
|
|||||||
offset-x (- (* tile-size (- tile-x bounds.min.x)) (/ map-width 2))
|
offset-x (- (* tile-size (- tile-x bounds.min.x)) (/ map-width 2))
|
||||||
offset-y (- (* tile-size (- tile-y bounds.min.y)) (/ map-height 2))]
|
offset-y (- (* tile-size (- tile-y bounds.min.y)) (/ map-height 2))]
|
||||||
(when (not map-surface)
|
(when (not map-surface)
|
||||||
(let [window (widget:get_window)]
|
(let [window (widget:get_window)
|
||||||
|
{ : lat : lon : zoom } app-state]
|
||||||
(set map-surface
|
(set map-surface
|
||||||
(doto
|
(doto
|
||||||
(window:create_similar_surface
|
(window:create_similar_surface
|
||||||
cairo.Content.COLOR
|
cairo.Content.COLOR
|
||||||
(* tile-size bounds.num-tiles-x)
|
(* tile-size bounds.num-tiles-x)
|
||||||
(* tile-size bounds.num-tiles-y))
|
(* 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_source_surface map-surface (- offset-x) (- offset-y))
|
||||||
(g:set_operator cairo.Operator.SOURCE)
|
(g:set_operator cairo.Operator.SOURCE)
|
||||||
|
Loading…
Reference in New Issue
Block a user