Hi,
I have some tabbed content on my page. One of the tabs has a Google map in, but when I select that tab, the map only half loads.
This is the map code I have:
jQuery(function($) {
// Asynchronously Load the map API
var script = document.createElement('script');
document.body.appendChild(script);
});
function initialize() {
var myLatlng = new google.maps.LatLng(53.36188, -2.27084);
var mapOptions = {
zoom: 9,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(
document.getElementById('map-canvas'), mapOptions);
map.setTilt(45);
var bounds = new google.maps.LatLngBounds();
var SW = new google.maps.LatLng(53.36188, -2.27084);
var NE = new google.maps.LatLng(53.36188, -2.27084);
bounds.extend(SW);
bounds.extend(NE);
var infowindow = new google.maps.InfoWindow({
content: "<div class='info_content_airport'><strong>Airport</strong></div>",
position: new google.maps.LatLng(53.36188, -2.27084),
pixelOffset: new google.maps.Size(0, -40),
maxWidth: 300
});
infowindow.open(map);
var markers = [
['Airport', 53.36188, -2.27084]
];
var infoWindowContent = [
'<div class="info_content_airport">' + '<strong>Airport</strong>' + '</div>'
for (i = 0; i < markers.length; i++ ) {
var position = new google.maps.LatLng(markers[i][1], markers[i][2]);
marker = new google.maps.Marker({
position: position,
map: map,
title: markers[i][0]
});
addInfoWindow(marker, infoWindowContent[i], map);
}
map.fitBounds(bounds);
// Override our map zoom level once our fitBounds function runs
// (Make sure it only runs once)
var boundsListener = google.maps.event.addListener(
(map), 'bounds_changed', function(event) {
this.setZoom(11);
google.maps.event.removeListener(boundsListener);
});
}
function addInfoWindow(marker, message, map) {
var infoWindow = new google.maps.InfoWindow({
content: message,
maxWidth: 300
});
google.maps.event.addListener(marker, 'click', function () {
infoWindow.open(map, marker);
marker.setAnimation(google.maps.Animation.BOUNCE);
setTimeout(function(){ marker.setAnimation(null); }, 2250);
});
}
google.maps.event.addDomListener(window, 'load', initialize);
initialize();
//<![CDATA[
and this is the JS i have in my head:
<script type="text/javascript" src="maps.js"></script>
<script type="text/javascript" src="hashtabs.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$(".tabs").accessibleTabs({
tabhead:'h2',
fx:"fadeIn",
autoAnchor:true
});
$(".prod-tabs").accessibleTabs({
tabhead:'h2.tabhead"',
fx:"fadeIn",
autoAnchor:true
});
});
$(document).ready(function() {
// click event listener
$('.hash').click(function(event) {
// get the id
var clickedLink = $(this).attr('id');
// push it into the url
location.hash = clickedLink;
// stop the regular href
event.preventDefault();
});
});
/* <![CDATA[ */
$(document).ready(function(){
$("#product-tabs li").click(function() {
// First remove class "active" from currently active tab
$("#product-tabs li").removeClass('active1');
// Now add class "active" to the selected/clicked tab
$(this).addClass("active1");
// Hide all tab content
$(".product-tab-content").hide();
// Here we get the href value of the selected tab
var selected_tab = $(this).find("a").attr("href");
// Show the selected tab content
$(selected_tab).fadeIn(100);
// At the end, we add return false so that the click on the link is not executed
return false;
});
Any ideas what I have wrong and why it is only half loading?
Thanks!