/* Error messages for possible errors */ var error_address_empty = 'Please enter a valid address first.'; var error_invalid_address = 'This address is invalid. Make sure to enter your street number and city as well?'; var error_google_error = 'There was a problem processing your request, please try again.'; var error_no_map_info = 'Sorry! Map information is not available for this address.'; /**********************************************************************************************************************/ /* CHANGE THIS TO YOUR ADDRESS - The default address of your store, This address will display on the map on startup */ /**********************************************************************************************************************/ marker_txt='

Locanda - Ristorante Bellevue
Avenue du Mont Blanc, 52
11010 - Pré Saint Didier (AOSTA) Italy

' var makerker_position = new google.maps.LatLng(45.76433463219172, 6.985872387886047); var current_address = null; /* Current address we are displaying, we save it here for directions */ var map = null; /* Instance of Google Maps object */ var geocoder = null; /* Instance of Google Deocoder object */ var gdir = null; /* Instance of Google Directions object */ var map_compatible = false; /* Whether or not user's browser is compatible to show the map */ /* Check if the browser is compatible */ if( GBrowserIsCompatible() ) { map_compatible = true; } /* Initialize the map this will be called when the document is loaded from: */ function initialize_map() { if( map_compatible ) { map = new GMap2(document.getElementById('map_canvas')); gdir = new GDirections(map, document.getElementById('directions')); geocoder = new GClientGeocoder(); map.setCenter(makerker_position, 13); var Icon = new GIcon(); Icon.image = "img/Google.png"; Icon.iconSize=new GSize(48,60); Icon.iconAnchor = new GPoint(24, 54); var marker = new GMarker(makerker_position, Icon); map.addOverlay(marker); marker.openInfoWindowHtml(marker_txt); GEvent.addListener(marker, "click", function() { marker.openInfoWindowHtml(marker_txt); }); current_address = makerker_position; /* This displays the zoom controls for the map. If you don't want them just delete the line */ map.addControl(new GSmallMapControl()); /* This displays the map type. If you don't want that feature then just delete this */ map.addControl(new GMapTypeControl()); } } /* Get the directions */ function get_directions() { if( map_compatible ) { if( document.getElementById('from_address').value == '' ) { alert(error_address_empty); return false; } /** * Delete the contents of 'directions' DIV first * because user might ask for directions more than once. **/ document.getElementById('directions').innerHTML = ''; /* Setup to event handlers, one: when the directions are loaded, two: if there was any error */ GEvent.addListener(gdir, 'load', onGDirectionsLoad); GEvent.addListener(gdir, 'error', handleErrors); /* Show the directions */ set_directions(document.getElementById('from_address').value, current_address); } return false; } /* This will actually set the directions on the map and loads the direction table */ function set_directions(fromAddress, toAddress) { gdir.load("from: " + fromAddress + " to: " + toAddress,{ "locale": "en" }); } /* This will handle the errors might happen while retrieving the directions */ function handleErrors(){ if( gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS ) alert(error_invalid_address); else if( gdir.getStatus().code == G_GEO_SERVER_ERROR ) alert(error_google_error); else if( gdir.getStatus().code == G_GEO_MISSING_QUERY ) alert(error_address_empty); else alert(error_invalid_address); } /* This function will be called when the directions are loaded */ function onGDirectionsLoad(){ /* We will simple scroll down to the directions, but with a little delay so it's loaded */ setTimeout('eval(\'window.location = "#directions_table"\;\')', 500); }