function addMarkers()
{
mySelect = document.getElementById('selection');
Kennewick = [];Richland = [];Pasco = [];Prosser = [];Benton_City = [];Paterson = [];_Prosser_Ave = [];West_Richland = [];mySelect.options[mySelect.options.length] = new Option("Benton City schools",'all=Benton_City');
mySelect.options[mySelect.options.length] = new Option("Kennewick schools",'all=Kennewick');
mySelect.options[mySelect.options.length] = new Option("Pasco schools",'all=Pasco');
mySelect.options[mySelect.options.length] = new Option("Paterson schools",'all=Paterson');
mySelect.options[mySelect.options.length] = new Option("Prosser schools",'all=Prosser');
mySelect.options[mySelect.options.length] = new Option("Richland schools",'all=Richland');
mySelect.options[mySelect.options.length] = new Option("West Richland schools",'all=West_Richland');
mySelect.options[mySelect.options.length] = new Option(" Prosser Ave schools",'all=_Prosser_Ave');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Kennewick[Kennewick.length] = createMarker(new GPoint(-119.13143158,46.20583725),"
",iconRd);
mySelect.options[mySelect.options.length] = new Option("Amistad Elementary School",'Kennewick=' + Kennewick.length);
Richland[Richland.length] = createMarker(new GPoint(-119.26950073,46.23400116),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Badger Mountain Elementary School",'Richland=' + Richland.length);
Pasco[Pasco.length] = createMarker(new GPoint(-118.57599640,46.53578186),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Benton-franklin Developmental Center",'Pasco=' + Pasco.length);
Kennewick[Kennewick.length] = createMarker(new GPoint(-119.19476318,46.22369766),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Benton/franklin Juvenile Justice Center",'Kennewick=' + Kennewick.length);
Kennewick[Kennewick.length] = createMarker(new GPoint(-119.13418579,46.18856430),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Canyon View Elementary School",'Kennewick=' + Kennewick.length);
Richland[Richland.length] = createMarker(new GPoint(-119.28990173,46.27298737),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Carmichael Middle School",'Richland=' + Richland.length);
Kennewick[Kennewick.length] = createMarker(new GPoint(-119.12570190,46.17297745),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Cascade Elementary School",'Kennewick=' + Kennewick.length);
Richland[Richland.length] = createMarker(new GPoint(-119.28206635,46.29568863),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Chief Joseph Middle School",'Richland=' + Richland.length);
Kennewick[Kennewick.length] = createMarker(new GPoint(-119.20502472,46.19846344),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Desert Hills Middle School",'Kennewick=' + Kennewick.length);
Kennewick[Kennewick.length] = createMarker(new GPoint(-119.10392761,46.19806290),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Eastgate Elementary School",'Kennewick=' + Kennewick.length);
Kennewick[Kennewick.length] = createMarker(new GPoint(-119.19049835,46.20818710),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Edison Elementary School",'Kennewick=' + Kennewick.length);
Kennewick[Kennewick.length] = createMarker(new GPoint(-119.05467224,46.14331818),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Finley Elementary School",'Kennewick=' + Kennewick.length);
Kennewick[Kennewick.length] = createMarker(new GPoint(-119.03409576,46.15555191),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Finley Middle School",'Kennewick=' + Kennewick.length);
Richland[Richland.length] = createMarker(new GPoint(-119.27203369,46.32413864),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Hanford High School",'Richland=' + Richland.length);
Richland[Richland.length] = createMarker(new GPoint(-119.26749420,46.32403564),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Hanford Middle School",'Richland=' + Richland.length);
Kennewick[Kennewick.length] = createMarker(new GPoint(-119.16825104,46.21793747),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Hawthorne Elementary School",'Kennewick=' + Kennewick.length);
Kennewick[Kennewick.length] = createMarker(new GPoint(-119.17803955,46.20589447),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Highlands Middle School",'Kennewick=' + Kennewick.length);
Kennewick[Kennewick.length] = createMarker(new GPoint(-119.14869690,46.17756271),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Horse Heaven Hills Middle School",'Kennewick=' + Kennewick.length);
Prosser[Prosser.length] = createMarker(new GPoint(-119.75357819,46.20926285),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Housel Middle School",'Prosser=' + Prosser.length);
Richland[Richland.length] = createMarker(new GPoint(-119.29331207,46.29323578),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Jason Lee Elementary School",'Richland=' + Richland.length);
Richland[Richland.length] = createMarker(new GPoint(-119.27209473,46.29258728),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Jefferson Elementary School",'Richland=' + Richland.length);
Kennewick[Kennewick.length] = createMarker(new GPoint(-119.18630219,46.21548843),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Kamiakin High School",'Kennewick=' + Kennewick.length);
Prosser[Prosser.length] = createMarker(new GPoint(-119.77518463,46.20053864),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Keene-riverview Elementary School",'Prosser=' + Prosser.length);
Kennewick[Kennewick.length] = createMarker(new GPoint(-119.12319946,46.20674515),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Keewaydin Discovery Center",'Kennewick=' + Kennewick.length);
Kennewick[Kennewick.length] = createMarker(new GPoint(-119.11869812,46.20321274),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Kennewick Alternative Education",'Kennewick=' + Kennewick.length);
Kennewick[Kennewick.length] = createMarker(new GPoint(-119.12319946,46.20377350),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Kennewick High School",'Kennewick=' + Kennewick.length);
Benton_City[Benton_City.length] = createMarker(new GPoint(-119.48918915,46.27076721),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Kiona-benton City Elementary School",'Benton_City=' + Benton_City.length);
Benton_City[Benton_City.length] = createMarker(new GPoint(-119.48918915,46.27076721),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Kiona-benton City High School",'Benton_City=' + Benton_City.length);
Benton_City[Benton_City.length] = createMarker(new GPoint(-119.48918915,46.27076721),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Kiona-benton City Middle School",'Benton_City=' + Benton_City.length);
Benton_City[Benton_City.length] = createMarker(new GPoint(-119.49013519,46.27086258),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Kiona-benton Intermediate",'Benton_City=' + Benton_City.length);
Richland[Richland.length] = createMarker(new GPoint(-119.27719879,46.26983643),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Lewis & Clark Elementary School",'Richland=' + Richland.length);
Kennewick[Kennewick.length] = createMarker(new GPoint(-119.17984009,46.18970108),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Lincoln Elementary School",'Kennewick=' + Kennewick.length);
Richland[Richland.length] = createMarker(new GPoint(-119.29437256,46.27239990),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Marcus Whitman Elementary School",'Richland=' + Richland.length);
Kennewick[Kennewick.length] = createMarker(new GPoint(-119.28507996,46.21036148),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Mid-columbia Parent Partnership Elementary School",'Kennewick=' + Kennewick.length);
Kennewick[Kennewick.length] = createMarker(new GPoint(-119.13208008,46.19836426),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Park Middle School",'Kennewick=' + Kennewick.length);
Paterson[Paterson.length] = createMarker(new GPoint(-119.62560272,45.93050003),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Paterson Elementary School",'Paterson=' + Paterson.length);
Prosser[Prosser.length] = createMarker(new GPoint(-119.77101135,46.21169281),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Prosser Falls Education Center",'Prosser=' + Prosser.length);
Prosser[Prosser.length] = createMarker(new GPoint(-119.75331116,46.21153641),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Prosser Heights Elementary School",'Prosser=' + Prosser.length);
_Prosser_Ave[_Prosser_Ave.length] = createMarker(new GPoint(-119.76708984,46.20381927),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Prosser High School",'_Prosser_Ave=' + _Prosser_Ave.length);
Richland[Richland.length] = createMarker(new GPoint(-119.28874969,46.27906418),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Richland High School",'Richland=' + Richland.length);
Kennewick[Kennewick.length] = createMarker(new GPoint(-119.21553040,46.19672775),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Ridge View Elementary School",'Kennewick=' + Kennewick.length);
Kennewick[Kennewick.length] = createMarker(new GPoint(-119.03829956,46.15545273),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("River View High School",'Kennewick=' + Kennewick.length);
Richland[Richland.length] = createMarker(new GPoint(-119.27704620,46.27272034),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Rivers Edge High School",'Richland=' + Richland.length);
Richland[Richland.length] = createMarker(new GPoint(-119.27600861,46.30653763),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Sacajawea Elementary School",'Richland=' + Richland.length);
Kennewick[Kennewick.length] = createMarker(new GPoint(-119.16271210,46.19126129),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Southgate Elementary School",'Kennewick=' + Kennewick.length);
Kennewick[Kennewick.length] = createMarker(new GPoint(-119.18037415,46.18476868),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Southridge High School",'Kennewick=' + Kennewick.length);
Richland[Richland.length] = createMarker(new GPoint(-119.27919769,46.24919891),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Special Programs",'Richland=' + Richland.length);
Kennewick[Kennewick.length] = createMarker(new GPoint(-119.23397827,46.21787262),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Sunset View Elementary School",'Kennewick=' + Kennewick.length);
West_Richland[West_Richland.length] = createMarker(new GPoint(-119.36729431,46.30717468),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Tapteal Elementary School",'West_Richland=' + West_Richland.length);
Kennewick[Kennewick.length] = createMarker(new GPoint(-119.20006561,46.21956253),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Tri City Area Vocational Skills Center",'Kennewick=' + Kennewick.length);
Richland[Richland.length] = createMarker(new GPoint(-119.27875519,46.30016327),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Twin Rivers Group Home",'Richland=' + Richland.length);
Kennewick[Kennewick.length] = createMarker(new GPoint(-119.21849823,46.22819519),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Vista Elementary School",'Kennewick=' + Kennewick.length);
Kennewick[Kennewick.length] = createMarker(new GPoint(-119.11747742,46.18906403),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Washington Elementary School",'Kennewick=' + Kennewick.length);
Kennewick[Kennewick.length] = createMarker(new GPoint(-119.15459442,46.20603561),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Westgate Elementary School",'Kennewick=' + Kennewick.length);
Prosser[Prosser.length] = createMarker(new GPoint(-120.67600250,47.12440109),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Whitstran Elementary School",'Prosser=' + Prosser.length);
West_Richland[West_Richland.length] = createMarker(new GPoint(-119.35720062,46.27513504),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Wiley Elementary School",'West_Richland=' + West_Richland.length);
} // End addStateMarkers JavaScript Function
// Takes an array of markers and centers/zooms map based on marker range
function centerByArray(myArray, recenter, newMaxMin)
{
if (newMaxMin == true)
reMaxMin(myArray);
for (var i = 0; i < myArray.length; i++)
{
var markLng = myArray[i].getPoint().x;
var markLat = myArray[i].getPoint().y;
if (markLat > maxLat) maxLat = markLat;
if (markLng > maxLng) maxLng = markLng;
if (markLat < minLat) minLat = markLat;
if (markLng < minLng) minLng = markLng;
}
if (recenter)
reCenterMap();
}
// Reinit max/mins
function reMaxMin(myArray)
{
maxLng = myArray[0].getPoint().x;
maxLat = myArray[0].getPoint().y;
minLng = myArray[0].getPoint().x;
minLat = myArray[0].getPoint().y;
}
// Recenter map based on global max/mins
function reCenterMap()
{
var bounds = new GLatLngBounds();
bounds.extend(new GLatLng(minLat, minLng));
bounds.extend(new GLatLng(maxLat, maxLng));
var center_lat = (bounds.getNorthEast().lat() + bounds.getSouthWest().lat()) / 2.0;
var center_lng = (bounds.getNorthEast().lng() + bounds.getSouthWest().lng()) / 2.0;
var center = new GLatLng(center_lat, center_lng);
var zoom = map.getBoundsZoomLevel(bounds);
map.setCenter(center,zoom);
//map.setCenter(center,10);
/*
var center = new GPoint( (maxLng + minLng)/2, (maxLat+minLat)/2 );
var delta = new GSize(maxLng - minLng, maxLat - minLat);
var minZoom = map.spec.getLowestZoomLevel(center, delta, map.viewSize);
if (minZoom < 4) minZoom = 4; // Lowest possible zoom is 4
map.centerAndZoom(center, minZoom);
*/
}
// Fires when drop down list of schools changes
function selectChange(selection)
{
var myVal = selection.options[selection.selectedIndex].value;
map.closeInfoWindow();
// Add entire array based on variable type
if (myVal.indexOf('all') != -1 && myVal != 'all')
{
var temp = myVal.split('=');
var showArray = temp[1];
// If Array is > X amount of markers, then open in a new page
if (eval(showArray).length > 20)
// New window depends on whether or not we're on the search page
if (location.href.indexOf('nearby_schools.php') == -1)
window.open(location.href + '/map/' + showArray);
else
window.open('/search////' + showArray);
map.removeOverlays(Benton_City);
map.removeOverlays(Kennewick);
map.removeOverlays(Pasco);
map.removeOverlays(Paterson);
map.removeOverlays(Prosser);
map.removeOverlays(Richland);
map.removeOverlays(West_Richland);
map.removeOverlays(_Prosser_Ave);
map.addOverlays(eval(showArray));
centerByArray(eval(showArray), true, true); // Center and zoom on set of markers
}
// Add individual markers
if (myVal.indexOf('all') == -1 && myVal != 'all' && myVal.length)
{
var temp = myVal.split('=');
var myArray = temp[0];
var myIndex = parseInt(temp[1]) - 1;
document.getElementById('map').width = "750";
map.removeOverlay(eval(myArray)[myIndex]);
map.addOverlay(eval(myArray)[myIndex]);
GEvent.trigger(eval(myArray)[myIndex],'click');
}
// Show all markers
if (myVal == 'all')
{
cntMarker = 0;
reMaxMin(Kennewick);map.removeOverlays(Benton_City);
map.removeOverlays(Kennewick);
map.removeOverlays(Pasco);
map.removeOverlays(Paterson);
map.removeOverlays(Prosser);
map.removeOverlays(Richland);
map.removeOverlays(West_Richland);
map.removeOverlays(_Prosser_Ave);
map.addOverlays(Benton_City);
centerByArray(Benton_City, false, false);
cntMarker += Benton_City.length;
map.addOverlays(Kennewick);
centerByArray(Kennewick, false, false);
cntMarker += Kennewick.length;
map.addOverlays(Pasco);
centerByArray(Pasco, false, false);
cntMarker += Pasco.length;
map.addOverlays(Paterson);
centerByArray(Paterson, false, false);
cntMarker += Paterson.length;
map.addOverlays(Prosser);
centerByArray(Prosser, false, false);
cntMarker += Prosser.length;
map.addOverlays(Richland);
centerByArray(Richland, false, false);
cntMarker += Richland.length;
map.addOverlays(West_Richland);
centerByArray(West_Richland, false, false);
cntMarker += West_Richland.length;
map.addOverlays(_Prosser_Ave);
centerByArray(_Prosser_Ave, false, false);
cntMarker += _Prosser_Ave.length;
centerByArray(Kennewick,true, false);
if (cntMarker > 20)
// New window depends on whether or not we're on the search page
if (location.href.indexOf('schools-by-distance') == -1)
window.open(location.href + '/map/all');
else
window.open('/search////all');
}
}