function initialize() {
    
    var mapOptions = {
    zoom: 15 //ZOOM INTO 15X AT USERS CURRENT LOCATION
    };
    
    //SHOWS THE MAP ON THE ID CALLED MAP-CANVA    
    map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
    
    
    
    directionsDisplay.setMap(map);
    directionsDisplay.setPanel(document.getElementById("directionsPanel"));
    
    //LOOKS FOR USERS CURRENT LOCATION 
    if(navigator.geolocation) {
        navigator.geolocation.getCurrentPosition(function(position) {
            var pos = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
            map.setCenter(pos);//CENTER MAP AT USERS CURRENT POSITION
            sessionStorage.setItem('currentpos', pos); //set within session for directions purpose
        },
        function() {
            handleNoGeolocation(true);
        });
    } else{
        // Browser doesn't support Geolocation
        handleNoGeolocation(false);
    }
    
    
//ERROR FOR NO BROWSER SUPPORT (VALIDATION) 
    function handleNoGeolocation(errorFlag) {
        if (errorFlag) {
            var content = 'Error: The Geolocation service failed.';
        } else {
            var content = 'Error: Your browser doesn\'t support geolocation.';
        }
        var options = {
            map: map,
            position: new google.maps.LatLng(60, 105),
            content: content
        };
        var infowindow = new google.maps.InfoWindow(options);
        map.setCenter(options.position);
    }


    //**************************************
    // SEARCHBOX TO LOOK UP A LOCATION
    //USES THE PLACE AUTOCOMPLETE METHOD
    //**************************************
    var autocomplete = new google.maps.places.Autocomplete( /** @type {HTMLInputElement} */(
        document.getElementById('pac-input')), //GRAB TEXT FROM SEARCH BOX
          {
            types: ['geocode'], //LOOKING FOR LOCATIONS AND PLACES ONLY 
          });
    autocomplete.bindTo('bounds', map); //BIND THE RESULTS TO BOUND TO MAP

    
    //CREATE INFO WINDOW TO DISPLAY DETAILS    
    var infowindow = new google.maps.InfoWindow();
    //CREATE A MARKER TO SHOW SEARCHED LOCATION
    var locmarker = new google.maps.Marker({
        map: map,
        anchorPoint: new google.maps.Point(0, -29)
    });

    //NEW PLACE SEARCH WILL CLOSE INFO WINDOW, HIDE MARKER AND GRAB THE NEW LOCATION
    google.maps.event.addListener(autocomplete, 'place_changed', function() {
        infowindow.close();
        locmarker.setVisible(false);
        var place = autocomplete.getPlace();
        if (!place.geometry) {
            return;
        }

        // If the place has a geometry, then present it on a map.
        if (place.geometry.viewport) {
            map.fitBounds(place.geometry.viewport);
        } 
        else {
            map.setCenter(place.geometry.location);
            map.setZoom(15);  // Why 15? Because it looks good.
        }
        
        //SHOW POSITION AND MAKE MARKER SHOW WHEN PLACE HAS BEEN FOUND  
        locmarker.setPosition(place.geometry.location);
        //GRAB THE PLACE ADDRESS AND SELECT THE FIRST THREE DETAILS FROM ARRAY  
        var address = '';
        if (place.address_components) {
            address = [
                (place.address_components[0] && place.address_components[0].short_name || ''),
                (place.address_components[1] && place.address_components[1].short_name || ''),
                (place.address_components[2] && place.address_components[2].short_name || '')
            ].join(' ');
        }
    });
    
    
    /*==============================CREATE AND DISPLAY GOOGLE MAPS DRAWING TOOLS============================*/
    // create a dialog box but don't bind it to anything yet
    myInfoWindow = new google.maps.InfoWindow();
    
    //DRAWING THE POLYGON ON MAP WHEN USERS SELECTS THE DRAW BUTTON
    $(".draw").on('click', function(e) {
        e.preventDefault(); //PREVENT THE LINK FROM JUMPING TO THE TOP OF THE PAGE
        document.getElementById("map_hand").style.cursor = "crosshair";
        directionsDisplay.setMap(null);
        $('#travelTab').hide('slow');
        disable()
        
        google.maps.event.addDomListener(map.getDiv(),'mousedown',function(e){
            drawFreeHand()
        });
    })//CLICK EVENT CLOSED

}//FUNCTION INT CLOSED

