JuliaGeo / Leaflet.jl

LeafletJS mapping library from Julia
MIT License
20 stars 4 forks source link

Is it possible to plot makers and circles ? #6

Open alex-s-gardner opened 1 year ago

alex-s-gardner commented 1 year ago

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

rafaqz commented 1 year ago

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.

alex-s-gardner commented 1 year ago

Thanks @rafaqz poking at this

rafaqz commented 1 year ago

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.

alex-s-gardner commented 1 year ago

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 
rafaqz commented 1 year ago

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 commented 1 year ago

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

rafaqz commented 1 year ago

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

alex-s-gardner commented 1 year ago

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

rafaqz commented 1 year ago

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.

ctlbau commented 1 year ago

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

rafaqz commented 1 year ago

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.