diff --git a/src/Tyler.jl b/src/Tyler.jl index 4c7a49d7..e38ab248 100644 --- a/src/Tyler.jl +++ b/src/Tyler.jl @@ -8,7 +8,7 @@ using HTTP: HTTP using ImageMagick: ImageMagick using LRUCache: LRUCache, LRU using MapTiles: MapTiles, Tile, TileGrid, web_mercator, wgs84, CoordinateReferenceSystemFormat -using Makie: Makie, Observable, Figure, Axis, RGBAf, on, isopen, meta, mesh!, translate!, scale! +using Makie: Makie, Observable, Figure, Axis, RGBAf, on, isopen, linesegments!, meta, mesh!, translate!, scale! using OrderedCollections: OrderedCollections, OrderedSet using ThreadSafeDicts: ThreadSafeDicts, ThreadSafeDict using TileProviders: TileProviders, AbstractProvider, geturl, min_zoom, max_zoom @@ -46,12 +46,12 @@ downloading and plotting more tiles as you zoom and pan. -`scale`: a tile scaling factor. Low number decrease the downloads but reduce the resolution. The default is `1.0`. """ -struct Map +struct Map{A<:Makie.AbstractAxis} provider::AbstractProvider crs::CoordinateReferenceSystemFormat zoom::Observable{Int} figure::Figure - axis + axis::A displayed_tiles::OrderedSet{Tile} plots::Dict{Tile,Any} free_tiles::Vector{Makie.Plot} @@ -151,14 +151,15 @@ function Map(extent, extent_crs=wgs84; ext_target = MapTiles.project_extent(extent, extent_crs, crs) X = ext_target.X Y = ext_target.Y - if axis isa Axis + if axis isa Makie.Axis3 + Makie.xlims!(axis, X[1], X[2]) + Makie.ylims!(axis, Y[1], Y[2]) + elseif axis isa Makie.LScene + # do nothing + else # any other axis is 2d axis.autolimitaspect = 1 Makie.limits!(axis, (X[1], X[2]), (Y[1], Y[2])) - elseif axis isa Makie.Axis3 - Makie.xlims!(axis, (X[1], X[2])) - Makie.ylims!(axis, (Y[1], Y[2])) end - plots = Dict{Tile,Any}() tyler = Map( provider, crs, @@ -293,6 +294,7 @@ function create_tile_plot!(tyler::Map, tile::Tile, image::TileImage) end function fetch_tile(tyler::Map, tile::Tile) + #println("Fetching Tile") return get!(tyler.fetched_tiles, tile) do fetch_tile(tyler.provider, tile) end