var markersArray = []; var geocoder; var myLatLng; var map; var infowindow = new google.maps.InfoWindow(); var arrayStores = new Array(2000); var gstrCurrentDate = "2012-02-23"; // CUSTOM ICONS var icons = { start: new google.maps.MarkerImage( // URL '../_images/indicator-A.gif', // (width,height) new google.maps.Size(28, 43), // The origin point (x,y) new google.maps.Point(0, 0), // The anchor point (x,y) new google.maps.Point(13, 40) ), end: new google.maps.MarkerImage( // URL '../_images/indicator-B.gif', // (width,height) new google.maps.Size(28, 43), // The origin point (x,y) new google.maps.Point(0, 0), // The anchor point (x,y) new google.maps.Point(13, 40) ), store: new google.maps.MarkerImage( // URL '../_images/marker-red.png', // (width,height) new google.maps.Size(28, 43), // The origin point (x,y) new google.maps.Point(0, 0), // The anchor point (x,y) new google.maps.Point(13, 40) ), grand_open: new google.maps.MarkerImage( // URL '../_images/marker-green.png', // (width,height) new google.maps.Size(28, 43), // The origin point (x,y) new google.maps.Point(0, 0), // The anchor point (x,y) new google.maps.Point(13, 40) ) }; // toggle to 0 for production var debugFlag = 0; function debugMode(input, force) { if ( (debugFlag == 1) || (force == 1) ) { // console.log(input); } } function showOnMapInfoWindow(marker_num) { // infowindow.open(map, markersArray[marker_num]); google.maps.event.trigger(markersArray[marker_num], 'click'); } function toggleInfoTabs(tab_name) { debugMode(tab_name); var display_element = 'marker_' + tab_name; if ($(display_element).visible()) { } if (!$(display_element).visible()) { if ($('marker_storeinfo').visible()) { $('marker_storeinfo').toggle(); } if ($('marker_services').visible()) { $('marker_services').toggle(); } if ($('marker_directions').visible()) { $('marker_directions').toggle(); } $(display_element).toggle(); } } function renderResults(data) { var storeSingPlur = ' Store'; var storesCount = data.markers.length; if (storesCount > 1) { storeSingPlur = ' Stores'; } debugMode('renderResults: data: '); //debugMode(data.toSource()); var results = '

' + data.markers.length + '' + storeSingPlur + ' Found

'; results += '
'; results += '

'; results += 'Check our Grand Openings arrow

'; document.getElementById('results-top').innerHTML = results; for (var i = 0; i < storesCount; i++) { if (data.markers[i].Grandopen >= gstrCurrentDate) { strStoreHTML = "
Store
" } else { strStoreHTML = "
Store
" } strStoreHTML += "

" + data.markers[i].Store_name + "
Store #" + data.markers[i].Store_id + "

"; if(data.markers[i].Grandopen >= gstrCurrentDate) { strStoreHTML = strStoreHTML + "

Opening " + data.markers[i].Grandopen + "

"; } strStoreHTML += "

" + data.markers[i].Address + "
" strStoreHTML += data.markers[i].City + ', ' + data.markers[i].State + ' ' + data.markers[i].Zipcode + "
"; strStoreHTML += data.markers[i].Phone + "
"; strStoreHTML += data.markers[i].distance + " miles

"; strHref = "javascript:showOnMapInfoWindow(" + i + ")"; strStoreHTML += "

Show on map

"; strStoreHTML += "

See Details

"; strStoreHTML += "

View in-store specials

"; strStoreHTML += "
"; //passed all the edits, so add the store marker //save the store info for the sidebar arrayStores[i] = strStoreHTML; debugMode('arrayStores ' + i + ': ' + arrayStores[i]); debugMode('strStoreHTML: ' + strStoreHTML); // strStoreInfoHTML = fncStoreInfoHTML(markers[i], i); //add store count and prev - next buttons to start of store list var iRemainder = storesCount % 3; iStorePages = ( storesCount - iRemainder ) / 3; if (iRemainder > 0) { iStorePages = iStorePages + 1; } strPageCountHTML = "

Showing page 1 of " + iStorePages + "

