function addMarkers(){
mySelect = document.getElementById('selection');
Portland = [];Troutdale = [];Gresham = [];mySelect.options[mySelect.options.length] = new Option("Gresham schools",'all=Gresham');
mySelect.options[mySelect.options.length] = new Option("Portland schools",'all=Portland');
mySelect.options[mySelect.options.length] = new Option("Troutdale schools",'all=Troutdale');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
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);
Portland[Portland.length] = createMarker(new GPoint(-122.64129400,45.51943700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Central Catholic High School",'Portland=' + Portland.length);
Portland[Portland.length] = createMarker(new GPoint(-122.56874900,45.54871600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("City Christian Schools",'Portland=' + Portland.length);
Portland[Portland.length] = createMarker(new GPoint(-122.57049500,45.52590900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Columbia Christian Schools",'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);
Portland[Portland.length] = createMarker(new GPoint(-122.69227200,45.57855400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("De La Salle North Catholic High School",'Portland=' + Portland.length);
Portland[Portland.length] = createMarker(new GPoint(-122.61794500,45.56163700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("De Paul Alternative School",'Portland=' + Portland.length);
Portland[Portland.length] = createMarker(new GPoint(-122.55839500,45.52710600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Eastside Education Center",'Portland=' + Portland.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);
Portland[Portland.length] = createMarker(new GPoint(-122.76955500,45.48626300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Jesuit High School",'Portland=' + Portland.length);
Portland[Portland.length] = createMarker(new GPoint(-122.61217300,45.47933700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lents Education Center",'Portland=' + Portland.length);
Portland[Portland.length] = createMarker(new GPoint(-122.68498200,45.51758600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Northwest Academy",'Portland=' + Portland.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);
Portland[Portland.length] = createMarker(new GPoint(-122.69970300,45.57795700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Open Meadow High School/crue",'Portland=' + Portland.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);
Portland[Portland.length] = createMarker(new GPoint(-122.63576400,45.52379000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Pacific Crest Community School",'Portland=' + Portland.length);
Gresham[Gresham.length] = createMarker(new GPoint(-122.39101200,45.50430200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Pacific View Alternative School",'Gresham=' + Gresham.length);
Gresham[Gresham.length] = createMarker(new GPoint(-122.41005100,45.49842400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Phonics Phactory",'Gresham=' + Gresham.length);
Portland[Portland.length] = createMarker(new GPoint(-122.56407100,45.51222000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Portland Adventist Academy",'Portland=' + Portland.length);
Portland[Portland.length] = createMarker(new GPoint(-122.53521500,45.53733700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Portland Christian School",'Portland=' + Portland.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);
Portland[Portland.length] = createMarker(new GPoint(-122.67421500,45.56203700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Portland Opportunities Industrialization Center",'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);
Portland[Portland.length] = createMarker(new GPoint(-122.68393000,45.45450700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Riverdale High School",'Portland=' + Portland.length);
Portland[Portland.length] = createMarker(new GPoint(-122.68109300,45.51265600),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("St. Marys Academy",'Portland=' + Portland.length);
Portland[Portland.length] = createMarker(new GPoint(-122.67496900,45.51204000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Serendipity Center",'Portland=' + Portland.length);
Gresham[Gresham.length] = createMarker(new GPoint(-122.44220400,45.50435300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Serp Alternative School",'Gresham=' + Gresham.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);
} // 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/////2/' + showArray);
map.removeOverlays(Gresham);
map.removeOverlays(Portland);
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(Portland);map.removeOverlays(Gresham);
map.removeOverlays(Portland);
map.removeOverlays(Troutdale);
map.addOverlays(Gresham);
centerByArray(Gresham, false, false);
cntMarker += Gresham.length;
map.addOverlays(Portland);
centerByArray(Portland, false, false);
cntMarker += Portland.length;
map.addOverlays(Troutdale);
centerByArray(Troutdale, false, false);
cntMarker += Troutdale.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////all');
//window.open('/map.php?type=1&schools=&school_level=2&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;
}