Jump to:

3447 Posts in 1032 Topics by 872 members

Template Questions

SilverStripe Forums » Template Questions » adding google maps to page template

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 2282 Views
  • spierala
    Avatar
    Community Member
    80 Posts

    adding google maps to page template Link to this post

    Hello folks,

    I´m new to silverstripe and I can´t find a way to make google maps run in my Page Template. I tried the jquery code found on this site: http://marcgrabanski.com/article/jquery-google-maps-tutorial-basics

    The code runs perfect in a single html file I created for testing. But in silverstripe FireFox reports an JS error like this:

    Error: google.maps is undefined

    It seems like the source for googlemaps is not visible to my site. Actually I´m not sure where to place the link to the google js. I always placed my js files that i need in the whole application in Page.php like this:

    Requirements::javascript("http://www.google.com/jsapi?key=KEYHERE");

    That worked for all the other files, but fails for google. Is there a special way to include external js files?

    Thanks very much for your help,
    Florian

  • spierala
    Avatar
    Community Member
    80 Posts

    Re: adding google maps to page template Link to this post

    ah here more Info: thats my code in my js file:

    google.load("maps", "2.x");
    google.load("jquery", "1.3.1");

    function initGoogle(){   
    var map = new GMap2(document.getElementById('map'));
    var burnsvilleMN = new GLatLng(44.797916,-93.278046);
    map.setCenter(burnsvilleMN, 8);
    }

    and in Page.php i have this to embed the google js and jquery:

    Requirements::javascript("http://www.google.com/jsapi?key=KEYHERE");
    Requirements::javascript("http://code.jquery.com/jquery-latest.js");

    The JS Error that my browser shows at the moment is:

    GMap2 is not defined

    So it seems my site finds google js source... but just does not know what GMap2 is.

    Greetz,
    Florian

  • spierala
    Avatar
    Community Member
    80 Posts

    Re: adding google maps to page template Link to this post

    this post solved my problem. after I saw that in IE googlemaps appears... the problem must have been something else:

    http://www.silverstripe.org/archive/show/1449

    nice forum!

    thanks,
    florian

    2282 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.