var geocoder; var map; var gigMarkers = new Array(); var loadingMessage = "Loading..."; var initLatLng = new google.maps.LatLng(54.484998, -3.532791); var noEvents = "There are no events for the selected options"; function initialize() { geocoder = new google.maps.Geocoder(); var myOptions = { zoom: 6, center: initLatLng, mapTypeId: google.maps.MapTypeId.ROADMAP } map = new google.maps.Map(document.getElementById("gigmap"), myOptions); } function ResetMap() { map.setCenter(initLatLng); map.setZoom(6); } function ClearList(){ $(".eventlist .content").html(loadingMessage); } // Gig info window var infowindow = new google.maps.InfoWindow(); function AddGigMarker(lat, lng, infocontent) { var gigLatLng = new google.maps.LatLng(lat, lng); var gigMarker = new google.maps.Marker({ position: gigLatLng, map: map }); // Add a click event google.maps.event.addListener(gigMarker, 'click', function() { infowindow.content=infocontent; infowindow.open(map,gigMarker ); }); gigMarkers[gigMarkers.length] = gigMarker; } function PopulateList(listContent){ var eventList = $(".eventlist .content"); if(eventList.html() == loadingMessage){ eventList.html(""); } eventList.html(eventList.html() + listContent); } function clearMarkers(){ infowindow.close(); for(i =0; i < gigMarkers.length; i++){ gigMarkers[i].setMap(null); } } var time = 0; function LoadEventsByDate(startdate, enddate, textDate){ // GA if(textDate != null){ pageTracker._trackPageview ('/timespan/' + textDate); } ClearList(); $.getJSON("http://www.thisawfultruth.com/ajax/mapdateevents.php?timespan=Week&startdate=" + startdate + "&enddate=" + enddate + "", function(data){ if(data.events.length > 0){ $.each(data.events, function(i,event){ AddGigMarker(event.lat, event.lng, event.description); PopulateList(event.description); }); } else { PopulateList("Please select a timespan other than \"all dates\" for national listings"); } }); } function LoadEventsByDateCity(startdate, enddate, textDate, city){ // GA if(textDate != null){ pageTracker._trackPageview ('/city/' + city + '/' + textDate); } ClearList(); $.getJSON("http://www.thisawfultruth.com/ajax/mapdateevents.php?timespan=Week&startdate=" + startdate + "&enddate=" + enddate + "&city=" + city, function(data){ if(data.events.length > 0){ $.each(data.events, function(i,event){ AddGigMarker(event.lat, event.lng, event.description); PopulateList(event.description); }); } else { PopulateList(noEvents); } }); } function CenterMapOnCity(city, country) { if (geocoder) { geocoder.geocode( { 'address': city + " " + country}, function(results, status) { if (status == google.maps.GeocoderStatus.OK) { map.setCenter(results[0].geometry.location); if(city == "London"){ map.setZoom(11); } else { map.setZoom(12); } } else { alert("Geocode was not successful for the following reason: " + status); } }); } } function LoadEventsByCity(city, country){ // GA track pageTracker._trackPageview ('/city/' + city); ClearList(); $.getJSON("http://www.thisawfultruth.com/ajax/mapdateevents.php?city=" + city, function(data){ if(data.events.length > 0){ $.each(data.events, function(i,event){ AddGigMarker(event.lat, event.lng, event.description); PopulateList(event.description); }); } else { PopulateList(noEvents); } }); CenterMapOnCity(city, country); } function LoadEventsByArtist(artist){ // GA pageTracker._trackPageview ('/artist/' + artist); ClearList(); $.getJSON("http://www.thisawfultruth.com/ajax/mapdateevents.php?artist=" + artist, function(data){ $.each(data.events, function(i,event){ //alert(event.description); // for each event, add it to the maps AddGigMarker(event.lat, event.lng, event.description); PopulateList(event.description); }); map.setZoom(6); map.setCenter(initLatLng); }); } // clears all option boxes function ClearOptions(selectedId){ var selects = $("select"); $.each(selects, function(){ // dont reset the selected one... if(selectedId.indexOf(this.id) == -1){ this.selectedIndex = 0; } }); }