MakieOrg / Tyler.jl

Makie package to plot maptiles from various map providers
https://makieorg.github.io/Tyler.jl/dev/
MIT License
73 stars 10 forks source link

Example conceals points on zoom #109

Open jademackay opened 1 month ago

jademackay commented 1 month ago

The "Add points, polygons and text to a map" example (here) duplicated below conceals the star point when I zoom about 10 mouse clicks. It seems to be that the point is printed over when the tiles update.

using Tyler, GLMakie
using Tyler.TileProviders
using Tyler.MapTiles
using Tyler.Extents

provider = TileProviders.Esri(:WorldImagery)

# point location to add to map
lat = 34.2013;
lon = -118.1714;
pts = Point2f(MapTiles.project((lon,lat), MapTiles.wgs84, MapTiles.web_mercator))
delta = 1
extent = Extent(X = (lon - delta/2, lon + delta/2), Y = (lat-delta/2, lat+delta/2));

m = Tyler.Map(extent; provider, figure=Figure(; size=(1000, 600)))
# wait for tiles to fully load
wait(m)

objscatter = scatter!(m.axis, pts; color = :red,
    marker = '⭐', markersize = 50)
# hide ticks, grid and lables
hidedecorations!(m.axis)
# hide frames
hidespines!(m.axis)
# Plot a plygon on the map
p1 = (lon-delta/8, lat-delta/8)
p2 = (lon-delta/8, lat+delta/8)
p3 = (lon+delta/8, lat+delta/8)
p4 = (lon+delta/8, lat-delta/8)

polyg = MapTiles.project.([p1, p2, p3, p4], Ref(MapTiles.wgs84), Ref(MapTiles.web_mercator))
polyg = Point2f.(polyg)
poly!(polyg; color = :transparent, strokecolor = :black, strokewidth = 5)

# Add text
pts2 = Point2f(MapTiles.project((lon,lat-delta/6), MapTiles.wgs84, MapTiles.web_mercator))
text!(pts2, text = "Basic Example"; fontsize = 30,
    color = :darkblue, align = (:center, :center)
    )
m

#10 mouse clicks and star disappears
asinghvi17 commented 1 month ago

@nilshg reported the same thing on Slack, if you translate!(objscatter, 0, 0, 10) it "fixes" the issue for now. You could do the same to the polygon and text plots.

jademackay commented 1 month ago

@asinghvi17 Oh that's a good idea, thanks! I was just looking at move_in_front! in src/tile-plotting.jl.

SimonDanisch commented 1 week ago

Maybe we should by default translate 2d maps back by 10 or so...