$(function(){ var map = new GMap2(document.getElementById('map_canvas_hdr')); var lat = 37.6; var lon = -94.583062; var zoom = 5; var distance = 5000; var locationStr = 'Zip code or City, State...'; var startLatLon = new GLatLng(lat,lon); //alert("I'm running the mini map code and zoom="+zoom+ " distance=" +distance); map.setUIToDefault(); map.setCenter(startLatLon, zoom); var geo = new GClientGeocoder(); loadLocations(lat, lon, locationStr, distance, zoom); var reasons=[]; reasons[G_GEO_SUCCESS] = 'Success'; reasons[G_GEO_MISSING_ADDRESS] = 'Missing Address'; reasons[G_GEO_UNKNOWN_ADDRESS] = 'Unknown Address.'; reasons[G_GEO_UNAVAILABLE_ADDRESS]= 'Unavailable Address'; reasons[G_GEO_BAD_KEY] = 'Bad API Key'; reasons[G_GEO_TOO_MANY_QUERIES] = 'Too Many Queries'; reasons[G_GEO_SERVER_ERROR] = 'Server error'; $('#carxlocationhdr').submit(function(){ openSlide(); return false; }); function resetPoint(geocode) { map.clearOverlays(); var newLatLon = new GLatLng(geocode[1],geocode[0]); var newAddress = $('#carxlocationhdr input[name=addresshdr]').val(); var newDistance = 25; var newZoom = 13; map.setCenter(newLatLon, newZoom); loadLocations(geocode[1], geocode[0], newAddress, newDistance, newZoom); } function geoEncode() { var address = $('#carxlocationhdr input[name=addresshdr]').val(); var no_Comma; var no_Space; if (isNaN(address)) { if (address.indexOf(",") == -1) { no_Comma = true; } if (address.indexOf(" ") == -1) { no_Space = true; } if (no_Comma && no_Space) { alert("Please specify a zip code or \"City, State\"") return false; } } geo.getLocations(address, function (result){ if (result.Status.code == G_GEO_SUCCESS) { geocode = result.Placemark[0].Point.coordinates; resetPoint(geocode); } else { var reason='Code '+result.Status.code; if (reasons[result.Status.code]) { reason = reasons[result.Status.code] } alert(reason); geocode = false; } }); } function addLocation(location) { var point = new GLatLng(location.lat, location.lng); // Create the car-x marker icon var carxIcon = new GIcon(G_DEFAULT_ICON); carxIcon.image = 'http://www.carx.com/images/map_pin.png'; carxIcon.shadow = 'http://www.carx.com/images/map_pin_shadow.png'; carxIcon.iconSize = new GSize(36, 21); carxIcon.shadowSize = new GSize(44, 29); carxIcon.iconAnchor = new GPoint(18, 11); carxIcon.infoWindowAnchor = new GPoint(18, 11); // Set up our GMarkerOptions object markerOptions = { icon:carxIcon }; var marker = new GMarker(point, markerOptions); map.addOverlay(marker); var markerText = '
' + location.address1 + ' ' + location.address2 + '
' + location.phone + 'View Coupons