function addMarkers(){
mySelect = document.getElementById('selection');
Portland = [];Troutdale = [];Creswell = [];Sheridan = [];Pleasant_Hill = [];Eugene = [];Hood_River = [];Milwaukie = [];Prineville = [];Molalla = [];Wilsonville = [];Damascus = [];Gresham = [];Lake_Oswego = [];Forest_Grove = [];mySelect.options[mySelect.options.length] = new Option("Creswell schools",'all=Creswell');
mySelect.options[mySelect.options.length] = new Option("Damascus schools",'all=Damascus');
mySelect.options[mySelect.options.length] = new Option("Eugene schools",'all=Eugene');
mySelect.options[mySelect.options.length] = new Option("Forest Grove schools",'all=Forest_Grove');
mySelect.options[mySelect.options.length] = new Option("Gresham schools",'all=Gresham');
mySelect.options[mySelect.options.length] = new Option("Hood River schools",'all=Hood_River');
mySelect.options[mySelect.options.length] = new Option("Lake Oswego schools",'all=Lake_Oswego');
mySelect.options[mySelect.options.length] = new Option("Milwaukie schools",'all=Milwaukie');
mySelect.options[mySelect.options.length] = new Option("Molalla schools",'all=Molalla');
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("Prineville schools",'all=Prineville');
mySelect.options[mySelect.options.length] = new Option("Sheridan schools",'all=Sheridan');
mySelect.options[mySelect.options.length] = new Option("Troutdale schools",'all=Troutdale');
mySelect.options[mySelect.options.length] = new Option("Wilsonville schools",'all=Wilsonville');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Portland[Portland.length] = createMarker(new GPoint(-122.67963500,45.50140700),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cedarwood School",'Portland=' + Portland.length);
Portland[Portland.length] = createMarker(new GPoint(-122.70733300,45.53664000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Class Academy",'Portland=' + Portland.length);
Troutdale[Troutdale.length] = createMarker(new GPoint(-122.41059300,45.53799900),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Counterpoint Day Treatment",'Troutdale=' + Troutdale.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);
Sheridan[Sheridan.length] = createMarker(new GPoint(-123.42946700,45.10804300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Delphian School",'Sheridan=' + Sheridan.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);
Portland[Portland.length] = createMarker(new GPoint(-122.51123800,45.50228900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Franciscan Montessori Earth School",'Portland=' + Portland.length);
Portland[Portland.length] = createMarker(new GPoint(-122.76422900,45.52863100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("French American International School",'Portland=' + Portland.length);
Hood_River[Hood_River.length] = createMarker(new GPoint(-121.51844900,45.69660000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Horizon Christian School",'Hood_River=' + Hood_River.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);
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);
Prineville[Prineville.length] = createMarker(new GPoint(-120.40903300,44.47680800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mount Bachelor Academy",'Prineville=' + Prineville.length);
Portland[Portland.length] = createMarker(new GPoint(-122.73108300,45.48847500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Odyssey Montessori School",'Portland=' + Portland.length);
Molalla[Molalla.length] = createMarker(new GPoint(-122.56841400,45.15227000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Oregon Outreach - Molalla Pride",'Molalla=' + Molalla.length);
Portland[Portland.length] = createMarker(new GPoint(-122.66138000,45.55043700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Oregon Outreach Inc - Mccoy Academy Ne",'Portland=' + Portland.length);
Wilsonville[Wilsonville.length] = createMarker(new GPoint(-122.76849900,45.30688000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Pacific Northwest Academy",'Wilsonville=' + Wilsonville.length);
Damascus[Damascus.length] = createMarker(new GPoint(-122.42297300,45.44707600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Pleasant Valley Montessori School",'Damascus=' + Damascus.length);
Gresham[Gresham.length] = createMarker(new GPoint(-122.47247800,45.49738600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Portland Adventist Elementary School",'Gresham=' + Gresham.length);
Portland[Portland.length] = createMarker(new GPoint(-122.67667200,45.47852800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Portland French School/ Ecole francaise de Portland",'Portland=' + Portland.length);
Lake_Oswego[Lake_Oswego.length] = createMarker(new GPoint(-122.71478900,45.42701000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Touchstone School",'Lake_Oswego=' + Lake_Oswego.length);
Forest_Grove[Forest_Grove.length] = createMarker(new GPoint(-123.08496500,45.55050700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Visitation Catholic School",'Forest_Grove=' + Forest_Grove.length);
Portland[Portland.length] = createMarker(new GPoint(-122.72753900,45.47616300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("West Hills Montessori School I",'Portland=' + Portland.length);
map.removeOverlays(Creswell);
map.removeOverlays(Damascus);
map.removeOverlays(Eugene);
map.removeOverlays(Forest_Grove);
map.removeOverlays(Gresham);
map.removeOverlays(Hood_River);
map.removeOverlays(Lake_Oswego);
map.removeOverlays(Milwaukie);
map.removeOverlays(Molalla);
map.removeOverlays(Pleasant_Hill);
map.removeOverlays(Portland);
map.removeOverlays(Prineville);
map.removeOverlays(Sheridan);
map.removeOverlays(Troutdale);
map.removeOverlays(Wilsonville);
setTimeout(function(){map.addOverlays(Creswell)},1000);
setTimeout(function(){map.addOverlays(Damascus)},1000);
setTimeout(function(){map.addOverlays(Eugene)},1000);
setTimeout(function(){map.addOverlays(Forest_Grove)},1000);
setTimeout(function(){map.addOverlays(Gresham)},1000);
setTimeout(function(){map.addOverlays(Hood_River)},1000);
setTimeout(function(){map.addOverlays(Lake_Oswego)},1000);
setTimeout(function(){map.addOverlays(Milwaukie)},1000);
setTimeout(function(){map.addOverlays(Molalla)},1000);
setTimeout(function(){map.addOverlays(Pleasant_Hill)},1000);
setTimeout(function(){map.addOverlays(Portland)},1000);
setTimeout(function(){map.addOverlays(Prineville)},1000);
setTimeout(function(){map.addOverlays(Sheridan)},1000);
setTimeout(function(){map.addOverlays(Troutdale)},1000);
setTimeout(function(){map.addOverlays(Wilsonville)},1000);
maxLng = -120.40903300;
maxLat = 45.69660000;
minLng = -123.42946700;
minLat = 43.90750000;
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(Creswell);
map.removeOverlays(Damascus);
map.removeOverlays(Eugene);
map.removeOverlays(Forest_Grove);
map.removeOverlays(Gresham);
map.removeOverlays(Hood_River);
map.removeOverlays(Lake_Oswego);
map.removeOverlays(Milwaukie);
map.removeOverlays(Molalla);
map.removeOverlays(Pleasant_Hill);
map.removeOverlays(Portland);
map.removeOverlays(Prineville);
map.removeOverlays(Sheridan);
map.removeOverlays(Troutdale);
map.removeOverlays(Wilsonville);
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(Portland);map.removeOverlays(Creswell);
map.removeOverlays(Damascus);
map.removeOverlays(Eugene);
map.removeOverlays(Forest_Grove);
map.removeOverlays(Gresham);
map.removeOverlays(Hood_River);
map.removeOverlays(Lake_Oswego);
map.removeOverlays(Milwaukie);
map.removeOverlays(Molalla);
map.removeOverlays(Pleasant_Hill);
map.removeOverlays(Portland);
map.removeOverlays(Prineville);
map.removeOverlays(Sheridan);
map.removeOverlays(Troutdale);
map.removeOverlays(Wilsonville);
map.addOverlays(Creswell);
centerByArray(Creswell, false, false);
cntMarker += Creswell.length;
map.addOverlays(Damascus);
centerByArray(Damascus, false, false);
cntMarker += Damascus.length;
map.addOverlays(Eugene);
centerByArray(Eugene, false, false);
cntMarker += Eugene.length;
map.addOverlays(Forest_Grove);
centerByArray(Forest_Grove, false, false);
cntMarker += Forest_Grove.length;
map.addOverlays(Gresham);
centerByArray(Gresham, false, false);
cntMarker += Gresham.length;
map.addOverlays(Hood_River);
centerByArray(Hood_River, false, false);
cntMarker += Hood_River.length;
map.addOverlays(Lake_Oswego);
centerByArray(Lake_Oswego, false, false);
cntMarker += Lake_Oswego.length;
map.addOverlays(Milwaukie);
centerByArray(Milwaukie, false, false);
cntMarker += Milwaukie.length;
map.addOverlays(Molalla);
centerByArray(Molalla, false, false);
cntMarker += Molalla.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(Prineville);
centerByArray(Prineville, false, false);
cntMarker += Prineville.length;
map.addOverlays(Sheridan);
centerByArray(Sheridan, false, false);
cntMarker += Sheridan.length;
map.addOverlays(Troutdale);
centerByArray(Troutdale, false, false);
cntMarker += Troutdale.length;
map.addOverlays(Wilsonville);
centerByArray(Wilsonville, false, false);
cntMarker += Wilsonville.length;
centerByArray(Portland,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///22683,22632,22763,35579,22697,35580,22801,22689,22680,22683,22836,22700,22957,22839,22632,22944,22697,35575,35576,22711,22712,22933,35578,35577,22962,22689,30392,/all');
//window.open('/map.php?type=2&schools=22683,22632,22763,35579,22697,35580,22801,22689,22680,22683,22836,22700,22957,22839,22632,22944,22697,35575,35576,22711,22712,22933,35578,35577,22962,22689,30392,&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;
}