I am trying to add a google api onto my site. The problem I am having is that google provide the code to add the api inline, however, being the organised man I am I want to run all scripts like css from an external .js file. I have tried to do this with a number of scripts and failed each time. Could anyone suggest how I break this down?
The code above is the exact inline code from google but when I add just the javascript code below into a .js file nothing happens? I have added a basic html code below to show how I am using everything. I have tried with lots of different API's but I am breaking the page every time I add it into an external page.
I thought all tags needed to be in the header even when linking to external sheets?
The code in my last post shows my HTML page and my Script page.
no, <script> tags can go anywhere, and it's better UX to have external scripts at the bottom so that they don't prevent page rendering while the script is fetched.
there's not enough code shown to make this work. it seems you are missing some code, probably a single file to be included on every page that uses the google map stuff.
google.load() is not a standard JavaScript command, so you need to define it using the aforementioned script.
__________________ my site (updated 5/13) STATS (2013/5) HTML5:90.2% MOB:15.2% IE7:0.5% IE8:8.4% IE9:8.5% IE10:8.5%
Okay, got that bit but I am still have no idea how I take this script and put it externally? If someone could explain then I can see what has to be in place and then apply it to any inline code.
I understand that API's work using external websites for their data and libraries but I can't see how you link to an external script webpage and then to an external site for the data?
Okay, got that bit but I am still have no idea how I take this script and put it externally? If someone could explain then I can see what has to be in place and then apply it to any inline code.
I understand that API's work using external websites for their data and libraries but I can't see how you link to an external script webpage and then to an external site for the data?
I think that was what rnd me was telling you just that. You must include additional javascript that enables the google.load() method. I found <script type="text/javascript" src="https://www.google.com/jsapi"></script>
at https://developers.google.com/loader/
along with detailed documentation on how to use it. I would assume you have the following in your HTML document
when you paste <script type="text/javascript" src="https://www.google.com/jsapi"></script> in your page you are loading all the extra javascript that makes the api work into your page. now the api is on your website, so all you have to do is call the available methods like so google.load('visualization', '1', {packages: ['geomap']});
__________________
Allwisend bin ich nicht, doch viel ist mir bewursst
-Goethe
I have tried that but nothing happens. I assume that the functions aren't being called using that HTML above? I have tried adding onload="visualisation()" in the body tag to call the function at the top of the script but again nothing is happening.
As soon as you don't give us a test URL ... you should start debugging. There are some neat tools out there (including some built-in developer tools for IE, Opera or Chrome) that will certainly help you in detecting issues with your page.