Hi @jonantonio,
Thank you for getting in touch, we do appreciate your time.
Yes, you can access the map instance directly via JavaScript by two primary methods, which I’ll showcase below.
Instance by Array
// Get map by map instance array
const map = WPGMZA.maps[0];
Instance by ID
// Get map by map ID
const map = WPGMZA.getMapByID(2);
You can access these once the page is ready, but you may find it difficult to bind events in this way, and instead we recommend you bind to one of our event listeners.
We might recommend “init.wpgmza” or “markersplaced.wpgmza“, which would be bound via a jQuery event listener:
// Wait for markers to be placed on the map
jQuery(($) => {
$(document.body).on('markersplaced.wpgmza', () => {
// Process here
});
});
I hope this helps?
Hi Dylan,
Thank you for your insightful answers, really helped me a lot.
Is it possible to do programmatical search using javascript?
Regards
Jon
Hi @jonantonio,
Only a pleasure, happy to help!
You can trigger the search via the JavaScript API, but it is often simpler to trigger a button click for the search button on your existing search form.
I had a look at your page and it seems that you have gone that direction. ☺