• Resolved daisy4rez

    (@daisy4rez)


    Hi,

    I’m using Complianz and Rentalhive theme and I want to block the Google Maps API till the user accepts all cookies. I use script center to block google urls like it describes here: https://complianz.io/debugging-google-maps/.

    • On “deny” the map gets blocked and the placeholder is displayed correctly.
    • On “accept” the map does not appear, but sometimes if I refresh the page, it works.

    But, no matter the settings I tried (accept/deny), in the console it gives the following error message: Uncaught ReferenceError: google is not defined. It seems some js, like common.min.js or jquery.min.js etc., still try to request the Google Maps.

    Uncaught ReferenceError: google is not defined
    at HTMLDivElement. (common.min.js?ver=1.3.7:1:2912)
    at Function.each (jquery.min.js?ver=3.7.0:2:3129)
    at e..each (jquery.min.js?ver=3.7.0:2:1594)
    at hivepress.initGeolocation (common.min.js?ver=1.3.7:1:2077)
    at HTMLDocument. (common.min.js?ver=1.3.7:1:4104)
    at HTMLDocument.dispatch (jquery.min.js?ver=3.7.0:2:39997)
    at v.handle (jquery.min.js?ver=3.7.0:2:37968)
    at Object.trigger (jquery.min.js?ver=3.7.0:2:70063)
    at HTMLDocument. (jquery.min.js?ver=3.7.0:2:70665)
    at Function.each (jquery.min.js?ver=3.7.0:2:3129)

    On the main page I have the similar error:

    Uncaught ReferenceError: google is not defined
        at GeoComplete.initGeocoder (jquery.geocomplete.min.js?ver=1.3.7:8:2461)
        at GeoComplete.init (jquery.geocomplete.min.js?ver=1.3.7:8:1270)
        at new GeoComplete (jquery.geocomplete.min.js?ver=1.3.7:8:1177)
        at HTMLInputElement.<anonymous> (jquery.geocomplete.min.js?ver=1.3.7:8:8724)
        at Function.each (jquery.min.js?ver=3.7.0:2:3129)
        at e.<computed>.each (jquery.min.js?ver=3.7.0:2:1594)
        at $.fn.geocomplete (jquery.geocomplete.min.js?ver=1.3.7:8:8649)
        at HTMLDivElement.<anonymous> (common.min.js?ver=1.3.7:1:1179)
        at Function.each (jquery.min.js?ver=3.7.0:2:3129)
        at e.<computed>.each (jquery.min.js?ver=3.7.0:2:1594)

    I followed this tutorial to fix it : https://complianz.io/custom-google-maps-implementation/ but still I can’t get the problem fixed.
    Could you please help me to find a technical solution with a MU plugin? I would be happy about any help!

    Best regards

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Contributor jarnovos

    (@jarnovos)

    Hi @daisy4rez,

    I’ve created a sandbox environment with the HivePress plugin (& Geolocation add-on) and added a Google Map. As far as I’ve been able to see, this Map only loads on the individual “Listing” pages.

    The below integration blocks the Maps API and the HivePress Geolocation scripts, and uses the hivepress.initUI(); function to initialize the Map after consent is obtained.

    This appears to work fine for me, as can be seen on this example page.

    Here’s the integration, you can upload it as a .php file in the /wp-content/mu-plugins/ folder for it to take effect.

    hivepress-maps.php

    Hope it helps, feel free to modify the snippet to your needs.

    Kind regards, Jarno

    • This reply was modified 1 year ago by jarnovos.
    Thread Starter daisy4rez

    (@daisy4rez)

    Hi @jarnovos,

    I am very grateful for your help. It works, thank you!

    I just had to add a placeholder for hp-map block, because the map loads on the search page too.

    'placeholder_class' => 'hp-listing__map, hp-map'

    Thank you for the best support ever! ??

    Best regards

    Plugin Contributor jarnovos

    (@jarnovos)

    Hi @daisy4rez,

    That’s very good to hear, thank you for the quick confirmation as well!

    If you’re happy with the plugin and our support, it would be really great if you could consider writing a review about the plugin here: https://www.ads-software.com/support/plugin/complianz-gdpr/reviews/#new-post

    I’ll mark the thread as resolved, but just let me know if you have any further questions.

    Kind regards, Jarno

    Thread Starter daisy4rez

    (@daisy4rez)

    Hi @jarnovos,

    I’ve just noticed after page refresh (few times in the row) unfortunately I have the same error: Uncaught ReferenceError: google is not defined. Here are lines from common.min.js file which are marked as error:

    e=new google.maps.LatLngBounds,
    f=new google.maps.Map(b.get(0)

    and from jquery.geocomplete.min.js file:

    this.autocomplete = new google.maps.places.Autocomplete(this.input,options);
    this.geocoder = new google.maps.Geocoder;

    But interesting is the map does work correctly.

    Could it be that google.maps.methods are loaded faster than maps.googleapis.com?

    Thank you!

    Best regards

    Thread Starter daisy4rez

    (@daisy4rez)

    Hi again,

    unfortunately, sometimes on “accept” by booking a listing I have internal server error 500 ( but on “deny” everything is fine and booking goes on the next page). If I switch complianz plugin off, it works right.

    Besides, I use reCaptcha v.2 for login page and doesn’t matter if captcha wrong or right, I always get an error “captcha is invalid” (error 400 bad request). And still, if I deactivate plugin, everithing is ok.

    I tried to test some things in that mu-plugin and it seems to me that this hivepress initialization function initUI() is the reason. Could you please take a look at it?

    Best regards

    ?

    Plugin Contributor jarnovos

    (@jarnovos)

    Hi @daisy4rez,

    Does the described behavior keep occurring when you temporarily remove the MU Plugin as well?

    If so, there might be another Integration at fault. Do you happen to have the Twitter integration enabled in Complianz -> Integrations -> Services, and if so, could you try disabling that?

    Kind regards, Jarno

    • This reply was modified 1 year ago by jarnovos.
    Thread Starter daisy4rez

    (@daisy4rez)

    Hi @jarnovos,

    tnx for quick answer! No, if I remove mu plugin google map have not been blocked but other of these errors don’t occur.

    If so, there might be another Integration at fault. Do you happen to have the Twitter integration enabled in Complianz -> Integrations -> Services, and if so, could you try disabling that?

    I don’t have twitter integration.

    Best Regards

    Plugin Contributor jarnovos

    (@jarnovos)

    Hi @daisy4rez,

    Okay, then I would be interested to know if the use of the HivePress initUI() function might be related. Remove it from the MU Plugin, re-enable the MU Plugin and check if the behavior still occurs.

    We’d need an alternative to re-initialize the Map after consent is obtained though, but the initUI() function seemed to be the most appropriate. I would recommend asking HivePress, if they have an alternative method that can be used here.

    Otherwise, it might be better for HivePress to integrate with Complianz on their end. That would allow them to load the Maps API based on consent, as opposed to us having to block their scripts, reinitialize the Map etc; which appears to be what causes the behavior to occur in this case.

    Kind regards, Jarno

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Google Maps with Hivepress doesn’t work’ is closed to new replies.