function addMarkers(){
mySelect = document.getElementById('selection');
Albany = [];Tangent = [];Lebanon = [];Sweet_Home = [];Harrisburg = [];Halsey = [];Scio = [];mySelect.options[mySelect.options.length] = new Option("Albany schools",'all=Albany');
mySelect.options[mySelect.options.length] = new Option("Halsey schools",'all=Halsey');
mySelect.options[mySelect.options.length] = new Option("Harrisburg schools",'all=Harrisburg');
mySelect.options[mySelect.options.length] = new Option("Lebanon schools",'all=Lebanon');
mySelect.options[mySelect.options.length] = new Option("Scio schools",'all=Scio');
mySelect.options[mySelect.options.length] = new Option("Sweet Home schools",'all=Sweet_Home');
mySelect.options[mySelect.options.length] = new Option("Tangent schools",'all=Tangent');
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);
Tangent[Tangent.length] = createMarker(new GPoint(-123.12272300,44.56076700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Central Valley Christian School",'Tangent=' + Tangent.length);
Albany[Albany.length] = createMarker(new GPoint(-123.10738800,44.63597500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Community Services Consortium",'Albany=' + Albany.length);
Lebanon[Lebanon.length] = createMarker(new GPoint(-122.90236900,44.51808100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Csc Lebanon Learning Opportunities Center",'Lebanon=' + Lebanon.length);
Lebanon[Lebanon.length] = createMarker(new GPoint(-122.91498600,44.50498300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("East Linn Christian Academy",'Lebanon=' + Lebanon.length);
Sweet_Home[Sweet_Home.length] = createMarker(new GPoint(-122.78681800,44.43068800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("East Linn Christian Academy Elem-liberty Campus",'Sweet_Home=' + Sweet_Home.length);
Albany[Albany.length] = createMarker(new GPoint(-123.00833900,44.59976800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Fairview Christian School",'Albany=' + Albany.length);
Albany[Albany.length] = createMarker(new GPoint(-123.11690200,44.61573800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("First United Methodist Early Learning Center",'Albany=' + Albany.length);
Albany[Albany.length] = createMarker(new GPoint(-123.08080400,44.61026300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Good Shepherd Lutheran School",'Albany=' + Albany.length);
Harrisburg[Harrisburg.length] = createMarker(new GPoint(-123.12671900,44.26160000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Harris Private School",'Harrisburg=' + Harrisburg.length);
Halsey[Halsey.length] = createMarker(new GPoint(-123.19923500,44.37118200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lake Creek Mennonite School",'Halsey=' + Halsey.length);
Albany[Albany.length] = createMarker(new GPoint(-123.11005300,44.58689700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Linn-benton Comm College Family Resource Center",'Albany=' + Albany.length);
Albany[Albany.length] = createMarker(new GPoint(-123.11635600,44.62378500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Livingwater Christian Assembly",'Albany=' + Albany.length);
Albany[Albany.length] = createMarker(new GPoint(-123.10598700,44.63147200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Mary Elementary School",'Albany=' + Albany.length);
Lebanon[Lebanon.length] = createMarker(new GPoint(-122.99736200,44.50475100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sandridge Academy",'Lebanon=' + Lebanon.length);
Scio[Scio.length] = createMarker(new GPoint(-122.66491000,44.70760100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Santiam Crossing",'Scio=' + Scio.length);
Scio[Scio.length] = createMarker(new GPoint(-122.76228700,44.68953200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Skyline Christian Academy",'Scio=' + Scio.length);
Albany[Albany.length] = createMarker(new GPoint(-123.09219800,44.63416400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sundborn Children's House, A Montessori School",'Albany=' + Albany.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/////3/' + showArray);
map.removeOverlays(Albany);
map.removeOverlays(Halsey);
map.removeOverlays(Harrisburg);
map.removeOverlays(Lebanon);
map.removeOverlays(Scio);
map.removeOverlays(Sweet_Home);
map.removeOverlays(Tangent);
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(Halsey);
map.removeOverlays(Harrisburg);
map.removeOverlays(Lebanon);
map.removeOverlays(Scio);
map.removeOverlays(Sweet_Home);
map.removeOverlays(Tangent);
map.addOverlays(Albany);
centerByArray(Albany, false, false);
cntMarker += Albany.length;
map.addOverlays(Halsey);
centerByArray(Halsey, false, false);
cntMarker += Halsey.length;
map.addOverlays(Harrisburg);
centerByArray(Harrisburg, false, false);
cntMarker += Harrisburg.length;
map.addOverlays(Lebanon);
centerByArray(Lebanon, false, false);
cntMarker += Lebanon.length;
map.addOverlays(Scio);
centerByArray(Scio, false, false);
cntMarker += Scio.length;
map.addOverlays(Sweet_Home);
centerByArray(Sweet_Home, false, false);
cntMarker += Sweet_Home.length;
map.addOverlays(Tangent);
centerByArray(Tangent, false, false);
cntMarker += Tangent.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////all');
//window.open('/map.php?type=1&schools=&school_level=3&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;
}