jQuery( document ).ready( function() { var $mapWrapper = jQuery( '#pageR3' ); if ( $mapWrapper.is( ':visible' ) ) initMap(); jQuery( '.subset-searchform-toggle', $pageBody ) .on( 'click.anzaccent', function( event ) { event.preventDefault(); jQuery( this ).children( 'i' ).each( function() { var $this = jQuery( this ); if ( $this.hasClass( 'icon-angle-down' ) ) { $this .removeClass( 'icon-angle-down' ) .addClass( 'icon-angle-up' ); } else { $this .removeClass( 'icon-angle-up' ) .addClass( 'icon-angle-down' ); } } ); jQuery( '.subset-searchform', $pageBody ) .slideToggle(); } ); jQuery( '.view-map a', $pageBody ) .on( 'click.anzaccent', function( event ) { event.preventDefault(); var $this = jQuery( this ); $mapWrapper.slideToggle( 400, function() { if ( $mapWrapper.is( ':hidden' ) ) { $this.text( 'View map' ); } else { $this.text( 'Hide map' ); if ( ! hasMap( 'map-canvas' ) ) setTimeout( initMap, 450 ); } } ); jQuery( 'html, body' ).animate( { scrollTop: $mapWrapper.offset().top }, 500 ); } ); jQuery( '#pageR3 .toolbar_hide', $pageBody ) .on( 'click.anzaccent', function( event ) { event.preventDefault(); $mapWrapper.slideToggle(); jQuery( '.view-map a', $pageBody ).text( 'View map' ); } ); } ); function hasMap( id ) { return !! document.getElementById( id ).firstChild; } function initMap() { /* DEVELOPERS NOTE: Variables 'locations' and 'redirects' are global and are defined inline within the stories-listing page (near the footer). */ var mapOptions = { center: new google.maps.LatLng( -37.830268, 144.973438 ) }; var map = new google.maps.Map( document.getElementById( 'map-canvas' ), mapOptions ); var bounds = new google.maps.LatLngBounds(); var marker, i; for ( i = 0; i < locations.length; i++ ) { marker = new google.maps.Marker( { position: new google.maps.LatLng( locations[ i ].lat, locations[ i ].lng ), map: map, title:locations[ i ].title } ); google.maps.event.addListener( marker, 'click', function() { window.location.href = redirects[ this.title ]; } ); bounds.extend( marker.position ); } map.fitBounds( bounds ); if ( ! jQuery( 'html' ).hasClass( 'lt-ie9' ) ) { jQuery( window ) .resize( function() { poll( function() { map.fitBounds( bounds ); }, 100 ); } ); } }