expose pixel bounds from TileMap not boundingTiles
This commit is contained in:
parent
7bb1b9666a
commit
d8180febe7
@ -469,7 +469,6 @@ powerView = measureView "power" "#994444" (.power >> Maybe.map toFloat)
|
||||
|
||||
eleView = measureView "elevation" "#4444ee" (.pos >> .ele)
|
||||
|
||||
|
||||
trackView : Int -> Int -> ZoomLevel -> List Point -> Svg Msg
|
||||
trackView leftedge topedge zoom points =
|
||||
let plot p =
|
||||
@ -518,21 +517,15 @@ ifTrack model content =
|
||||
canvas : Coord -> ZoomLevel -> Int -> Int -> Model -> Html Msg
|
||||
canvas centre zoom width height model =
|
||||
let tm = TileMap centre zoom width height
|
||||
(mintile, maxtile) = boundingTiles tm
|
||||
-- offset is pixel difference between centre (which *should*
|
||||
-- be the middle of the image) and actual middle of the canvas
|
||||
(pixelCentreX,pixelCentreY) = pixelFromCoord centre zoom
|
||||
leftedge = mintile.x * 256
|
||||
topedge = mintile.y * 256
|
||||
offsetX = pixelCentreX - (width // 2) - leftedge
|
||||
offsetY = pixelCentreY - (height // 2) - topedge
|
||||
pixWidth = (1 + maxtile.x - mintile.x) * 256
|
||||
pixHeight = (1 + maxtile.y - mintile.y) * 256
|
||||
mapBounds = TileMap.bounds tm
|
||||
(pixelCentreX, pixelCentreY) = pixelFromCoord centre zoom
|
||||
offsetX = pixelCentreX - (width // 2) - mapBounds.left
|
||||
offsetY = pixelCentreY - (height // 2) - mapBounds.top
|
||||
epos e = Tuple.mapBoth floor floor e.pointer.clientPos
|
||||
tv = ifTrack model (trackView leftedge topedge zoom)
|
||||
tv = ifTrack model (trackView mapBounds.left mapBounds.top zoom)
|
||||
in div [style "position" "absolute"
|
||||
,style "width" (px pixWidth)
|
||||
,style "height" (px pixHeight)
|
||||
,style "width" (px mapBounds.width)
|
||||
,style "height" (px mapBounds.height)
|
||||
,style "left" (px -offsetX)
|
||||
,style "top" (px -offsetY)
|
||||
,style "lineHeight" (px 0)
|
||||
|
@ -8,7 +8,7 @@ module TileMap exposing (tiles
|
||||
, translate
|
||||
, translatePixels
|
||||
, incZoom
|
||||
, boundingTiles
|
||||
, bounds
|
||||
, pixelsToCoord
|
||||
, pixelFromCoord
|
||||
, zoomStep)
|
||||
@ -89,6 +89,17 @@ boundingTiles (TileMap centre z width height) =
|
||||
in ((tileCovering minCoord z),
|
||||
(translate (tileCovering maxCoord z) (TileNumber 1 1)))
|
||||
|
||||
bounds : TileMap -> { left : Int, top : Int, width: Int, height: Int }
|
||||
bounds tmap =
|
||||
let (mintile, maxtile) = boundingTiles tmap
|
||||
in {
|
||||
left = mintile.x * 256,
|
||||
top = mintile.y * 256,
|
||||
width = (1 + maxtile.x - mintile.x) * 256,
|
||||
height = (1 + maxtile.y - mintile.y) * 256
|
||||
}
|
||||
|
||||
|
||||
tileUrl : TileNumber -> ZoomLevel -> String
|
||||
tileUrl {x,y} z =
|
||||
String.concat ["https://a.tile.openstreetmap.org",
|
||||
|
Loading…
Reference in New Issue
Block a user