• Resolved Arun George

    (@arunsgeo)


    Hello,

    On the frontend, I want to add some additional text to a specific location. I don’t want to customize the plugin so I’m writing my own code on the theme. Is there any hook available to check the map is completely loaded or not. Basically I want to load my script after all the map is loaded.

    Thank you!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author DylanAuty

    (@dylanauty)

    Hi @arunsgeo,

    Thank you for getting in touch, we do appreciate your time.

    We do have various hooks available throughout the plugin, which would allow you to add additional content to the output of the plugin. You can find most of these documented here: WP Go Maps Hooks

    To add additional JavaScript to the page, as part of our shortcode, I’d recommend using the wpgmza_script_loader_enqueue_custom_js action – As this would fall inline with our own custom JavaScript block.

    With that said, these hooks are not run based on whether or not the map has been loaded, meaning if you’d like to run your JavaScript when the map is initialized, you would need to make use of our JavaScript (jQuery) events system as well.

    For example, your script might look something like this:

    jQuery(($) => {
        $(document.body).on('init.wpgmza', () => {
            console.log("Primary map elements initialized, markers would be loaded next");
        });
    })

    We have many events throughout the loading of the map, which can be leveraged to action more specific tasks. If you could elaborate slightly on what you’d like to accomplish, I can assist you with a more purpose build event if needed.

    I hope this helps?

    Thread Starter Arun George

    (@arunsgeo)

    Hi @dylanauty

    Thank you so much for your support. I appreciate it. I think the example you gave would work in my case so I will try to reuse that.

    Plugin Author DylanAuty

    (@dylanauty)

    Happy to hear that helped @arunsgeo – Have a great day further 🙂

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

The topic ‘Need hook to add custom JS’ is closed to new replies.