//SET UP THE GOOGLE MAPS ONTO SITE ON WINDOW LOAD

SET UP THE GOOGLE MAPS ONTO SITE ON WINDOW LOAD
SET UP THE GOOGLE MAPS ONTO SITE ON WINDOW LOAD
function initialize() {
    var mapOptions = {
    zoom: 15 
    };
    map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
    directionsDisplay.setMap(map);
    directionsDisplay.setPanel(document.getElementById("directionsPanel"));
    if(navigator.geolocation) {
        navigator.geolocation.getCurrentPosition(function(position) {
            var pos = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
            map.setCenter(pos);
            sessionStorage.setItem('currentpos', pos); 
        },
        function() {
            handleNoGeolocation(true);
        });
    } else{
        handleNoGeolocation(false);
    }
    function handleNoGeolocation(errorFlag) {
        if (errorFlag) {
            var content = 'Error: The Geolocation service failed.';
        } else {
            var content = 'Error: Your browser doesn\'t support geolocation.';
        }
        var options = {
            map: map,
            position: new google.maps.LatLng(60, 105),
            content: content
        };
        var infowindow = new google.maps.InfoWindow(options);
        map.setCenter(options.position);
    }
    var autocomplete = new google.maps.places.Autocomplete( (
        document.getElementById('pac-input')), 
          {
            types: ['geocode'], 
          });
    autocomplete.bindTo('bounds', map); 
    var infowindow = new google.maps.InfoWindow();
    var locmarker = new google.maps.Marker({
        map: map,
        anchorPoint: new google.maps.Point(0, -29)
    });
    google.maps.event.addListener(autocomplete, 'place_changed', function() {
        infowindow.close();
        locmarker.setVisible(false);
        var place = autocomplete.getPlace();
        if (!place.geometry) {
            return;
        }
        if (place.geometry.viewport) {
            map.fitBounds(place.geometry.viewport);
        } 
        else {
            map.setCenter(place.geometry.location);
            map.setZoom(15);  
        }
        locmarker.setPosition(place.geometry.location);
        var address = '';
        if (place.address_components) {
            address = [
                (place.address_components[0] && place.address_components[0].short_name || ''),
                (place.address_components[1] && place.address_components[1].short_name || ''),
                (place.address_components[2] && place.address_components[2].short_name || '')
            ].join(' ');
        }
    });
    myInfoWindow = new google.maps.InfoWindow();
    $(".draw").on('click', function(e) {
        e.preventDefault(); 
        document.getElementById("map_hand").style.cursor = "crosshair";
        directionsDisplay.setMap(null);
        $('#travelTab').hide('slow');
        disable()
        google.maps.event.addDomListener(map.getDiv(),'mousedown',function(e){
            drawFreeHand()
        });
    })
}
function initialize ( ) { var mapOptions = { zoom : 15 } ; map = new google . maps . Map ( document . getElementById ( 'map-canvas' ) , mapOptions ) ; directionsDisplay . setMap ( map ) ; directionsDisplay . setPanel ( document . getElementById ( "directionsPanel" ) ) ; if ( navigator . geolocation ) { navigator . geolocation . getCurrentPosition ( function ( position ) { var pos = new google . maps . LatLng ( position . coords . latitude , position . coords . longitude ) ; map . setCenter ( pos ) ; sessionStorage . setItem ( 'currentpos' , pos ) ; } , function ( ) { handleNoGeolocation ( true ) ; } ) ; } else { handleNoGeolocation ( false ) ; } function handleNoGeolocation ( errorFlag ) { if ( errorFlag ) { var content = 'Error: The Geolocation service failed.' ; } else { var content = 'Error: Your browser doesn\'t support geolocation.' ; } var options = { map : map , position : new google . maps . LatLng ( 60 , 105 ) , content : content } ; var infowindow = new google . maps . InfoWindow ( options ) ; map . setCenter ( options . position ) ; } var autocomplete = new google . maps . places . Autocomplete ( ( document . getElementById ( 'pac-input' ) ) , { types : [ 'geocode' ] , } ) ; autocomplete . bindTo ( 'bounds' , map ) ; var infowindow = new google . maps . InfoWindow ( ) ; var locmarker = new google . maps . Marker ( { map : map , anchorPoint : new google . maps . Point ( 0 , - 29 ) } ) ; google . maps . event . addListener ( autocomplete , 'place_changed' , function ( ) { infowindow . close ( ) ; locmarker . setVisible ( false ) ; var place = autocomplete . getPlace ( ) ; if ( ! place . geometry ) { return ; } if ( place . geometry . viewport ) { map . fitBounds ( place . geometry . viewport ) ; } else { map . setCenter ( place . geometry . location ) ; map . setZoom ( 15 ) ; } locmarker . setPosition ( place . geometry . location ) ; var address = '' ; if ( place . address_components ) { address = [ ( place . address_components [ 0 ] && place . address_components [ 0 ] . short_name || '' ) , ( place . address_components [ 1 ] && place . address_components [ 1 ] . short_name || '' ) , ( place . address_components [ 2 ] && place . address_components [ 2 ] . short_name || '' ) ] . join ( ' ' ) ; } } ) ; myInfoWindow = new google . maps . InfoWindow ( ) ; $ ( ".draw" ) . on ( 'click' , function ( e ) { e . preventDefault ( ) ; document . getElementById ( "map_hand" ) . style . cursor = "crosshair" ; directionsDisplay . setMap ( null ) ; $ ( '#travelTab' ) . hide ( 'slow' ) ; disable ( ) google . maps . event . addDomListener ( map . getDiv ( ) , 'mousedown' , function ( e ) { drawFreeHand ( ) } ) ; } ) }
SET UP THE GOOGLE MAPS ONTO SITE ON WINDOW LOAD
SET UP THE GOOGLE MAPS ONTO SITE ON WINDOW LOAD
//ZOOM INTO 15X AT USERS CURRENT LOCATION
 //SHOWS THE MAP ON THE ID CALLED MAP-CANVA    
 //LOOKS FOR USERS CURRENT LOCATION 
 //CENTER MAP AT USERS CURRENT POSITION
 //set within session for directions purpose
 // Browser doesn't support Geolocation
 //ERROR FOR NO BROWSER SUPPORT (VALIDATION) 
 //**************************************
 // SEARCHBOX TO LOOK UP A LOCATION
 //USES THE PLACE AUTOCOMPLETE METHOD
 //**************************************
 /** @type {HTMLInputElement} */ //GRAB TEXT FROM SEARCH BOX
 //LOOKING FOR LOCATIONS AND PLACES ONLY 
 //BIND THE RESULTS TO BOUND TO MAP
 //CREATE INFO WINDOW TO DISPLAY DETAILS    
 //CREATE A MARKER TO SHOW SEARCHED LOCATION
 //NEW PLACE SEARCH WILL CLOSE INFO WINDOW, HIDE MARKER AND GRAB THE NEW LOCATION
 // If the place has a geometry, then present it on a map.
 // Why 15? Because it looks good.
 //SHOW POSITION AND MAKE MARKER SHOW WHEN PLACE HAS BEEN FOUND  
 //GRAB THE PLACE ADDRESS AND SELECT THE FIRST THREE DETAILS FROM ARRAY  
 /*==============================CREATE AND DISPLAY GOOGLE MAPS DRAWING TOOLS============================*/ // create a dialog box but don't bind it to anything yet
 //DRAWING THE POLYGON ON MAP WHEN USERS SELECTS THE DRAW BUTTON
 //PREVENT THE LINK FROM JUMPING TO THE TOP OF THE PAGE
 //CLICK EVENT CLOSED
 //FUNCTION INT CLOSED