" ; strPageCountHTML += "Previous" if(iStorePages > 1) { strPageCountHTML += "
"; strPageCountHTML += "Next
" } else { strPageCountHTML += "Next" } // add line strPageCountHTML += "
" //get the stores for the first page if (storesCount > 0 && storesCount < 4) { iCurrentPage = 1; } else { iCurrentPage = 0; } strStoreHTML += fncStoreHTML(true); // add line before the last prev - next buttons strStoreHTML += "
" //add prev - next buttons to end of store list strStoreHTML += "Previous" if (iStorePages > 1) { strStoreHTML += "
"; strStoreHTML += "Next
" } else { fncStoreHTML(false); } } } function clearMarkers() { debugMode(markersArray.length); // debugMode(markersArray.toSource(), 1); if (markersArray.length > 0) { infowindow.close(); for (var i = 0; i < markersArray.length; i++) { markersArray[i].setMap(null); } markersArray = new Array(); } } /* var infoBubble; function init() { var mapCenter = new google.maps.LatLng(-35.397, 150.644); map = new google.maps.Map(document.getElementById('map'), { zoom: 8, center: mapCenter, mapTypeId: google.maps.MapTypeId.ROADMAP }); var marker = new google.maps.Marker({ map: map, position: new google.maps.LatLng(-35, 150), draggable: true }); var contentString = '
'+ '

Uluru

'+ '

Uluru, also referred to as Ayers Rock, is a large ' + 'sandstone rock formation in the southern part of the '+ 'Northern Territory, central Australia. It lies 335 km (208 mi) '+ 'south west of the nearest large town, Alice Springs; 450 km '+ '(280 mi) by road. Kata Tjuta and Uluru are the two major '+ 'features of the Uluru - Kata Tjuta National Park. Uluru is '+ 'sacred to the Pitjantjatjara and Yankunytjatjara, the '+ 'Aboriginal people of the area. It has many springs, waterholes, '+ 'rock caves and ancient paintings. Uluru is listed as a World '+ 'Heritage Site.

'+ '

Attribution: Uluru, '+ 'http://en.wikipedia.org/w/index.php?title=Uluru '+ '(last visited June 22, 2009).

'+ '
'; infoBubble = new InfoBubble({ maxWidth: 300 }); infoBubble2 = new InfoBubble({ map: map, content: '
Some label
', position: new google.maps.LatLng(-35, 151), shadowStyle: 1, padding: 0, backgroundColor: 'rgb(57,57,57)', borderRadius: 4, arrowSize: 10, borderWidth: 1, borderColor: '#2c2c2c', disableAutoPan: true, hideCloseButton: true, arrowPosition: 30, backgroundClassName: 'phoney', arrowStyle: 2 }); infoBubble.open(map, marker); infoBubble2.open(); var div = document.createElement('DIV'); div.innerHTML = 'Hello'; infoBubble.addTab('A Tab', div); infoBubble.addTab('Uluru', contentString); google.maps.event.addListener(marker, 'click', function() { if (!infoBubble.isOpen()) { infoBubble.open(map, marker); } }); google.maps.event.addDomListener(document.getElementById('update'), 'click', updateStyles); google.maps.event.addDomListener(document.getElementById('add'), 'click', addTab); google.maps.event.addDomListener(document.getElementById('update-tab'), 'click', updateTab); google.maps.event.addDomListener(document.getElementById('remove'), 'click', removeTab); google.maps.event.addDomListener(document.getElementById('open'), 'click', function() { infoBubble2.open(); }); google.maps.event.addDomListener(document.getElementById('close'), 'click', function() { infoBubble2.close(); }); } google.maps.event.addDomListener(window, 'load', init); function updateStyles() { var shadowStyle = document.getElementById('shadowstyle').value; infoBubble.setShadowStyle(shadowStyle); var padding = document.getElementById('padding').value; infoBubble.setPadding(padding); var borderRadius = document.getElementById('borderRadius').value; infoBubble.setBorderRadius(borderRadius); var borderWidth = document.getElementById('borderWidth').value; infoBubble.setBorderWidth(borderWidth); var borderColor = document.getElementById('borderColor').value; infoBubble.setBorderColor(borderColor); var backgroundColor = document.getElementById('backgroundColor').value; infoBubble.setBackgroundColor(backgroundColor); var maxWidth = document.getElementById('maxWidth').value; infoBubble.setMaxWidth(maxWidth); var maxHeight = document.getElementById('maxHeight').value; infoBubble.setMaxHeight(maxHeight); var minWidth = document.getElementById('minWidth').value; infoBubble.setMinWidth(minWidth); var minHeight = document.getElementById('minHeight').value; infoBubble.setMinHeight(minHeight); var arrowSize = document.getElementById('arrowSize').value; infoBubble.setArrowSize(arrowSize); var arrowPosition = document.getElementById('arrowPosition').value; infoBubble.setArrowPosition(arrowPosition); var arrowStyle = document.getElementById('arrowStyle').value; infoBubble.setArrowStyle(arrowStyle); } function addTab() { var title = document.getElementById('tab-title').value; var content = document.getElementById('tab-content').value; if (title != '' && content != '') { infoBubble.addTab(title, content); } } function updateTab() { var index = document.getElementById('tab-index-update').value; var title = document.getElementById('tab-title-update').value; var content = document.getElementById('tab-content-update').value; if (index) { infoBubble.updateTab(index, title, content); } } function removeTab() { var index = document.getElementById('tab-index').value; infoBubble.removeTab(index); } */ //function onload() function load() { debugMode("in load function for new page load"); var latlng = new google.maps.LatLng(42, -96); var myOptions = { zoom: 4, center: latlng, mapTypeId: google.maps.MapTypeId.ROADMAP }; map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); var location = ''; var radius = ''; var grooming = ''; location = getQueryVariable('location'); radius = getQueryVariable('radius'); grooming = getQueryVariable('grooming'); if (radius == 0) { radius = 20; } if (location) { getStores(location, radius, grooming); } } function getQueryVariable(variable) { var query = window.location.search.substring(1); var vars = query.split("&"); for (var i=0; iStore Info | Services | Directions
'; html += '
'; html += '
'; html += '

