Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #926651

    Dear Enfold Team,

    we searched a lot but unfortunately couldn’t find a working solution for us.

    For instance this solution here just seems to fix Google Maps issues to work along with other plugins:
    https://kriesi.at/support/topic/disable-google-maps-api-call-in-backend/

    But what we really want to achieve is to prevent the Google Maps Api from loading, where it’s not needed.

    That is, we don’t want to call
    https://maps.googleapis.com/maps/api/js?key=XXX

    AND prevent

    <script type="text/javascript" charset="UTF-8" src="https://maps.googleapis.com/maps-api-v3/api/js/32/5/intl/de_ALL/common.js"></script>
    <script type="text/javascript" charset="UTF-8" src="https://maps.googleapis.com/maps-api-v3/api/js/32/5/intl/de_ALL/util.js"></script>
    <script type="text/javascript" charset="UTF-8" src="https://maps.googleapis.com/maps-api-v3/api/js/32/5/intl/de_ALL/stats.js"></script>

    being added to each page.

    We want the scripts being loaded on our contact page however, where we actually show a Google Map.

    What we would like to see would be something like a filter, which we can apply for all pages except for our contact page.

    Looking forward to your reply!

    Thanks a lot in advance!

    #926667

    try this to your functions.php of child-theme:
    Example page here ID=3184 so if not page ID = 3184 than disable

    add_filter('avf_load_google_map_api', 'disable_google_map_api', 10, 1);
    function disable_google_map_api($load_google_map_api) {
    if( !is_page(3184) ) {
            $load_google_map_api = false;
            return $load_google_map_api;
    }
    }
    #926673

    Hi Gueni007,

    Thanks a lot for your reply, but this is basically the solution from the other ticket and it does unfortunately not prevent the API from loading.

    However, this really looks like the right solution.

    Thanks anyways!

    #926675

    maybe a mod knows how to prevent the backend api load.
    All frontend apis are disabled by this.

    #926700

    try a combination of this: (my test page was ID 35) and do not enter a google api key to enfold options dialog (save it)
    replace the xyxyxy with your api key !

    Edit: go on with https://kriesi.at/support/topic/disable-loading-google-maps-api-where-not-needed/#post-926707

    • This reply was modified 6 years, 8 months ago by Guenni007.
    #926707

    Let the input field in Enfold Google Map api empty !

    because it does not load – if there was no input in that field

    EDIT: this is what enfold would insert if enfold options are set – it can be placed in footer too as well

    add_action( 'wp_footer', 'custom_gmap_script', 10 );
    function custom_gmap_script() {
    if( is_page(35) ) {
      ?>
    	<script type='text/javascript'>
    	/* <![CDATA[ */
    	var avia_framework_globals = avia_framework_globals || {};
    	avia_framework_globals.gmap_api = 'YOUR_API_KEY_HERE';
    	avia_framework_globals.gmap_maps_loaded = 'https://maps.googleapis.com/maps/api/js?v=3.30&key=YOUR_API_KEY_HERE&callback=aviaOnGoogleMapsLoaded';
    	avia_framework_globals.gmap_builder_maps_loaded = 'https://maps.googleapis.com/maps/api/js?v=3.30&key=YOUR_API_KEY_HERE&callback=av_builder_maps_loaded';
    	avia_framework_globals.gmap_backend_maps_loaded = 'https://maps.googleapis.com/maps/api/js?v=3.30&callback=av_backend_maps_loaded';
    	avia_framework_globals.gmap_source = 'https://maps.googleapis.com/maps/api/js?v=3.30&key=YOUR_API_KEY_HERE';
    	/* ]]> */	
    	</script>	
      <?php
    }
    }

    you had to modify YOUR_API_KEY_HERE to your Maps API Key 4 times !

    you can see it here working: https://webers-testseite.de/weber/contact-2/
    and on the other pages no gmap is loaded

    • This reply was modified 6 years, 8 months ago by Guenni007.
    #927107

    Hi,

    Thanks a lot for sharing and helping out @guenni007, did you try that out and did you have any luck with it @cb?

    Best regards,
    Rikard

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.