i have a view called template.php that loads different modules eg. head, header_graphic, left_nav, main_content, right_c开发者_开发知识库olumn etc.
I'm creating a page that should display a google map (classic 'where we are' type of page), but I'm not clear how I should code it.
the javascripts should go in the 'head' component the div for the map should go in the main_content component the 'body onload="initialize()> should go in the template.php
but this way it doesn't work. the rest of the page loads normally, but the map doesn't appear.
any ideas?
I know this is an old thread but for others that are stumbling across it looking to do the same thing I hope I can be of some help.
I wrote a CodeIgniter library that builds Google Maps based on the V3 API and takes care of all the code. You can find out more and view a demo here:
CodeIgniter Google Maps API library
Hope that helps
You can load the javascript that fetches the google map in your content page itself, and call the initialize function when the page is done loading. If you're using jquery, you can do this by using:
<script type="text/javascript">
//... google maps javascript code above this
$(document).ready(function(){
initialize();
});
</script>
Calling initialize() without jQuery:
function init() {
initialize(); // calls google maps initialize method
}
window.onload = init;
精彩评论