'; // html += '
'; html += '
'; html += '

'+ storeInfo.Store_name + ' #' + storeInfo.Store_id + '

'; html += '

' + storeInfo.Address + '
' + storeInfo.City + ', ' + storeInfo.State + ' ' + storeInfo.Zipcode + '
' + storeInfo.Phone + '
' + storeInfo.distance + ' miles

'; html += '

Monday-Saturday: ' + storeInfo.Store_open + 'a.m. - ' + storeInfo.Store_close + ' p.m.
Sunday: ' + storeInfo.Sunday_store_open + ' a.m. - ' + storeInfo.Sunday_store_close + ' p.m.

'; html += '

Please call store to confirm hours.

'; html += '
'; html += '
'; html += ''; var storeDestAddr = storeInfo.Address + ', ' + storeInfo.City + ', ' + storeInfo.State + ' ' + storeInfo.Zipcode; var baseURL = window.location.hostname; // baseURL = baseURL[1]; html += ''; html += ''; return html; } function displayMarker(i, whichLatlng, canDrag, whichMap, icon, contentString) { var marker = new google.maps.Marker({map: whichMap}); var marker_options = ({ position: whichLatlng, draggable: canDrag, icon: icon, content: contentString }); marker.setOptions(marker_options); debugMode('marker content: ' + contentString); google.maps.event.addListener(marker, 'click', function() { infowindow.setOptions(marker_options); infowindow.open(map, marker); }); // markersArray.push(marker); // whichMap.setCenter(whichLatlng); return marker; } function getStores(location, dist, grooming) { var address = ''; var radius = ''; var service_selection = ''; if (location && dist && grooming) { address = location; radius = dist; service_selection = '&groom=G'; } else { address = document.getElementById('location').value; radius = document.getElementById('miles').value; if (document.searchLocations.adoptions.checked) { service_selection += '&adopt=A'; } if (document.searchLocations.doggie_day_camp.checked) { service_selection += '&daycamp=D'; } if (document.searchLocations.grooming.checked) { service_selection += '&groom=G'; } if (document.searchLocations.training.checked) { service_selection += '&train=T'; } if (document.searchLocations.boarding.checked) { service_selection += '&board=B'; } if (document.searchLocations.veterinary.checked) { service_selection += '&vet=V'; } debugMode(service_selection); } debugMode("in getStores -- addr: " + address + ' -- radius: ' + radius); if (!geocoder) { geocoder = new google.maps.Geocoder(); } var geocoderRequest = {address: address}; geocoder.geocode(geocoderRequest, function(results, status) { // Check if status is OK before proceeding if (status != google.maps.GeocoderStatus.OK) { alert("Sorry, " + address + " could not be found"); return; } customerLatLng = results[0].geometry.location; var searchUrl = '/_includes/store_radius_search.php?lat=' + customerLatLng.lat() + '&lng=' + customerLatLng.lng() + '&radius=' + radius + service_selection; debugMode(searchUrl); downloadUrl(searchUrl, function(data) { debugMode(data); var jsonData = eval('(' + data + ')'); clearMarkers(); var bounds = new google.maps.LatLngBounds(); for (var i = 0; i < jsonData.markers.length; i++) { var name = jsonData.markers[i].Store_name; var store_num = jsonData.markers[i].Store_id; var address = jsonData.markers[i].Address; debugMode('result: ' + i + ' -- Store no: ' + store_num + ' -- Name: ' + name + ' -- Lat/Lng: ' + jsonData.markers[i].latitude + '/' + jsonData.markers[i].longitude); var point = new google.maps.LatLng(jsonData.markers[i].latitude, jsonData.markers[i].longitude); var content = createInfoWindowData(jsonData.markers[i]); if (jsonData.markers[i].Grandopen > gstrCurrentDate) { icon = icons.grand_open; } else { icon = icons.store; } marker = displayMarker(i, point, false, map, icon, content); markersArray.push(marker); bounds.extend(point); // google.maps.event.addListener(marker, 'dragend', function() { // updateLatLng(marker, true, map); // }); // google.maps.event.addListener(map, 'click', function(event) { // clearMarkers(); // marker = displayMarker(event.latLng, true, map); // updateLatLng(marker, true, map); // google.maps.event.addListener(marker, 'dragend', function() { // updateLatLng(marker, true, map); // }); // }); } map.fitBounds(bounds); if (jsonData.markers.length == 1) { map.setZoom(14); } renderResults(jsonData); debugMode('profile: fitbounds'); }); debugMode("Completed rendering map and store markers"); }); debugMode("Exiting getStores"); } function downloadUrl(url, callback) { var request = window.ActiveXObject ? new ActiveXObject('Microsoft.XMLHTTP') : new XMLHttpRequest; request.onreadystatechange = function() { if (request.readyState == 4) { request.onreadystatechange = doNothing; callback(request.responseText, request.status); } }; request.open('GET', url, true); request.send(null); } function checkKey(e) { var keycode; if (window.event) keycode = window.event.keyCode; else if (e) keycode = e.which; else return true; if (keycode == 13) { ReloadMap(false); } } function returnValues() { var search_location = ""; var search_radius = ""; var search_adoptions = ""; var search_ddc = ""; var search_grooming = ""; var search_training = ""; var search_boarding = ""; var search_veterinary = ""; if(search_adoptions == "Adoptions") { document.searchLocations.adoptions.checked = true; } if(search_ddc == "Doggie Day Camp") { document.searchLocations.doggie_day_camp.checked = true; } if(search_grooming == "Grooming") { document.searchLocations.grooming.checked = true; } // if(search_photography == "Photography") // { // document.searchLocations.photography.checked = true; // } if(search_training == "Training") { document.searchLocations.training.checked = true; } if(search_boarding == "Boarding (PetsHotel)") { document.searchLocations.boarding.checked = true; } if(search_veterinary == "Veterinary (Banfield)") { document.searchLocations.veterinary.checked = true; } // ReloadMap(false, search_location, search_radius, search_adoptions, search_ddc, search_grooming, search_photography, search_training, search_boarding, search_veterinary); // ReloadMap(false, search_location, search_radius, search_adoptions, search_ddc, search_grooming, search_training, search_boarding, search_veterinary); } function fncStoreHTML(bNextPage) { var strStoreHTML; var iCntr = 0; if(bNextPage == true) iCurrentPage++; else iCurrentPage--; //generate store sidebar html strStoreHTML = "

