I'm currently working on a basic website layout that consists of a full-width banner, a left menu (200px), and right content (600px). I have a simple jQuery script set up to load the content on the right-hand side when any of the five menu items are clicked. Everything seems to be functioning properly except for the Google Maps feature. When I try to embed it into the overall HTML document, it doesn't load correctly. However, when I access localhost/contact.html directly, it works fine, indicating that the functionality is there but just doesn't cooperate with the rest of the page.
Here's the code snippet for the menu:
$(document).ready(function() {
$("#about").on("click", function() {
$("#content").load("about-us.html");
});
$("#candidate").on("click", function() {
$("#content").load("candidate.html");
});
$("#client").on("click", function() {
$("#content").load("client.html");
});
$("#meet").on("click", function() {
$("#content").load("meet.html");
});
$("#contact").on("click", function() {
$("#content").load("contact.html");
});
});
And here's the code for contact.html:
<body>
<script type="text/javascript" src="js/jquery-2.1.0.min.js"></script>
<script type="text/javascript" src="js/script.js"></script>
<script src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script>
var myCenter = new google.maps.LatLng(51.510252,-0.086585);
function initialize()
{
var mapProp = {
center: myCenter,
zoom: 15,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("googleMap"), mapProp);
var marker = new google.maps.Marker({
position: myCenter,
animation:google.maps.Animation.BOUNCE
});
marker.setMap(map);
}
</script>
<table border="3px">
<tr><td align="right">
t: <br>
1st Floor<br>
Regis House<br>
45 King William Street<br>
London, EC4R 9AN
</td>
<td id="googleMap" width="300px" height="300px">
</td>
</tr>
</table>
<script type="text/javascript">initialize('googleMap');</script>
</body>
Upon inspecting with Chrome, I came across this error message:
Uncaught ReferenceError: google is not defined VM500:1
(anonymous function) VM500:1
o.extend.globalEval jquery-2.1.0.min.js:2
o.fn.extend.domManip jquery-2.1.0.min.js:3
o.fn.extend.append jquery-2.1.0.min.js:3
(anonymous function) jquery-2.1.0.min.js:3
o.access jquery-2.1.0.min.js:2
o.fn.extend.html jquery-2.1.0.min.js:3
(anonymous function) jquery-2.1.0.min.js:4
j jquery-2.1.0.min.js:2
k.fireWith jquery-2.1.0.min.js:2
x jquery-2.1.0.min.js:4
(anonymous function)