function addMarkers()
{
mySelect = document.getElementById('selection');
Tangent = [];Albany = [];Lebanon = [];Scio = [];Brownsville = [];Halsey = [];Crawfordsville = [];Detroit = [];Foster = [];Gates = [];Harrisburg = [];Sweet_Home = [];Lyons = [];Mill_City = [];mySelect.options[mySelect.options.length] = new Option("Albany schools",'all=Albany');
mySelect.options[mySelect.options.length] = new Option("Brownsville schools",'all=Brownsville');
mySelect.options[mySelect.options.length] = new Option("Crawfordsville schools",'all=Crawfordsville');
mySelect.options[mySelect.options.length] = new Option("Detroit schools",'all=Detroit');
mySelect.options[mySelect.options.length] = new Option("Foster schools",'all=Foster');
mySelect.options[mySelect.options.length] = new Option("Gates schools",'all=Gates');
mySelect.options[mySelect.options.length] = new Option("Halsey schools",'all=Halsey');
mySelect.options[mySelect.options.length] = new Option("Harrisburg schools",'all=Harrisburg');
mySelect.options[mySelect.options.length] = new Option("Lebanon schools",'all=Lebanon');
mySelect.options[mySelect.options.length] = new Option("Lyons schools",'all=Lyons');
mySelect.options[mySelect.options.length] = new Option("Mill City schools",'all=Mill_City');
mySelect.options[mySelect.options.length] = new Option("Scio schools",'all=Scio');
mySelect.options[mySelect.options.length] = new Option("Sweet Home schools",'all=Sweet_Home');
mySelect.options[mySelect.options.length] = new Option("Tangent schools",'all=Tangent');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Tangent[Tangent.length] = createMarker(new GPoint(-123.11039734,44.64360046),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Albany Options School",'Tangent=' + Tangent.length);
Albany[Albany.length] = createMarker(new GPoint(-123.09245300,44.61846161),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Calapooia Middle School",'Albany=' + Albany.length);
Lebanon[Lebanon.length] = createMarker(new GPoint(-122.91587067,44.52497864),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Cascades School",'Lebanon=' + Lebanon.length);
Scio[Scio.length] = createMarker(new GPoint(-122.85368347,44.70483780),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Centennial Elementary School",'Scio=' + Scio.length);
Albany[Albany.length] = createMarker(new GPoint(-123.10654449,44.63068390),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Central Elementary School",'Albany=' + Albany.length);
Brownsville[Brownsville.length] = createMarker(new GPoint(-122.98173523,44.38553619),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Central Linn Alternative Education High School",'Brownsville=' + Brownsville.length);
Halsey[Halsey.length] = createMarker(new GPoint(-123.10999298,44.38734055),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Central Linn Elementary School",'Halsey=' + Halsey.length);
Halsey[Halsey.length] = createMarker(new GPoint(-123.08599854,44.38904190),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Central Linn High School",'Halsey=' + Halsey.length);
Albany[Albany.length] = createMarker(new GPoint(-123.10353088,44.63681030),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Clover Ridge Elementary School",'Albany=' + Albany.length);
Crawfordsville[Crawfordsville.length] = createMarker(new GPoint(-122.85540009,44.35720062),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Crawfordsville Elementary School",'Crawfordsville=' + Crawfordsville.length);
Detroit[Detroit.length] = createMarker(new GPoint(-122.18029785,44.78390121),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Detroit Lakes Charter School",'Detroit=' + Detroit.length);
Foster[Foster.length] = createMarker(new GPoint(-122.59069824,44.40340042),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Foster Elementary School",'Foster=' + Foster.length);
Gates[Gates.length] = createMarker(new GPoint(-122.48400116,44.61840057),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Gates Elementary School",'Gates=' + Gates.length);
Lebanon[Lebanon.length] = createMarker(new GPoint(-122.91363525,44.56096268),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Gore Elementary School",'Lebanon=' + Lebanon.length);
Lebanon[Lebanon.length] = createMarker(new GPoint(-122.92097473,44.53895187),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Green Acres School",'Lebanon=' + Lebanon.length);
Lebanon[Lebanon.length] = createMarker(new GPoint(-122.83541107,44.51261139),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Hamilton Creek School",'Lebanon=' + Lebanon.length);
Harrisburg[Harrisburg.length] = createMarker(new GPoint(-123.11789703,44.27009964),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Harrisburg Elementary School",'Harrisburg=' + Harrisburg.length);
Harrisburg[Harrisburg.length] = createMarker(new GPoint(-123.11789703,44.27009964),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Harrisburg High School",'Harrisburg=' + Harrisburg.length);
Harrisburg[Harrisburg.length] = createMarker(new GPoint(-123.11789703,44.27009964),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Harrisburg Middle School",'Harrisburg=' + Harrisburg.length);
Sweet_Home[Sweet_Home.length] = createMarker(new GPoint(-122.70706940,44.39866257),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Hawthorne Elementary School",'Sweet_Home=' + Sweet_Home.length);
Sweet_Home[Sweet_Home.length] = createMarker(new GPoint(-122.78484344,44.35946274),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Holley Elementary School",'Sweet_Home=' + Sweet_Home.length);
Lebanon[Lebanon.length] = createMarker(new GPoint(-122.73709106,44.58546448),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Lacomb School",'Lebanon=' + Lebanon.length);
Albany[Albany.length] = createMarker(new GPoint(-123.09139252,44.61227036),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Lafayette Elementary School",'Albany=' + Albany.length);
Lebanon[Lebanon.length] = createMarker(new GPoint(-122.91309357,44.52996826),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lebanon High School",'Lebanon=' + Lebanon.length);
Albany[Albany.length] = createMarker(new GPoint(-123.11893463,44.62023926),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Liberty Elementary School",'Albany=' + Albany.length);
Scio[Scio.length] = createMarker(new GPoint(-122.69235229,44.71764755),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Lourdes School",'Scio=' + Scio.length);
Lyons[Lyons.length] = createMarker(new GPoint(-122.61649323,44.77981186),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Mari-linn Elementary School",'Lyons=' + Lyons.length);
Albany[Albany.length] = createMarker(new GPoint(-123.11530304,44.62351227),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Memorial Middle School",'Albany=' + Albany.length);
Mill_City[Mill_City.length] = createMarker(new GPoint(-122.47669983,44.76169968),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Mill City Middle School",'Mill_City=' + Mill_City.length);
Albany[Albany.length] = createMarker(new GPoint(-123.09291840,44.59973526),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Oak Creek School",'Albany=' + Albany.length);
Albany[Albany.length] = createMarker(new GPoint(-123.08547974,44.60912323),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Oak Elementary School",'Albany=' + Albany.length);
Sweet_Home[Sweet_Home.length] = createMarker(new GPoint(-122.73705292,44.39166260),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Oak Heights Elementary School",'Sweet_Home=' + Sweet_Home.length);
Albany[Albany.length] = createMarker(new GPoint(-123.07864380,44.62146378),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Periwinkle Elementary School",'Albany=' + Albany.length);
Lebanon[Lebanon.length] = createMarker(new GPoint(-122.91280365,44.54795837),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Pioneer School",'Lebanon=' + Lebanon.length);
Sweet_Home[Sweet_Home.length] = createMarker(new GPoint(-122.73908997,44.41346359),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Pleasant Valley Kg Elementary School",'Sweet_Home=' + Sweet_Home.length);
Lebanon[Lebanon.length] = createMarker(new GPoint(-122.90498352,44.53416443),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Queen Anne Elementary School",'Lebanon=' + Lebanon.length);
Lebanon[Lebanon.length] = createMarker(new GPoint(-122.89298248,44.52573776),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Riverview School",'Lebanon=' + Lebanon.length);
Lebanon[Lebanon.length] = createMarker(new GPoint(-122.99741364,44.50472260),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sand Ridge Charter School",'Lebanon=' + Lebanon.length);
Mill_City[Mill_City.length] = createMarker(new GPoint(-122.47669983,44.76169968),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Santiam High School",'Mill_City=' + Mill_City.length);
Scio[Scio.length] = createMarker(new GPoint(-122.85368347,44.70483780),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Scio High School",'Scio=' + Scio.length);
Scio[Scio.length] = createMarker(new GPoint(-122.85368347,44.70483780),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Scio Middle School",'Scio=' + Scio.length);
Lebanon[Lebanon.length] = createMarker(new GPoint(-122.89213562,44.51057816),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Seven Oak Middle School",'Lebanon=' + Lebanon.length);
Albany[Albany.length] = createMarker(new GPoint(-123.07940674,44.60763168),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("South Albany High School",'Albany=' + Albany.length);
Albany[Albany.length] = createMarker(new GPoint(-123.06937408,44.63376236),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("South Shore Elementary School",'Albany=' + Albany.length);
Albany[Albany.length] = createMarker(new GPoint(-123.09414673,44.62306213),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Sunrise Elementary School",'Albany=' + Albany.length);
Sweet_Home[Sweet_Home.length] = createMarker(new GPoint(-122.72506714,44.39763260),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sweet Home High School",'Sweet_Home=' + Sweet_Home.length);
Sweet_Home[Sweet_Home.length] = createMarker(new GPoint(-122.71899414,44.39475250),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Sweet Home Junior High School",'Sweet_Home=' + Sweet_Home.length);
Albany[Albany.length] = createMarker(new GPoint(-123.11788940,44.62707138),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Takena Elementary School",'Albany=' + Albany.length);
Tangent[Tangent.length] = createMarker(new GPoint(-123.09474182,44.53448105),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Tangent Elementary School",'Tangent=' + Tangent.length);
Lebanon[Lebanon.length] = createMarker(new GPoint(-122.82527924,44.49229813),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Waterloo Elementary School",'Lebanon=' + Lebanon.length);
Albany[Albany.length] = createMarker(new GPoint(-123.07820892,44.63753128),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Waverly Elementary School",'Albany=' + Albany.length);
Albany[Albany.length] = createMarker(new GPoint(-123.11701202,44.62346268),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("West Albany High School",'Albany=' + Albany.length);
Harrisburg[Harrisburg.length] = createMarker(new GPoint(-123.12723541,44.21538162),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Wyatt Elementary School",'Harrisburg=' + Harrisburg.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(Albany);
map.removeOverlays(Brownsville);
map.removeOverlays(Crawfordsville);
map.removeOverlays(Detroit);
map.removeOverlays(Foster);
map.removeOverlays(Gates);
map.removeOverlays(Halsey);
map.removeOverlays(Harrisburg);
map.removeOverlays(Lebanon);
map.removeOverlays(Lyons);
map.removeOverlays(Mill_City);
map.removeOverlays(Scio);
map.removeOverlays(Sweet_Home);
map.removeOverlays(Tangent);
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(Tangent);map.removeOverlays(Albany);
map.removeOverlays(Brownsville);
map.removeOverlays(Crawfordsville);
map.removeOverlays(Detroit);
map.removeOverlays(Foster);
map.removeOverlays(Gates);
map.removeOverlays(Halsey);
map.removeOverlays(Harrisburg);
map.removeOverlays(Lebanon);
map.removeOverlays(Lyons);
map.removeOverlays(Mill_City);
map.removeOverlays(Scio);
map.removeOverlays(Sweet_Home);
map.removeOverlays(Tangent);
map.addOverlays(Albany);
centerByArray(Albany, false, false);
cntMarker += Albany.length;
map.addOverlays(Brownsville);
centerByArray(Brownsville, false, false);
cntMarker += Brownsville.length;
map.addOverlays(Crawfordsville);
centerByArray(Crawfordsville, false, false);
cntMarker += Crawfordsville.length;
map.addOverlays(Detroit);
centerByArray(Detroit, false, false);
cntMarker += Detroit.length;
map.addOverlays(Foster);
centerByArray(Foster, false, false);
cntMarker += Foster.length;
map.addOverlays(Gates);
centerByArray(Gates, false, false);
cntMarker += Gates.length;
map.addOverlays(Halsey);
centerByArray(Halsey, false, false);
cntMarker += Halsey.length;
map.addOverlays(Harrisburg);
centerByArray(Harrisburg, false, false);
cntMarker += Harrisburg.length;
map.addOverlays(Lebanon);
centerByArray(Lebanon, false, false);
cntMarker += Lebanon.length;
map.addOverlays(Lyons);
centerByArray(Lyons, false, false);
cntMarker += Lyons.length;
map.addOverlays(Mill_City);
centerByArray(Mill_City, false, false);
cntMarker += Mill_City.length;
map.addOverlays(Scio);
centerByArray(Scio, false, false);
cntMarker += Scio.length;
map.addOverlays(Sweet_Home);
centerByArray(Sweet_Home, false, false);
cntMarker += Sweet_Home.length;
map.addOverlays(Tangent);
centerByArray(Tangent, false, false);
cntMarker += Tangent.length;
centerByArray(Tangent,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');
}
}