Showing page " + iCurrentPage + " of " + iStorePages + "

" ; //update the top page buttons //previous button if(iCurrentPage < 2) { strStoreHTML = strStoreHTML + "Previous"; } else { strStoreHTML = strStoreHTML + "
"; strStoreHTML = strStoreHTML + "Previous
"; } //next button if(iCurrentPage < iStorePages) { strStoreHTML = strStoreHTML + "
"; strStoreHTML = strStoreHTML + "Next
"; } else { strStoreHTML = strStoreHTML + "Next"; } strStoreHTML = strStoreHTML + "
"; //add the store information strStores = ""; iStartCntr = iCurrentPage*3 -3; iEndCntr = iCurrentPage*3; for (iCntr = iStartCntr; iCntr < iEndCntr; iCntr++) { if (arrayStores[iCntr] != null) { strStores = strStores + arrayStores[iCntr]; } else { strStores = strStores + "









"; } } strStoreHTML = strStoreHTML + strStores; // update the bottom page buttons strStoreHTML += '
'; strStoreHTML = strStoreHTML + "
"; //add prev - next buttons to end of store list if (iCurrentPage > 1) { strStoreHTML = strStoreHTML + "
"; strStoreHTML = strStoreHTML + "Previous
"; } else { strStoreHTML = strStoreHTML + "Previous"; } if (iCurrentPage < iStorePages) { strStoreHTML = strStoreHTML + "
"; strStoreHTML = strStoreHTML + "Next
"; } else { strStoreHTML = strStoreHTML + "Next
"; } strStoreHTML += '
'; // document.getElementById('results-container').innerHTML = strStoreHTML; document.getElementById('results-container').innerHTML = strStoreHTML; // document.getElementById('results-container').innerText = strStoreHTML; } function submitenter(myfield,e) { var keycode; if (window.event) keycode = window.event.keyCode; else if (e) keycode = e.which; else return true; if (keycode == 13) { myfield.form.submit(); return false; } else { return true; } } function doNothing() {}