Title: MarkerCluster with Programmatically Generated Markers
Last modified: February 26, 2022

---

# MarkerCluster with Programmatically Generated Markers

 *  Resolved [TimothyDalton](https://wordpress.org/support/users/timothydalton/)
 * (@timothydalton)
 * [4 years, 3 months ago](https://wordpress.org/support/topic/markercluster-with-programmatically-generated-markers/)
 * 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](https://wordpress.org/support/users/hupe13/)
 * (@hupe13)
 * [4 years, 3 months ago](https://wordpress.org/support/topic/markercluster-with-programmatically-generated-markers/#post-15407191)
 * That was one reason [I decided](https://leafext.de/en/doku/about/) 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](https://wordpress.org/support/users/timothydalton/)
 * (@timothydalton)
 * [4 years, 3 months ago](https://wordpress.org/support/topic/markercluster-with-programmatically-generated-markers/#post-15409240)
 * Greetings [@hupe13](https://wordpress.org/support/users/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?
    -  This reply was modified 4 years, 3 months ago by [TimothyDalton](https://wordpress.org/support/users/timothydalton/).
 *  Plugin Author [hupe13](https://wordpress.org/support/users/hupe13/)
 * (@hupe13)
 * [4 years, 3 months ago](https://wordpress.org/support/topic/markercluster-with-programmatically-generated-markers/#post-15412082)
 * 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](https://wordpress.org/support/users/timothydalton/)
 * (@timothydalton)
 * [4 years, 3 months ago](https://wordpress.org/support/topic/markercluster-with-programmatically-generated-markers/#post-15412516)
 * Works like a charm this way. Thank you once again [@hupe13](https://wordpress.org/support/users/hupe13/)!
    -  This reply was modified 4 years, 3 months ago by [TimothyDalton](https://wordpress.org/support/users/timothydalton/).

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘MarkerCluster with Programmatically Generated Markers’ is closed to new
replies.

 * ![](https://ps.w.org/extensions-leaflet-map/assets/icon-256x256.png?rev=3067862)
 * [Extensions for Leaflet Map](https://wordpress.org/plugins/extensions-leaflet-map/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/extensions-leaflet-map/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/extensions-leaflet-map/)
 * [Active Topics](https://wordpress.org/support/plugin/extensions-leaflet-map/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/extensions-leaflet-map/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/extensions-leaflet-map/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [TimothyDalton](https://wordpress.org/support/users/timothydalton/)
 * Last activity: [4 years, 3 months ago](https://wordpress.org/support/topic/markercluster-with-programmatically-generated-markers/#post-15412516)
 * Status: resolved