Home>Support>Google Map widget $this.parent().is( ‘:visible’ ) returns false not loading apiKey

Google Map widget $this.parent().is( ‘:visible’ ) returns false not loading apiKey

I am having issues on multiple sites loading the API key for the Google Map widget since $this.parent().is( ‘:visible’ ) returns false for some reasons in sow.google-map.js on line 454

I have tried setting styling for the parent element to the map canvas to force it being visible on load but with no luck.

Think it might be lazy loading or similar effects that delays the visible true flag long enough for the map to load without apiKey and therefor showing the developer map instead.

My solution was to remove the $this.parent().is( ‘:visible’ ) check to make the map work. I get that this is check for not loading maps that are for example on hidden tabs etc. But it returns $this and does not try to load the map again when it is visible so seems more like a bug

This is our free support forum. Replies can take several days. If you need fast email support, please purchase a SiteOrigin Premium license.

  1. 29 days, 7 hours ago Alex S Hi, I Work Here

    Hi Pär,

    Do you have a public URL where we can take a look at what’s going on?
    The SiteOrigin Google Maps widget doesn’t lazy load (although its loading can be delayed if the consent prompt is enabled), and its code is set to execute on page load.

    Kind regards,
    Alex

  2. 29 days, 4 hours ago Pär Häggström

    Hi and thanks for the response
    No unfortunately I don’t have any of the sites with the issue public since it shows the developer map when the API key doesn’t load so I have had to manually remove the line causing the issue

    But the issue is pretty straight forward. It’s not the SiteOrigin Google Maps widget that lazy loads. But when map loads on page load it checks if the map canvas area is visible as a criteria for loading the API key and that check fails for me. I believe it has to do with my styling of the theme combined with lazy loading and loading animations etc but that’s not important because everything works later on except for the API key.

    So my suggestion is the API key should not depend on this

    $this.parent().is( ‘:visible’ )

    on line 454 in sow.google-map.js

    The rest of the map loading could very well depend on that line to initiate the map only when it is visible so maybe its not that line that you need to fix but instead move the entire API key loading outside to keep the map loading as it is today but make sure the API key does not fail.

    BR Pär

  3. 29 days, 1 hour ago Alex S Hi, I Work Here

    Hi Pär,

    I’ve made some changes to how Maps are loaded to avoid this potential situation – although, it’s more of a partial rework as it also avoids another issue. I’ve prepared you a build you can try and you can download it by clicking here.

    Before proceeding, do a backup.

    Once downloaded, please navigate to PluginsInstalled Plugins and deactivate SiteOrigin Widgets Bundle, then delete it. Scroll to the top of the page and click the Add New button, then Upload Plugin. Upload so-widgets-bundle.1.23.2.1-beta.zip and when prompted, activate SiteOrigin Widgets Bundle.

    Kind regards,
    Alex

  4. 28 days, 10 hours ago Pär Häggström

    That worked! Thanks for a great plugin!

  5. 28 days, 10 hours ago Alex S Hi, I Work Here

    Hi Pär,

    That’s great to hear! Thank you for your kind words. :)
    Let me know if any issues arise with that change and I’ll lend a hand. If anything else comes up, please feel free to open a new thread.
    Have a good one mate.

    Kind regards,
    Alex

Please log in to post on our forums. Signing up is free.

Get The Most Out of SiteOrigin with SiteOrigin Premium

Find Out More