marker.OpenPopup() for a given querystring (url parameter)

106 views
Skip to first unread message

El Condorito

unread,
Jun 30, 2021, 5:43:22 PM6/30/21
to Leaflet
Hello, 

First post here...
I would like to display a marker with its popup open, when it matches a given querystring

e.g : 
when loading page : myurl?id=75
Then I want the given marker matching this ID to be in the state "OpenPopup()'. 

First, it seems there's no way to assign an id to a marker. I could pass it as 'title', but it's ugly, and I can't search markers by title (as far as I know). And also I use tooltip instead. 

I also tried to rely on lat,lon but they are somewhat rounded up, when using the "hash" in the URL (# zoom-level/lat/lon), so not reliable enough ( 6.2464496 becomes 6.24645)

Second I load two JSON files (files are not mine, otherwise I would have done differently).

File "A" holds for the lat, lon and ID. 
File "B"  holds the data to be displayed in the popup content, and the ID. 

Working sample is here : https://parapente-mexico.com/balise-ffvl

unminified JS code is here :  https://parapente-mexico.com/js/condorito-map.js 

In a nutshell, when I display : https://parapente-mexico.com/balise-ffvl/?ttl=Montmin&id=75#11/45.8140/6.2464
I would like to have "Montmin décollage" marker to pop up. 

I hope it's clear enough. Any ideas ? 

I saw this "workaround', but it would not be applicable in my case : 
https://stackoverflow.com/questions/42081012/openpopup-in-leaflet-map-using-custom-link-click


Thank you.  

Mark Lawton

unread,
Jun 30, 2021, 6:10:07 PM6/30/21
to leafl...@googlegroups.com
Why not have an array with all the markers ?    The first field of the array item will hold the ID and the second the marker.  So search the array for the Correct ID then show the marker

Sent from my iPhone

On Jun 30, 2021, at 2:43 PM, El Condorito <cota...@gmail.com> wrote:

Hello, 
--

---
You received this message because you are subscribed to the Google Groups "Leaflet" group.
To unsubscribe from this group and stop receiving emails from it, send an email to leaflet-js+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/leaflet-js/25e248d7-6657-41a6-992b-526865737f20n%40googlegroups.com.

El Condorito

unread,
Jul 1, 2021, 1:44:19 AM7/1/21
to Leaflet
Hello,  
Thanks for your input. 
Actually I also tried to pass the markers in a global array (global scope). 
But according to my tests, it returns null.

I will investigate a little more. 
Reply all
Reply to author
Forward
0 new messages