function addMarkers(){
mySelect = document.getElementById('selection');
Albany = [];Mcminnville = [];Burns = [];Jacksonville = [];Bend = [];Portland = [];Medford = [];La_Grande = [];Troutdale = [];Lake_Oswego = [];Salem = [];Ontario = [];Klamath_Falls = [];Tigard = [];mySelect.options[mySelect.options.length] = new Option("Albany schools",'all=Albany');
mySelect.options[mySelect.options.length] = new Option("Bend schools",'all=Bend');
mySelect.options[mySelect.options.length] = new Option("Burns schools",'all=Burns');
mySelect.options[mySelect.options.length] = new Option("Jacksonville schools",'all=Jacksonville');
mySelect.options[mySelect.options.length] = new Option("Klamath Falls schools",'all=Klamath_Falls');
mySelect.options[mySelect.options.length] = new Option("La Grande schools",'all=La_Grande');
mySelect.options[mySelect.options.length] = new Option("Lake Oswego schools",'all=Lake_Oswego');
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("Ontario schools",'all=Ontario');
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("Tigard schools",'all=Tigard');
mySelect.options[mySelect.options.length] = new Option("Troutdale schools",'all=Troutdale');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Albany[Albany.length] = createMarker(new GPoint(-123.10032000,44.63619300),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Albany Christian School",'Albany=' + Albany.length);
Mcminnville[Mcminnville.length] = createMarker(new GPoint(-123.20131100,45.22536000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bethel Christian School",'Mcminnville=' + Mcminnville.length);
Burns[Burns.length] = createMarker(new GPoint(-118.89206900,43.61390000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bible Baptist Christian Academy",'Burns=' + Burns.length);
Jacksonville[Jacksonville.length] = createMarker(new GPoint(-122.96353900,42.31541400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cascade Christian High School",'Jacksonville=' + Jacksonville.length);
Bend[Bend.length] = createMarker(new GPoint(-121.25387400,44.06662000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Eastmont Community School",'Bend=' + Bend.length);
Portland[Portland.length] = createMarker(new GPoint(-122.53570000,45.55190000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Gateway Christian School",'Portland=' + Portland.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);
Portland[Portland.length] = createMarker(new GPoint(-122.48018100,45.51346800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Greater Portland Christian Academy",'Portland=' + Portland.length);
La_Grande[La_Grande.length] = createMarker(new GPoint(-118.09531200,45.32646300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Heidi Ho Kindergarten & Preschool",'La_Grande=' + La_Grande.length);
Troutdale[Troutdale.length] = createMarker(new GPoint(-122.37637100,45.50642600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Open Door Christian Academy",'Troutdale=' + Troutdale.length);
Lake_Oswego[Lake_Oswego.length] = createMarker(new GPoint(-122.70635000,45.42887800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sonshine Express Preschool",'Lake_Oswego=' + Lake_Oswego.length);
Salem[Salem.length] = createMarker(new GPoint(-123.03677100,44.94458600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sonshine School",'Salem=' + Salem.length);
Ontario[Ontario.length] = createMarker(new GPoint(-116.98530800,44.03188000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Treasure Valley Christian School",'Ontario=' + Ontario.length);
Klamath_Falls[Klamath_Falls.length] = createMarker(new GPoint(-121.72841800,42.20663700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Triad School",'Klamath_Falls=' + Klamath_Falls.length);
Tigard[Tigard.length] = createMarker(new GPoint(-122.80976600,45.44291400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Westgate Christian School",'Tigard=' + Tigard.length);
map.removeOverlays(Albany);
map.removeOverlays(Bend);
map.removeOverlays(Burns);
map.removeOverlays(Jacksonville);
map.removeOverlays(Klamath_Falls);
map.removeOverlays(La_Grande);
map.removeOverlays(Lake_Oswego);
map.removeOverlays(Mcminnville);
map.removeOverlays(Medford);
map.removeOverlays(Ontario);
map.removeOverlays(Portland);
map.removeOverlays(Salem);
map.removeOverlays(Tigard);
map.removeOverlays(Troutdale);
setTimeout(function(){map.addOverlays(Albany)},1000);
setTimeout(function(){map.addOverlays(Bend)},1000);
setTimeout(function(){map.addOverlays(Burns)},1000);
setTimeout(function(){map.addOverlays(Jacksonville)},1000);
setTimeout(function(){map.addOverlays(Klamath_Falls)},1000);
setTimeout(function(){map.addOverlays(La_Grande)},1000);
setTimeout(function(){map.addOverlays(Lake_Oswego)},1000);
setTimeout(function(){map.addOverlays(Mcminnville)},1000);
setTimeout(function(){map.addOverlays(Medford)},1000);
setTimeout(function(){map.addOverlays(Ontario)},1000);
setTimeout(function(){map.addOverlays(Portland)},1000);
setTimeout(function(){map.addOverlays(Salem)},1000);
setTimeout(function(){map.addOverlays(Tigard)},1000);
setTimeout(function(){map.addOverlays(Troutdale)},1000);
maxLng = -116.98530800;
maxLat = 45.55190000;
minLng = -123.20131100;
minLat = 42.20663700;
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(Albany);
map.removeOverlays(Bend);
map.removeOverlays(Burns);
map.removeOverlays(Jacksonville);
map.removeOverlays(Klamath_Falls);
map.removeOverlays(La_Grande);
map.removeOverlays(Lake_Oswego);
map.removeOverlays(Mcminnville);
map.removeOverlays(Medford);
map.removeOverlays(Ontario);
map.removeOverlays(Portland);
map.removeOverlays(Salem);
map.removeOverlays(Tigard);
map.removeOverlays(Troutdale);
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(Albany);map.removeOverlays(Albany);
map.removeOverlays(Bend);
map.removeOverlays(Burns);
map.removeOverlays(Jacksonville);
map.removeOverlays(Klamath_Falls);
map.removeOverlays(La_Grande);
map.removeOverlays(Lake_Oswego);
map.removeOverlays(Mcminnville);
map.removeOverlays(Medford);
map.removeOverlays(Ontario);
map.removeOverlays(Portland);
map.removeOverlays(Salem);
map.removeOverlays(Tigard);
map.removeOverlays(Troutdale);
map.addOverlays(Albany);
centerByArray(Albany, false, false);
cntMarker += Albany.length;
map.addOverlays(Bend);
centerByArray(Bend, false, false);
cntMarker += Bend.length;
map.addOverlays(Burns);
centerByArray(Burns, false, false);
cntMarker += Burns.length;
map.addOverlays(Jacksonville);
centerByArray(Jacksonville, false, false);
cntMarker += Jacksonville.length;
map.addOverlays(Klamath_Falls);
centerByArray(Klamath_Falls, false, false);
cntMarker += Klamath_Falls.length;
map.addOverlays(La_Grande);
centerByArray(La_Grande, false, false);
cntMarker += La_Grande.length;
map.addOverlays(Lake_Oswego);
centerByArray(Lake_Oswego, false, false);
cntMarker += Lake_Oswego.length;
map.addOverlays(Mcminnville);
centerByArray(Mcminnville, false, false);
cntMarker += Mcminnville.length;
map.addOverlays(Medford);
centerByArray(Medford, false, false);
cntMarker += Medford.length;
map.addOverlays(Ontario);
centerByArray(Ontario, false, false);
cntMarker += Ontario.length;
map.addOverlays(Portland);
centerByArray(Portland, false, false);
cntMarker += Portland.length;
map.addOverlays(Salem);
centerByArray(Salem, false, false);
cntMarker += Salem.length;
map.addOverlays(Tigard);
centerByArray(Tigard, false, false);
cntMarker += Tigard.length;
map.addOverlays(Troutdale);
centerByArray(Troutdale, false, false);
cntMarker += Troutdale.length;
centerByArray(Albany,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///33662,22650,22938,30452,22967,22823,22617,32784,33662,22938,22764,22878,22637,22722,22945,22715,30452,22879,22967,22823,/all');
//window.open('/map.php?type=2&schools=33662,22650,22938,30452,22967,22823,22617,32784,33662,22938,22764,22878,22637,22722,22945,22715,30452,22879,22967,22823,&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;
}