function addMarkers(){
mySelect = document.getElementById('selection');
Toledo = [];Portland = [];Coos_Bay = [];Hood_River = [];Hillsboro = [];Milwaukie = [];Cornelius = [];Medford = [];Klamath_Falls = [];Tigard = [];Ashland = [];Aloha = [];Eugene = [];Bend = [];Oregon_City = [];Roseburg = [];Gladstone = [];Beaverton = [];Salem = [];mySelect.options[mySelect.options.length] = new Option("Aloha schools",'all=Aloha');
mySelect.options[mySelect.options.length] = new Option("Ashland schools",'all=Ashland');
mySelect.options[mySelect.options.length] = new Option("Beaverton schools",'all=Beaverton');
mySelect.options[mySelect.options.length] = new Option("Bend schools",'all=Bend');
mySelect.options[mySelect.options.length] = new Option("Coos Bay schools",'all=Coos_Bay');
mySelect.options[mySelect.options.length] = new Option("Cornelius schools",'all=Cornelius');
mySelect.options[mySelect.options.length] = new Option("Eugene schools",'all=Eugene');
mySelect.options[mySelect.options.length] = new Option("Gladstone schools",'all=Gladstone');
mySelect.options[mySelect.options.length] = new Option("Hillsboro schools",'all=Hillsboro');
mySelect.options[mySelect.options.length] = new Option("Hood River schools",'all=Hood_River');
mySelect.options[mySelect.options.length] = new Option("Klamath Falls schools",'all=Klamath_Falls');
mySelect.options[mySelect.options.length] = new Option("Medford schools",'all=Medford');
mySelect.options[mySelect.options.length] = new Option("Milwaukie schools",'all=Milwaukie');
mySelect.options[mySelect.options.length] = new Option("Oregon City schools",'all=Oregon_City');
mySelect.options[mySelect.options.length] = new Option("Portland schools",'all=Portland');
mySelect.options[mySelect.options.length] = new Option("Roseburg schools",'all=Roseburg');
mySelect.options[mySelect.options.length] = new Option("Salem schools",'all=Salem');
mySelect.options[mySelect.options.length] = new Option("Tigard schools",'all=Tigard');
mySelect.options[mySelect.options.length] = new Option("Toledo schools",'all=Toledo');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Toledo[Toledo.length] = createMarker(new GPoint(-123.93910600,44.62752300),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Abundant Life Academy",'Toledo=' + Toledo.length);
Portland[Portland.length] = createMarker(new GPoint(-122.67530300,45.54978700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Albina Youth Opportunity School",'Portland=' + Portland.length);
Coos_Bay[Coos_Bay.length] = createMarker(new GPoint(-124.27564700,43.38518400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Alternative Youth Activities, Inc",'Coos_Bay=' + Coos_Bay.length);
Hood_River[Hood_River.length] = createMarker(new GPoint(-121.51691600,45.70825500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bright Beginnings",'Hood_River=' + Hood_River.length);
Hillsboro[Hillsboro.length] = createMarker(new GPoint(-122.97785200,45.54414400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Carden Cascade Academy",'Hillsboro=' + Hillsboro.length);
Milwaukie[Milwaukie.length] = createMarker(new GPoint(-122.58783000,45.43987500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Christ The King Parish School",'Milwaukie=' + Milwaukie.length);
Cornelius[Cornelius.length] = createMarker(new GPoint(-123.05071900,45.48941000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Forest Hills Lutheran School",'Cornelius=' + Cornelius.length);
Medford[Medford.length] = createMarker(new GPoint(-122.86200200,42.33556700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Grace Christian School",'Medford=' + Medford.length);
Klamath_Falls[Klamath_Falls.length] = createMarker(new GPoint(-121.94257100,42.25640100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Integral Youth Services Step-thru School",'Klamath_Falls=' + Klamath_Falls.length);
Portland[Portland.length] = createMarker(new GPoint(-122.67680500,45.50653100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The International School",'Portland=' + Portland.length);
Tigard[Tigard.length] = createMarker(new GPoint(-122.80546000,45.44197700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Kindercare Learning Centers",'Tigard=' + Tigard.length);
Tigard[Tigard.length] = createMarker(new GPoint(-122.81075600,45.44237100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Knowledge Beginnings",'Tigard=' + Tigard.length);
Ashland[Ashland.length] = createMarker(new GPoint(-122.66912000,42.18088900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lithia Springs School",'Ashland=' + Ashland.length);
Aloha[Aloha.length] = createMarker(new GPoint(-122.86202800,45.49451200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Little Lambs Christian Montessori Center",'Aloha=' + Aloha.length);
Klamath_Falls[Klamath_Falls.length] = createMarker(new GPoint(-121.78113800,42.22856800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Little Lambs Learning Center",'Klamath_Falls=' + Klamath_Falls.length);
Eugene[Eugene.length] = createMarker(new GPoint(-123.11976600,44.04757900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Looking Glass Center Point School",'Eugene=' + Eugene.length);
Bend[Bend.length] = createMarker(new GPoint(-121.33816400,43.99327800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Morning Star Christian School",'Bend=' + Bend.length);
Bend[Bend.length] = createMarker(new GPoint(-121.29990000,44.07220000),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("New Leaf Academy",'Bend=' + Bend.length);
Oregon_City[Oregon_City.length] = createMarker(new GPoint(-122.57948500,45.32270000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("North Clackamas Christian School",'Oregon_City=' + Oregon_City.length);
Roseburg[Roseburg.length] = createMarker(new GPoint(-123.31102000,43.21286300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Phoenix School Of Roseburg",'Roseburg=' + Roseburg.length);
Portland[Portland.length] = createMarker(new GPoint(-122.70375400,45.47614300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Portland Jewish Academy",'Portland=' + Portland.length);
Portland[Portland.length] = createMarker(new GPoint(-122.56847500,45.48617100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Portland Youth Builders",'Portland=' + Portland.length);
Gladstone[Gladstone.length] = createMarker(new GPoint(-122.57792200,45.39191300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Rivergate Adventist Elementary School",'Gladstone=' + Gladstone.length);
Medford[Medford.length] = createMarker(new GPoint(-122.87325900,42.32069100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sacred Heart Catholic School",'Medford=' + Medford.length);
Beaverton[Beaverton.length] = createMarker(new GPoint(-122.82860300,45.48748200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Mary Of The Valley Elementary School",'Beaverton=' + Beaverton.length);
Salem[Salem.length] = createMarker(new GPoint(-122.98314700,44.94272600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Salem Academy Middle & High School",'Salem=' + Salem.length);
Salem[Salem.length] = createMarker(new GPoint(-123.03369100,44.94012000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Salem Family Ymca Preschool & Kindergarten",'Salem=' + Salem.length);
Portland[Portland.length] = createMarker(new GPoint(-122.63622000,45.49025700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Tucker-Maxon Oral School",'Portland=' + Portland.length);
Portland[Portland.length] = createMarker(new GPoint(-122.70007400,45.46691900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("West Hills Christian School",'Portland=' + Portland.length);
Portland[Portland.length] = createMarker(new GPoint(-122.62179500,45.47972400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Whole Child Montessori Center",'Portland=' + Portland.length);
Portland[Portland.length] = createMarker(new GPoint(-122.66560300,45.51855200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Youth Progress Association",'Portland=' + Portland.length);
map.removeOverlays(Aloha);
map.removeOverlays(Ashland);
map.removeOverlays(Beaverton);
map.removeOverlays(Bend);
map.removeOverlays(Coos_Bay);
map.removeOverlays(Cornelius);
map.removeOverlays(Eugene);
map.removeOverlays(Gladstone);
map.removeOverlays(Hillsboro);
map.removeOverlays(Hood_River);
map.removeOverlays(Klamath_Falls);
map.removeOverlays(Medford);
map.removeOverlays(Milwaukie);
map.removeOverlays(Oregon_City);
map.removeOverlays(Portland);
map.removeOverlays(Roseburg);
map.removeOverlays(Salem);
map.removeOverlays(Tigard);
map.removeOverlays(Toledo);
setTimeout(function(){map.addOverlays(Aloha)},1000);
setTimeout(function(){map.addOverlays(Ashland)},1000);
setTimeout(function(){map.addOverlays(Beaverton)},1000);
setTimeout(function(){map.addOverlays(Bend)},1000);
setTimeout(function(){map.addOverlays(Coos_Bay)},1000);
setTimeout(function(){map.addOverlays(Cornelius)},1000);
setTimeout(function(){map.addOverlays(Eugene)},1000);
setTimeout(function(){map.addOverlays(Gladstone)},1000);
setTimeout(function(){map.addOverlays(Hillsboro)},1000);
setTimeout(function(){map.addOverlays(Hood_River)},1000);
setTimeout(function(){map.addOverlays(Klamath_Falls)},1000);
setTimeout(function(){map.addOverlays(Medford)},1000);
setTimeout(function(){map.addOverlays(Milwaukie)},1000);
setTimeout(function(){map.addOverlays(Oregon_City)},1000);
setTimeout(function(){map.addOverlays(Portland)},1000);
setTimeout(function(){map.addOverlays(Roseburg)},1000);
setTimeout(function(){map.addOverlays(Salem)},1000);
setTimeout(function(){map.addOverlays(Tigard)},1000);
setTimeout(function(){map.addOverlays(Toledo)},1000);
maxLng = -121.29990000;
maxLat = 45.70825500;
minLng = -124.27564700;
minLat = 42.18088900;
reCenterMap();
} // 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,11);
/*
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(Aloha);
map.removeOverlays(Ashland);
map.removeOverlays(Beaverton);
map.removeOverlays(Bend);
map.removeOverlays(Coos_Bay);
map.removeOverlays(Cornelius);
map.removeOverlays(Eugene);
map.removeOverlays(Gladstone);
map.removeOverlays(Hillsboro);
map.removeOverlays(Hood_River);
map.removeOverlays(Klamath_Falls);
map.removeOverlays(Medford);
map.removeOverlays(Milwaukie);
map.removeOverlays(Oregon_City);
map.removeOverlays(Portland);
map.removeOverlays(Roseburg);
map.removeOverlays(Salem);
map.removeOverlays(Tigard);
map.removeOverlays(Toledo);
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(Toledo);map.removeOverlays(Aloha);
map.removeOverlays(Ashland);
map.removeOverlays(Beaverton);
map.removeOverlays(Bend);
map.removeOverlays(Coos_Bay);
map.removeOverlays(Cornelius);
map.removeOverlays(Eugene);
map.removeOverlays(Gladstone);
map.removeOverlays(Hillsboro);
map.removeOverlays(Hood_River);
map.removeOverlays(Klamath_Falls);
map.removeOverlays(Medford);
map.removeOverlays(Milwaukie);
map.removeOverlays(Oregon_City);
map.removeOverlays(Portland);
map.removeOverlays(Roseburg);
map.removeOverlays(Salem);
map.removeOverlays(Tigard);
map.removeOverlays(Toledo);
map.addOverlays(Aloha);
centerByArray(Aloha, false, false);
cntMarker += Aloha.length;
map.addOverlays(Ashland);
centerByArray(Ashland, false, false);
cntMarker += Ashland.length;
map.addOverlays(Beaverton);
centerByArray(Beaverton, false, false);
cntMarker += Beaverton.length;
map.addOverlays(Bend);
centerByArray(Bend, false, false);
cntMarker += Bend.length;
map.addOverlays(Coos_Bay);
centerByArray(Coos_Bay, false, false);
cntMarker += Coos_Bay.length;
map.addOverlays(Cornelius);
centerByArray(Cornelius, false, false);
cntMarker += Cornelius.length;
map.addOverlays(Eugene);
centerByArray(Eugene, false, false);
cntMarker += Eugene.length;
map.addOverlays(Gladstone);
centerByArray(Gladstone, false, false);
cntMarker += Gladstone.length;
map.addOverlays(Hillsboro);
centerByArray(Hillsboro, false, false);
cntMarker += Hillsboro.length;
map.addOverlays(Hood_River);
centerByArray(Hood_River, false, false);
cntMarker += Hood_River.length;
map.addOverlays(Klamath_Falls);
centerByArray(Klamath_Falls, false, false);
cntMarker += Klamath_Falls.length;
map.addOverlays(Medford);
centerByArray(Medford, false, false);
cntMarker += Medford.length;
map.addOverlays(Milwaukie);
centerByArray(Milwaukie, false, false);
cntMarker += Milwaukie.length;
map.addOverlays(Oregon_City);
centerByArray(Oregon_City, false, false);
cntMarker += Oregon_City.length;
map.addOverlays(Portland);
centerByArray(Portland, false, false);
cntMarker += Portland.length;
map.addOverlays(Roseburg);
centerByArray(Roseburg, false, false);
cntMarker += Roseburg.length;
map.addOverlays(Salem);
centerByArray(Salem, false, false);
cntMarker += Salem.length;
map.addOverlays(Tigard);
centerByArray(Tigard, false, false);
cntMarker += Tigard.length;
map.addOverlays(Toledo);
centerByArray(Toledo, false, false);
cntMarker += Toledo.length;
centerByArray(Toledo,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///36058,22799,22810,36055,36059,36057,22812,22618,36060,22979,22834,22862,22614,36052,22901,22799,22810,22710,36059,22853,32782,36056,36057,22981,22722,22859,22661,22812,22933,22844,22950,22960,22969,22865,31704,36053,22614,/all');
//window.open('/map.php?type=2&schools=36058,22799,22810,36055,36059,36057,22812,22618,36060,22979,22834,22862,22614,36052,22901,22799,22810,22710,36059,22853,32782,36056,36057,22981,22722,22859,22661,22812,22933,22844,22950,22960,22969,22865,31704,36053,22614,&school_level=&radius=&zipcode=&school_type_search=&school_type_code=');
}
}
function createMarker(point, label, icon)
{
var marker = new GMarker(point, icon);
var html = label;
GEvent.addListener(marker, "click", function() {
marker.openInfoWindowHtml(html);
});
return marker;
}