I have an html page with google maps in one of the divs called map.
var map = new google.maps.Map(document.getElementById('map'),mapOptions);
Now I want to have the same google maps in multiple webpages. How do I reference this div in other pages.
For e.g.
I have another html file like this
<html><head></head>
<body><div><!--How do I get the map here--></div>
</body></html>
Is it posible using Jquery?
—edit—-
So I have a script called myscript.js
which has a
jQuery(document).ready(function(){
which in turn has a
var map = new google.maps.Map(document.getElementById('map'),mapOptions);
So how do I load this script anywhere else?
You won’t reference this div. Map is generated on the fly when page is loaded.
If you thought about using
$('#element').load('map.html #map)– it will stripe all the scripts from loaded content, so generation scripts won’t be available to run.Since it’s supposed to be the same map try use jQuery.getScript()?
You might also look at examples here on stackoverflow of using
jQuery.getScript()and google maps:jQuery getScript and Google Maps API Error message
http://lostmonocle.com/post/88217865/jquery-getscript-and-the-google-maps-api
EDIT – updated example