Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to add Markers #1

Open
JuanjoA opened this issue Aug 22, 2023 · 7 comments
Open

How to add Markers #1

JuanjoA opened this issue Aug 22, 2023 · 7 comments

Comments

@JuanjoA
Copy link

JuanjoA commented Aug 22, 2023

Hi @sntran , I'm trying your library because it seems interesting to me that the calls to the open street maps api are managed from the backend and javascript libraries are not used.

I'm a bit stuck, as I can't think of a way to add markers.

Can you give me a little guidance? If I can collaborate and contribute with some PR, it will be done.

Thanks.

@sntran
Copy link
Owner

sntran commented Aug 22, 2023

Hi there, thanks for checking out my experiment.

To add support for markers, I think the way to go is to create slots for them, like the current :style and :zoom_in and :zoom_out slots. We can then render them using the attributes on the slots. Some math are required to convert longitude and latitude to pixel coordinates.

PR is very welcome, as I have moved away from Elixir for some time now.

@JuanjoA
Copy link
Author

JuanjoA commented Aug 22, 2023

Thanks @sntran, I agree with You about the slots, the tricky part is going to be the calculation of latitude and longitude to pixels, right.
I will try, thanks again!

@larshei
Copy link

larshei commented Aug 23, 2023

I am also thinking of adding a map with markers (actually multiple Maps with markers on one view)
and found this while searching for MapLibre snippets.

In a previous project I worked with Leaflet, but somehow that felt a bit clunky with pushing events around manually and writing the hooks on the frontend. So this would actually be great! (I do not even need map interaction)

@nomtrosk
Copy link

@JuanjoA Did you manage to get it working? I tried the same but got stuck when I found SVG not centring the coordinate correctly meaning its hard to determine precise lat/long position in the image. I tried to hardcode a black square in the middle of the SVG image and expected this to be placed at the lat/lon argument for livemap at all zoom levels. It was not the case..

@larshei
Copy link

larshei commented Sep 19, 2023

I went with a different approach and used LeafLet Map.

After your question I created a quick gist for app.js, liveview and a component here: https://gist.github.com/larshei/249ebc49b7469c41d8ea4260fe9ad93a

As noted in the readme, I copied this together and did not actually give it a try in its own project, as I am short on time right now. If needed I can review it in 2 weeks.

@larshei
Copy link

larshei commented Sep 19, 2023

I took this approach because I worked with Leaflet earlier and it seemed like the "easier" way for me personally.

If someone adjusts this package instead, I'd be happy to try that as well!

@nomtrosk
Copy link

Yeah, it may be an easier solution to use already existing mapping engine with scrolling, markers and all. Thanks @larshei, I'll take a look at that solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants