Hi guys, I'm relatively new to javascript, so this may be an easy answer.
I am using the Google Places & Maps API's to create a javascript based webpage.
All I need to know, is if it is possible to reference an external library (e.g. the places library from a javacript file as opposed to in the html page in script tags)?
The google documentation (http://code.google.com/apis/maps/doc...pt/places.html) recommends to put the reference in a script tag in the webpage like so:
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?libraries=places&sensor=true_or_false"></script>
but seeing as all my workings are in an external javascript file (mapstuff.js) which my .jsp references, how do i reference the Google library from my mapstuff.js?
Then all of the included .js files can 'work together' calling upon the functions, variables and classes from each of the other .js files. The only thing that would matter is functions or code that is executed before another(or all) external .js files are loaded.
The only way to actually include a javascript file from within another javascript file is to use something like AJAX to grab the file and then eval() the returned code. However I think it's a better idea to just have it loaded from within HTML as it requires less code, less time and will give you the same result.
"Given billions of tries, could a spilled bottle of ink ever fall into the words of Shakespeare?"
Thanks for the reply man.
So if I load the google library from my webpage, all my other external .js's will be able to access the library's functions provided the external one is loaded afterward the google one?
...
So if I load the google library from my webpage, all my other external .js's will be able to access the library's functions provided the external one is loaded afterward the google one?
That is correct. You will be able to call any of the functions or variables from the google .js library from your own external .js files. The order in which they are loaded matters but it seems you understood that part as well so I don't think I need to explain.
Good luck.
"Given billions of tries, could a spilled bottle of ink ever fall into the words of Shakespeare?"
Bookmarks