• Resolved TimothyDalton

    (@timothydalton)


    Thank you for this outstanding plugin. I am interested in using the MarkerCluster extension and I was wondering whether it is actually possible to generate the markers programatically “on the fly”. These are basically thousands of posts in wordpress sitting in mysql which all have an arbitrary latLng attached to them. They also have additional information which I would stick into a popup. I’d appreciate any kind of pointers. Thanks a lot!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author hupe13

    (@hupe13)

    That was one reason I decided to use Leaflet Map: select lat and lngs from a mysql database and create the shortcode for leaflet-marker. Are you able to program in php? Then it is very simple. How can I help?

    Thread Starter TimothyDalton

    (@timothydalton)

    Greetings @hupe13 – thank you for your response. Yes, I can program a little in php. If I think in pseudo code I would try and do the following. If I create a shortcode handler make_clusters which does something similar to this:

    0. echo do_shortcode('[leaflet-map]')
    1. Get all posts
    2. Loop over them and echo do_shortcode('[leaflet-marker...]')
    3. echo do_shortcode('[cluster]')

    Does this make sense do you think?

    Plugin Author hupe13

    (@hupe13)

    Yes it makes sense, but:

    0. echo do_shortcode(‘[leaflet-map]’)

    ok.

    1. Get all posts

    and their content

    2. Loop over them and echo do_shortcode(‘[leaflet-marker…]’)

    But how to get lat and lngs for markers and infos for the popups? You must separate these. Have all posts these infos and do all pages have the same structure?

    3. echo do_shortcode(‘[cluster]’)

    ok.

    You may need to cache the results somehow (in a mysql table(?)).

    I have a mysql table with my data: lat, lng, infos (and more). I also do it no differently:

    [leaflet-map ...]
    //Generate many
    [leaflet-marker ...]
    [cluster]
    Thread Starter TimothyDalton

    (@timothydalton)

    Works like a charm this way. Thank you once again @hupe13 !

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘MarkerCluster with Programmatically Generated Markers’ is closed to new replies.