function addMarkers(){
mySelect = document.getElementById('selection');
Redwood_Valley = [];Covelo = [];Talmage = [];Fort_Bragg = [];Ukiah = [];Willits = [];Philo = [];Calpella = [];mySelect.options[mySelect.options.length] = new Option("Calpella schools",'all=Calpella');
mySelect.options[mySelect.options.length] = new Option("Covelo schools",'all=Covelo');
mySelect.options[mySelect.options.length] = new Option("Fort Bragg schools",'all=Fort_Bragg');
mySelect.options[mySelect.options.length] = new Option("Philo schools",'all=Philo');
mySelect.options[mySelect.options.length] = new Option("Redwood Valley schools",'all=Redwood_Valley');
mySelect.options[mySelect.options.length] = new Option("Talmage schools",'all=Talmage');
mySelect.options[mySelect.options.length] = new Option("Ukiah schools",'all=Ukiah');
mySelect.options[mySelect.options.length] = new Option("Willits schools",'all=Willits');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Redwood_Valley[Redwood_Valley.length] = createMarker(new GPoint(-123.21593900,39.27161000),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cornerstone School",'Redwood_Valley=' + Redwood_Valley.length);
Covelo[Covelo.length] = createMarker(new GPoint(-123.26204000,39.81610300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Covelo Sda School",'Covelo=' + Covelo.length);
Redwood_Valley[Redwood_Valley.length] = createMarker(new GPoint(-123.22510000,39.27670000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Deep Valley Christian School",'Redwood_Valley=' + Redwood_Valley.length);
Talmage[Talmage.length] = createMarker(new GPoint(-123.16580000,39.12690000),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Developing Virtue Secondary School",'Talmage=' + Talmage.length);
Fort_Bragg[Fort_Bragg.length] = createMarker(new GPoint(-123.79807900,39.47188500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Ft. Bragg Seventh-day Advent",'Fort_Bragg=' + Fort_Bragg.length);
Talmage[Talmage.length] = createMarker(new GPoint(-123.16580000,39.12690000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Instilling Goodness / Developing Virtue Schools",'Talmage=' + Talmage.length);
Fort_Bragg[Fort_Bragg.length] = createMarker(new GPoint(-123.81332100,39.41203700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mendocino Coast Christian School",'Fort_Bragg=' + Fort_Bragg.length);
Ukiah[Ukiah.length] = createMarker(new GPoint(-123.19891500,39.14662400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("New Morning Montessori School",'Ukiah=' + Ukiah.length);
Ukiah[Ukiah.length] = createMarker(new GPoint(-123.21492700,39.14800300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("North Haven School-advanced Educ Services",'Ukiah=' + Ukiah.length);
Ukiah[Ukiah.length] = createMarker(new GPoint(-123.20974800,39.13828900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Mary Of The Angels Catholic School",'Ukiah=' + Ukiah.length);
Fort_Bragg[Fort_Bragg.length] = createMarker(new GPoint(-123.74929900,39.50416300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Thomas More Preparatory",'Fort_Bragg=' + Fort_Bragg.length);
Willits[Willits.length] = createMarker(new GPoint(-123.35804800,39.40548900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Trinity Holiness Academy",'Willits=' + Willits.length);
Ukiah[Ukiah.length] = createMarker(new GPoint(-123.19719800,39.10706100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Ukiah Junior Academy",'Ukiah=' + Ukiah.length);
Philo[Philo.length] = createMarker(new GPoint(-123.50190000,39.11490000),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Unicorn School",'Philo=' + Philo.length);
Calpella[Calpella.length] = createMarker(new GPoint(-123.20757900,39.23429000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Waldorf School Of Mendocino County",'Calpella=' + Calpella.length);
Willits[Willits.length] = createMarker(new GPoint(-123.33602100,39.41059000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Willits Sda School",'Willits=' + Willits.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(Calpella);
map.removeOverlays(Covelo);
map.removeOverlays(Fort_Bragg);
map.removeOverlays(Philo);
map.removeOverlays(Redwood_Valley);
map.removeOverlays(Talmage);
map.removeOverlays(Ukiah);
map.removeOverlays(Willits);
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(Redwood_Valley);map.removeOverlays(Calpella);
map.removeOverlays(Covelo);
map.removeOverlays(Fort_Bragg);
map.removeOverlays(Philo);
map.removeOverlays(Redwood_Valley);
map.removeOverlays(Talmage);
map.removeOverlays(Ukiah);
map.removeOverlays(Willits);
map.addOverlays(Calpella);
centerByArray(Calpella, false, false);
cntMarker += Calpella.length;
map.addOverlays(Covelo);
centerByArray(Covelo, false, false);
cntMarker += Covelo.length;
map.addOverlays(Fort_Bragg);
centerByArray(Fort_Bragg, false, false);
cntMarker += Fort_Bragg.length;
map.addOverlays(Philo);
centerByArray(Philo, false, false);
cntMarker += Philo.length;
map.addOverlays(Redwood_Valley);
centerByArray(Redwood_Valley, false, false);
cntMarker += Redwood_Valley.length;
map.addOverlays(Talmage);
centerByArray(Talmage, false, false);
cntMarker += Talmage.length;
map.addOverlays(Ukiah);
centerByArray(Ukiah, false, false);
cntMarker += Ukiah.length;
map.addOverlays(Willits);
centerByArray(Willits, false, false);
cntMarker += Willits.length;
centerByArray(Redwood_Valley,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;
}