function addMarkers(){
mySelect = document.getElementById('selection');
Milwaukie = [];Pleasant_Hill = [];Salem = [];Baker_City = [];Klamath_Falls = [];Portland = [];Beaverton = [];North_Bend = [];Lincoln_City = [];Cottage_Grove = [];Aloha = [];Medford = [];Hillsboro = [];Mcminnville = [];mySelect.options[mySelect.options.length] = new Option("Aloha schools",'all=Aloha');
mySelect.options[mySelect.options.length] = new Option("Baker City schools",'all=Baker_City');
mySelect.options[mySelect.options.length] = new Option("Beaverton schools",'all=Beaverton');
mySelect.options[mySelect.options.length] = new Option("Cottage Grove schools",'all=Cottage_Grove');
mySelect.options[mySelect.options.length] = new Option("Hillsboro schools",'all=Hillsboro');
mySelect.options[mySelect.options.length] = new Option("Klamath Falls schools",'all=Klamath_Falls');
mySelect.options[mySelect.options.length] = new Option("Lincoln City schools",'all=Lincoln_City');
mySelect.options[mySelect.options.length] = new Option("Mcminnville schools",'all=Mcminnville');
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("North Bend schools",'all=North_Bend');
mySelect.options[mySelect.options.length] = new Option("Pleasant Hill schools",'all=Pleasant_Hill');
mySelect.options[mySelect.options.length] = new Option("Portland schools",'all=Portland');
mySelect.options[mySelect.options.length] = new Option("Salem schools",'all=Salem');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
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);
Pleasant_Hill[Pleasant_Hill.length] = createMarker(new GPoint(-122.94922800,43.97980400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Emerald Christian Academy",'Pleasant_Hill=' + Pleasant_Hill.length);
Salem[Salem.length] = createMarker(new GPoint(-123.04730000,44.90520000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("H.i.s. Academy",'Salem=' + Salem.length);
Baker_City[Baker_City.length] = createMarker(new GPoint(-117.81467600,44.79314200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Harvest Christian Academy",'Baker_City=' + Baker_City.length);
Klamath_Falls[Klamath_Falls.length] = createMarker(new GPoint(-121.75101800,42.21800000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Hilltop Christian Academy",'Klamath_Falls=' + Klamath_Falls.length);
Portland[Portland.length] = createMarker(new GPoint(-122.70752300,45.48215000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Hilltop Christian School",'Portland=' + Portland.length);
Beaverton[Beaverton.length] = createMarker(new GPoint(-122.81817200,45.50699800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Holy Trinity Parish School",'Beaverton=' + Beaverton.length);
Salem[Salem.length] = createMarker(new GPoint(-123.04454100,44.89068500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Immanuel Evangelical Lutheran School",'Salem=' + Salem.length);
North_Bend[North_Bend.length] = createMarker(new GPoint(-124.23870300,43.39403700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Kingsview Christian School",'North_Bend=' + North_Bend.length);
Milwaukie[Milwaukie.length] = createMarker(new GPoint(-122.58561800,45.43602000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("La Salle Catholic College Preparatory",'Milwaukie=' + Milwaukie.length);
Lincoln_City[Lincoln_City.length] = createMarker(new GPoint(-124.00322100,44.99624000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lincoln City Montessori",'Lincoln_City=' + Lincoln_City.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);
Portland[Portland.length] = createMarker(new GPoint(-122.71078600,45.45851200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Little Lambs Preschool/Daycare",'Portland=' + Portland.length);
Cottage_Grove[Cottage_Grove.length] = createMarker(new GPoint(-123.04360000,43.75820000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Oak Park Christian School",'Cottage_Grove=' + Cottage_Grove.length);
Aloha[Aloha.length] = createMarker(new GPoint(-122.86340000,45.51930000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Palace Of Praise Academy",'Aloha=' + Aloha.length);
Beaverton[Beaverton.length] = createMarker(new GPoint(-112.03820100,33.37795200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Pilgrim Lutheran School",'Beaverton=' + Beaverton.length);
Portland[Portland.length] = createMarker(new GPoint(-122.47558300,45.51743400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Portland Lutheran School",'Portland=' + Portland.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);
Portland[Portland.length] = createMarker(new GPoint(-122.72640200,45.47542000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. John Fisher School",'Portland=' + Portland.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);
Hillsboro[Hillsboro.length] = createMarker(new GPoint(-122.98758800,45.51767700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Matthew School",'Hillsboro=' + Hillsboro.length);
Cottage_Grove[Cottage_Grove.length] = createMarker(new GPoint(-123.05535900,43.78749000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("South Lane Christian School",'Cottage_Grove=' + Cottage_Grove.length);
Mcminnville[Mcminnville.length] = createMarker(new GPoint(-123.21480000,45.20760000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St John Lutheran School / Little Lamb Preschool",'Mcminnville=' + Mcminnville.length);
Portland[Portland.length] = createMarker(new GPoint(-122.60548300,45.56256800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Trinity Lutheran School",'Portland=' + Portland.length);
map.removeOverlays(Aloha);
map.removeOverlays(Baker_City);
map.removeOverlays(Beaverton);
map.removeOverlays(Cottage_Grove);
map.removeOverlays(Hillsboro);
map.removeOverlays(Klamath_Falls);
map.removeOverlays(Lincoln_City);
map.removeOverlays(Mcminnville);
map.removeOverlays(Medford);
map.removeOverlays(Milwaukie);
map.removeOverlays(North_Bend);
map.removeOverlays(Pleasant_Hill);
map.removeOverlays(Portland);
map.removeOverlays(Salem);
setTimeout(function(){map.addOverlays(Aloha)},1000);
setTimeout(function(){map.addOverlays(Baker_City)},1000);
setTimeout(function(){map.addOverlays(Beaverton)},1000);
setTimeout(function(){map.addOverlays(Cottage_Grove)},1000);
setTimeout(function(){map.addOverlays(Hillsboro)},1000);
setTimeout(function(){map.addOverlays(Klamath_Falls)},1000);
setTimeout(function(){map.addOverlays(Lincoln_City)},1000);
setTimeout(function(){map.addOverlays(Mcminnville)},1000);
setTimeout(function(){map.addOverlays(Medford)},1000);
setTimeout(function(){map.addOverlays(Milwaukie)},1000);
setTimeout(function(){map.addOverlays(North_Bend)},1000);
setTimeout(function(){map.addOverlays(Pleasant_Hill)},1000);
setTimeout(function(){map.addOverlays(Portland)},1000);
setTimeout(function(){map.addOverlays(Salem)},1000);
maxLng = -112.03820100;
maxLat = 45.56256800;
minLng = -124.23870300;
minLat = 33.37795200;
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(Baker_City);
map.removeOverlays(Beaverton);
map.removeOverlays(Cottage_Grove);
map.removeOverlays(Hillsboro);
map.removeOverlays(Klamath_Falls);
map.removeOverlays(Lincoln_City);
map.removeOverlays(Mcminnville);
map.removeOverlays(Medford);
map.removeOverlays(Milwaukie);
map.removeOverlays(North_Bend);
map.removeOverlays(Pleasant_Hill);
map.removeOverlays(Portland);
map.removeOverlays(Salem);
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(Milwaukie);map.removeOverlays(Aloha);
map.removeOverlays(Baker_City);
map.removeOverlays(Beaverton);
map.removeOverlays(Cottage_Grove);
map.removeOverlays(Hillsboro);
map.removeOverlays(Klamath_Falls);
map.removeOverlays(Lincoln_City);
map.removeOverlays(Mcminnville);
map.removeOverlays(Medford);
map.removeOverlays(Milwaukie);
map.removeOverlays(North_Bend);
map.removeOverlays(Pleasant_Hill);
map.removeOverlays(Portland);
map.removeOverlays(Salem);
map.addOverlays(Aloha);
centerByArray(Aloha, false, false);
cntMarker += Aloha.length;
map.addOverlays(Baker_City);
centerByArray(Baker_City, false, false);
cntMarker += Baker_City.length;
map.addOverlays(Beaverton);
centerByArray(Beaverton, false, false);
cntMarker += Beaverton.length;
map.addOverlays(Cottage_Grove);
centerByArray(Cottage_Grove, false, false);
cntMarker += Cottage_Grove.length;
map.addOverlays(Hillsboro);
centerByArray(Hillsboro, false, false);
cntMarker += Hillsboro.length;
map.addOverlays(Klamath_Falls);
centerByArray(Klamath_Falls, false, false);
cntMarker += Klamath_Falls.length;
map.addOverlays(Lincoln_City);
centerByArray(Lincoln_City, false, false);
cntMarker += Lincoln_City.length;
map.addOverlays(Mcminnville);
centerByArray(Mcminnville, false, false);
cntMarker += Mcminnville.length;
map.addOverlays(Medford);
centerByArray(Medford, false, false);
cntMarker += Medford.length;
map.addOverlays(Milwaukie);
centerByArray(Milwaukie, false, false);
cntMarker += Milwaukie.length;
map.addOverlays(North_Bend);
centerByArray(North_Bend, false, false);
cntMarker += North_Bend.length;
map.addOverlays(Pleasant_Hill);
centerByArray(Pleasant_Hill, false, false);
cntMarker += Pleasant_Hill.length;
map.addOverlays(Portland);
centerByArray(Portland, false, false);
cntMarker += Portland.length;
map.addOverlays(Salem);
centerByArray(Salem, false, false);
cntMarker += Salem.length;
centerByArray(Milwaukie,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///22628,22880,22732,22763,22759,22697,22845,22832,22628,22738,22835,22901,22820,22880,22905,22732,22981,22776,22917,22859,22661,22759,22697,22733,34442,22845,22891,22947,22727,34441,/all');
//window.open('/map.php?type=2&schools=22628,22880,22732,22763,22759,22697,22845,22832,22628,22738,22835,22901,22820,22880,22905,22732,22981,22776,22917,22859,22661,22759,22697,22733,34442,22845,22891,22947,22727,34441,&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;
}