Leaflet.jl icon indicating copy to clipboard operation
Leaflet.jl copied to clipboard

Is it possible to plot makers and circles ?

Open alex-s-gardner opened this issue 2 years ago • 11 comments

So glad to see this library!!! Thanks for all of your efforts.

Is it possible to plot makers and circles [as shown for the JaveScript](library https://leafletjs.com/examples/quick-start/)?

My attempt was:

using Leaflet, Blink, GADM, GeoInterface
layers = Leaflet.Layer.([(X=73.5, Y = 70, geometry = "Point")]; color=:red);
provider = Leaflet.Esri(:imagery)
m = Leaflet.Map(; layers, provider, zoom=9, height=1000, center=[70, -73.5]);
w = Blink.Window()
body!(w, m)

but no marker is visible

alex-s-gardner avatar Dec 20 '22 17:12 alex-s-gardner

Your syntax is not quite right but ther right syntax is broken too so I gues syou tried it This should work, but it doesn't - somehow the geometry in the GeoJSON is null even though GeoInterface.geometry(feature) gives us the right result. I will have to look into it a little.

feature = (; geometry=(X=73.5, Y = 70))
layers = Leaflet.Layer(feature; color=:red)

Most likely this is a GeoJSON.jl bug.

rafaqz avatar Dec 20 '22 20:12 rafaqz

Thanks @rafaqz poking at this

alex-s-gardner avatar Dec 20 '22 21:12 alex-s-gardner

This was a GeoInterface.jl bug: https://github.com/JuliaGeo/GeoInterface.jl/pull/84

If you checkout that branch and define a feature as I did above it should work.

rafaqz avatar Dec 21 '22 12:12 rafaqz

For me it seems the issue persists. Maybe I'm missing something. Executing the following produces an interactive map without any markers:

# ]add GeoInterface#fix_base_types
using Leaflet, Blink, GADM, GeoInterface

begin
    feature = (; geometry=(Y=70, X=-73.5))
    layers = Leaflet.Layer(feature; color=:red)
    provider = Leaflet.Esri(:imagery)
    m = Leaflet.Map(; layers, provider, zoom=9, height=1000, center=[70, -73.5]);
    w = Blink.Window()
    body!(w, m)
end 

alex-s-gardner avatar Dec 21 '22 17:12 alex-s-gardner

Did you check out the PR branch of GeoInterface.jl?

~~Also your zoom area is wrong.~~

It's working here, if you are on that PR I will see if I missed something somewhere

rafaqz avatar Dec 22 '22 09:12 rafaqz

Ok yes there is another bug with NamedTuple points your point is in Antarctica lol

rafaqz avatar Dec 22 '22 09:12 rafaqz

Second bug is in GeoJSON.jl

https://github.com/JuliaGeo/GeoJSON.jl/pull/57

After that you example is working for me

Edit: I'm thinking we should make that center keyword accept a proper GeoInterace.jl point so you can specify (Y=70, X=-73.5) for clarity

rafaqz avatar Dec 22 '22 20:12 rafaqz

I agree that the center keyword should GeoInterace.jl or at a minimum be x, y order... I hate the lat, lon order legacy and feel the Julia Geo should take the opportunity to retire the old convention and stick with x, y order when needed

alex-s-gardner avatar Dec 24 '22 19:12 alex-s-gardner

Sure, I agree. Note that that keyword is just a direct translation to the javascript, it's not something anyone really made a decision about.

rafaqz avatar Dec 27 '22 12:12 rafaqz

It would be nice if we could specify icons like so Leaflet.Layer(geoms; icon=url) at least to points

ctbaum avatar Mar 08 '23 10:03 ctbaum

Absolutely! But you should make another issue for that, as when I close this as completed whenever we can finally merge the GeoJSON.jl PR, your idea will be lost.

rafaqz avatar Mar 08 '23 14:03 rafaqz