function addMarkers(){
mySelect = document.getElementById('selection');
Eugene = [];Junction_City = [];Creswell = [];Pleasant_Hill = [];Cottage_Grove = [];Jasper = [];Vida = [];Springfield = [];mySelect.options[mySelect.options.length] = new Option("Cottage Grove schools",'all=Cottage_Grove');
mySelect.options[mySelect.options.length] = new Option("Creswell schools",'all=Creswell');
mySelect.options[mySelect.options.length] = new Option("Eugene schools",'all=Eugene');
mySelect.options[mySelect.options.length] = new Option("Jasper schools",'all=Jasper');
mySelect.options[mySelect.options.length] = new Option("Junction City schools",'all=Junction_City');
mySelect.options[mySelect.options.length] = new Option("Pleasant Hill schools",'all=Pleasant_Hill');
mySelect.options[mySelect.options.length] = new Option("Springfield schools",'all=Springfield');
mySelect.options[mySelect.options.length] = new Option("Vida schools",'all=Vida');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Eugene[Eugene.length] = createMarker(new GPoint(-123.10364600,44.04864900),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Children's Choice Main St. Montessori",'Eugene=' + Eugene.length);
Junction_City[Junction_City.length] = createMarker(new GPoint(-123.20617800,44.22013700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Christ's Center School",'Junction_City=' + Junction_City.length);
Eugene[Eugene.length] = createMarker(new GPoint(-123.08832500,44.01708300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("College Hill Montessori",'Eugene=' + Eugene.length);
Creswell[Creswell.length] = createMarker(new GPoint(-123.02380000,43.90750000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Creswell Christian School",'Creswell=' + Creswell.length);
Eugene[Eugene.length] = createMarker(new GPoint(-123.08791600,43.99630900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Educational Environments Inc",'Eugene=' + Eugene.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);
Eugene[Eugene.length] = createMarker(new GPoint(-123.07585900,44.00632500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Eugene Christian School",'Eugene=' + Eugene.length);
Eugene[Eugene.length] = createMarker(new GPoint(-123.11390100,44.02515800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Eugene Waldorf School",'Eugene=' + Eugene.length);
Eugene[Eugene.length] = createMarker(new GPoint(-123.08633700,44.05523300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Eweb Cdc",'Eugene=' + Eugene.length);
Cottage_Grove[Cottage_Grove.length] = createMarker(new GPoint(-122.98348900,43.73649300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Faith Christian School",'Cottage_Grove=' + Cottage_Grove.length);
Eugene[Eugene.length] = createMarker(new GPoint(-123.08179900,44.03228000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Far Horizons Montessori School",'Eugene=' + Eugene.length);
Eugene[Eugene.length] = createMarker(new GPoint(-123.06987800,44.07086800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("International English Christian School",'Eugene=' + Eugene.length);
Jasper[Jasper.length] = createMarker(new GPoint(-122.86169800,43.97301500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Jasper Mountain School.",'Jasper=' + Jasper.length);
Eugene[Eugene.length] = createMarker(new GPoint(-123.08130800,44.02207500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Kiddie Kollege",'Eugene=' + Eugene.length);
Eugene[Eugene.length] = createMarker(new GPoint(-123.07462300,44.06684400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Kinder Care Learn Center #1036",'Eugene=' + Eugene.length);
Eugene[Eugene.length] = createMarker(new GPoint(-123.11829000,44.04426900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Kindercare Learning Ctrs",'Eugene=' + Eugene.length);
Eugene[Eugene.length] = createMarker(new GPoint(-123.08185800,44.04096300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Life Lutheran School",'Eugene=' + Eugene.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);
Vida[Vida.length] = createMarker(new GPoint(-122.59253000,44.14474100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mckenzie River Christian School",'Vida=' + Vida.length);
Eugene[Eugene.length] = createMarker(new GPoint(-123.10296500,44.04046700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("O Hara Catholic School",'Eugene=' + Eugene.length);
Eugene[Eugene.length] = createMarker(new GPoint(-123.02830400,44.01250500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Oak Hill School",'Eugene=' + Eugene.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);
Eugene[Eugene.length] = createMarker(new GPoint(-123.05890800,44.07553700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Paul Parish School",'Eugene=' + Eugene.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);
Springfield[Springfield.length] = createMarker(new GPoint(-122.99673400,44.06600100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Springfield Christian Kindergarten & Preschool",'Springfield=' + Springfield.length);
Eugene[Eugene.length] = createMarker(new GPoint(-123.05209000,44.06881000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Unity School, Inc.",'Eugene=' + Eugene.length);
Eugene[Eugene.length] = createMarker(new GPoint(-123.08220000,44.06480000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Willakinzie Christ Learn Center",'Eugene=' + Eugene.length);
Eugene[Eugene.length] = createMarker(new GPoint(-123.13160800,44.04036300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Willamette Christian School",'Eugene=' + Eugene.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,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/////1/' + showArray);
map.removeOverlays(Cottage_Grove);
map.removeOverlays(Creswell);
map.removeOverlays(Eugene);
map.removeOverlays(Jasper);
map.removeOverlays(Junction_City);
map.removeOverlays(Pleasant_Hill);
map.removeOverlays(Springfield);
map.removeOverlays(Vida);
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(Eugene);map.removeOverlays(Cottage_Grove);
map.removeOverlays(Creswell);
map.removeOverlays(Eugene);
map.removeOverlays(Jasper);
map.removeOverlays(Junction_City);
map.removeOverlays(Pleasant_Hill);
map.removeOverlays(Springfield);
map.removeOverlays(Vida);
map.addOverlays(Cottage_Grove);
centerByArray(Cottage_Grove, false, false);
cntMarker += Cottage_Grove.length;
map.addOverlays(Creswell);
centerByArray(Creswell, false, false);
cntMarker += Creswell.length;
map.addOverlays(Eugene);
centerByArray(Eugene, false, false);
cntMarker += Eugene.length;
map.addOverlays(Jasper);
centerByArray(Jasper, false, false);
cntMarker += Jasper.length;
map.addOverlays(Junction_City);
centerByArray(Junction_City, false, false);
cntMarker += Junction_City.length;
map.addOverlays(Pleasant_Hill);
centerByArray(Pleasant_Hill, false, false);
cntMarker += Pleasant_Hill.length;
map.addOverlays(Springfield);
centerByArray(Springfield, false, false);
cntMarker += Springfield.length;
map.addOverlays(Vida);
centerByArray(Vida, false, false);
cntMarker += Vida.length;
centerByArray(Eugene,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');
//window.open('/map.php?type=1&schools=&school_level=1&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;
}