Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #427703

    Hello,

    In my child theme, I have a custom template that I need to embed a Google Map into that uses the wordpress loop to put a marker on a map for each blog post. Each blog post has latitude and longitude coordinates already in it’s meta data. How can I hook into the existing Google Map API that ships with Enfold to embed a custom map into a custom template?

    I know how to do it using these instructions: http://martyspellerberg.com/2012/02/tutorial-integrating-wordpress-and-google-maps-api-v-3/
    But that is with a site without the Google Map API already being loaded.

    Any insight you have will be greatly appreciated!

    #428351

    Hi dmvieira!

    It doesn’t matter whether we load the API or if you load it as long as a copy of it is loaded.

    When you follow their tutorial just skip this line.

    <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
    

    Because we already have it loaded.

    Cheers!
    Elliott

    #428445

    Hi Elliot,

    For my custom template, I just duplicated page.php and renamed it. I have removed the callout to the external Google Map API. It still didn’t seem to work. Then I added onload=”initialize()” to the body tag and I get this error:

    Uncaught ReferenceError: google is not defined

    It stems from this code:

    var mapOptions = {
    		zoom: 11,
    		center: new google.maps.LatLng(33.683415, -117.1542139),
    		mapTypeId: google.maps.MapTypeId.ROADMAP
    	};

    The Google Maps API that ships with Enfold doesn’t seem to be getting loaded for this page.

    Should I use a different page template to use as a base for my custom template? Maybe index.php?

    Again, any help is much appreciated.

    #428801

    In my new Themes / Installation there is always the following lines in the header:

    <script type='text/javascript' src='//maps.google.com/maps/api/js?sensor=true&ver=4.1.1'></script>

    Why?

    And how to deactivate this?

    It is slowing down websites.

    #429244

    Hi!


    @dmvieira
    , Sorry, what I meant was it gets loaded when you use our map shortcodes. If your using it on a page with no map shortcodes then go ahead and leave that line in.


    @hunter74
    , That should not be loading on it’s own. Perhaps your using a plugin that is loading it or your embedding a map in the page? Send us a link and we’ll take a look.

    Regards,
    Elliott

    • This reply was modified 9 years ago by Elliott.
    #429435

    Ok,
    it seems that the plugin “mycalendar” is causing that problem. But I’m not using the maps.

    On that sites:
    http://heinzcluster.de/seminare/
    http://tickets-vip.com

    here the topic has been treated before: But the code is not working°
    https://kriesi.at/support/topic/website-load-speed-questions-on-the-theme-components/

    #429953

    Thanks Elliot. I got it to work. I am conditionally enqueueing the Google Map API for just one page, along with the onload initialize in the body tag. No errors to speak of! Thanks again.

    #430486

    Hey!


    @hunter74
    , That is for disabling the maps API from loading when using our map shortcodes or the widget. To stop your plugin from loading it you will need to contact the plugin authors.

    Best regards,
    Elliott

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