Title: callback on click?
Last modified: June 28, 2024

---

# callback on click?

 *  Resolved [e dev](https://wordpress.org/support/users/efishinsea/)
 * (@efishinsea)
 * [1 year, 11 months ago](https://wordpress.org/support/topic/callback-on-click/)
 * I’m trying to fire a JS callback function when a map marker is clicked to act
   on the popup window for that marker point. I can’t seem to find this addressed
   in the docs. Is it possible?

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

 *  Plugin Author [DylanAuty](https://wordpress.org/support/users/dylanauty/)
 * (@dylanauty)
 * [1 year, 11 months ago](https://wordpress.org/support/topic/callback-on-click/#post-17855374)
 * Hi [@efishinsea](https://wordpress.org/support/users/efishinsea/),
 * Thank you for getting in touch, we do appreciate your time.
 * Yes, this is possible in a few ways as we offer both an extendable JavaScript
   core, and various document events. For this example, I’ll showcase the event 
   system as this is a bit simpler and more future-safe as it does not override 
   any of the core modules.
 * Please see an example script below:
 *     ```wp-block-code
       jQuery(($) => {    $(document.body).on('click.wpgmza', (event) => {        /* Check if the click originated from a marker */        if(event && event.target && event.target instanceof WPGMZA.Marker){            const marker = event.target;            const map = marker.map;            const infowindow = marker.infoWindow;			            /* Note, the infowindow might not be ready yet. We'd recommend a short timeout here, to allow it to initialize */            console.log(marker, map, infowindow);        }    });});
       ```
   
 * As an alternative, you may prefer to simply listen for infowindow (popup) open
   calls, as seen below:
 *     ```wp-block-code
       jQuery(($) => {    $(document.body).on('infowindowopen.wpgmza', (event) => {        /* Act on the info-window, you can also access data from the event object */        if(event && event.target && event.target instanceof WPGMZA.InfoWindow){            const infowindowElement = event.target.element;            const infowindowMarker = event.target.feature;                        const infowindowMap = event.target.parent;			            console.log(infowindowElement, infowindowMarker, infowindowMap);        }    });});
       ```
   
 * This second option may simplify the way you integrate with the plugin, as it 
   will trigger whenever the popups are opened, instead of opening specifically 
   on a marker click event.
 * I hope this helps?
 *  Thread Starter [e dev](https://wordpress.org/support/users/efishinsea/)
 * (@efishinsea)
 * [1 year, 11 months ago](https://wordpress.org/support/topic/callback-on-click/#post-17855496)
 * thank you!
 *  Plugin Author [DylanAuty](https://wordpress.org/support/users/dylanauty/)
 * (@dylanauty)
 * [1 year, 11 months ago](https://wordpress.org/support/topic/callback-on-click/#post-17856113)
 * My pleasure [@efishinsea](https://wordpress.org/support/users/efishinsea/) – 
   Have a great day!

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

The topic ‘callback on click?’ is closed to new replies.

 * ![](https://ps.w.org/wp-google-maps/assets/icon-256x256.png?rev=3058363)
 * [WP Go Maps - Google Maps, OpenStreetMap, Leaflet Map](https://wordpress.org/plugins/wp-google-maps/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-google-maps/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-google-maps/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-google-maps/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-google-maps/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-google-maps/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [DylanAuty](https://wordpress.org/support/users/dylanauty/)
 * Last activity: [1 year, 11 months ago](https://wordpress.org/support/topic/callback-on-click/#post-17856113)
 * Status: resolved