function addMarkers(){
mySelect = document.getElementById('selection');
Azusa = [];Placerville = [];Davis = [];El_Sobrante = [];Northridge = [];San_Rafael = [];Altadena = [];Fair_Oaks = [];San_Francisco = [];Cardiff_By_The_Sea = [];Santa_Cruz = [];Jamestown = [];San_Gabriel = [];Colfax = [];Lake_Balboa = [];Costa_Mesa = [];Los_Altos = [];San_Diego = [];Goleta = [];mySelect.options[mySelect.options.length] = new Option("Altadena schools",'all=Altadena');
mySelect.options[mySelect.options.length] = new Option("Azusa schools",'all=Azusa');
mySelect.options[mySelect.options.length] = new Option("Cardiff By The Sea schools",'all=Cardiff_By_The_Sea');
mySelect.options[mySelect.options.length] = new Option("Colfax schools",'all=Colfax');
mySelect.options[mySelect.options.length] = new Option("Costa Mesa schools",'all=Costa_Mesa');
mySelect.options[mySelect.options.length] = new Option("Davis schools",'all=Davis');
mySelect.options[mySelect.options.length] = new Option("El Sobrante schools",'all=El_Sobrante');
mySelect.options[mySelect.options.length] = new Option("Fair Oaks schools",'all=Fair_Oaks');
mySelect.options[mySelect.options.length] = new Option("Goleta schools",'all=Goleta');
mySelect.options[mySelect.options.length] = new Option("Jamestown schools",'all=Jamestown');
mySelect.options[mySelect.options.length] = new Option("Lake Balboa schools",'all=Lake_Balboa');
mySelect.options[mySelect.options.length] = new Option("Los Altos schools",'all=Los_Altos');
mySelect.options[mySelect.options.length] = new Option("Northridge schools",'all=Northridge');
mySelect.options[mySelect.options.length] = new Option("Placerville schools",'all=Placerville');
mySelect.options[mySelect.options.length] = new Option("San Diego schools",'all=San_Diego');
mySelect.options[mySelect.options.length] = new Option("San Francisco schools",'all=San_Francisco');
mySelect.options[mySelect.options.length] = new Option("San Gabriel schools",'all=San_Gabriel');
mySelect.options[mySelect.options.length] = new Option("San Rafael schools",'all=San_Rafael');
mySelect.options[mySelect.options.length] = new Option("Santa Cruz schools",'all=Santa_Cruz');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Azusa[Azusa.length] = createMarker(new GPoint(-117.91340100,34.11813700),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Azusa Day School Montessori",'Azusa=' + Azusa.length);
Placerville[Placerville.length] = createMarker(new GPoint(-120.86252000,38.69235700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cedar Springs Waldorf School",'Placerville=' + Placerville.length);
Davis[Davis.length] = createMarker(new GPoint(-121.76698600,38.57031100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Davis Waldorf School",'Davis=' + Davis.length);
El_Sobrante[El_Sobrante.length] = createMarker(new GPoint(-122.30107800,37.96616400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("East Bay Waldorf School",'El_Sobrante=' + El_Sobrante.length);
Northridge[Northridge.length] = createMarker(new GPoint(-118.50567800,34.24651100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Highland Hall Waldorf School",'Northridge=' + Northridge.length);
San_Rafael[San_Rafael.length] = createMarker(new GPoint(-122.55879500,38.02826900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Marin Waldorf School",'San_Rafael=' + San_Rafael.length);
Altadena[Altadena.length] = createMarker(new GPoint(-118.14462400,34.19177200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Pasadena Waldorf School",'Altadena=' + Altadena.length);
Fair_Oaks[Fair_Oaks.length] = createMarker(new GPoint(-121.28693400,38.63276000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sacramento Waldorf School",'Fair_Oaks=' + Fair_Oaks.length);
San_Francisco[San_Francisco.length] = createMarker(new GPoint(-122.44170200,37.79079800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("San Francisco Waldorf School",'San_Francisco=' + San_Francisco.length);
Cardiff_By_The_Sea[Cardiff_By_The_Sea.length] = createMarker(new GPoint(-117.27270300,33.03274300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sanderling School",'Cardiff_By_The_Sea=' + Cardiff_By_The_Sea.length);
Santa_Cruz[Santa_Cruz.length] = createMarker(new GPoint(-122.07358600,37.00543700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Santa Cruz Waldorf School",'Santa_Cruz=' + Santa_Cruz.length);
Jamestown[Jamestown.length] = createMarker(new GPoint(-120.44924800,37.96335700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sierra Waldorf School",'Jamestown=' + Jamestown.length);
San_Gabriel[San_Gabriel.length] = createMarker(new GPoint(-118.10421600,34.10260800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sinwa Education Center",'San_Gabriel=' + San_Gabriel.length);
Colfax[Colfax.length] = createMarker(new GPoint(-120.95600000,39.07880000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Somerset Home School",'Colfax=' + Colfax.length);
Lake_Balboa[Lake_Balboa.length] = createMarker(new GPoint(-118.51277500,34.20098700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Valley Waldorf City School",'Lake_Balboa=' + Lake_Balboa.length);
Costa_Mesa[Costa_Mesa.length] = createMarker(new GPoint(-117.94068300,33.65860900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Waldorf School Of Orange County",'Costa_Mesa=' + Costa_Mesa.length);
Los_Altos[Los_Altos.length] = createMarker(new GPoint(-122.09421300,37.34356700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Waldorf School Of The Peninsula",'Los_Altos=' + Los_Altos.length);
San_Diego[San_Diego.length] = createMarker(new GPoint(-117.08600300,32.74324200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Waldorf School Of San Diego",'San_Diego=' + San_Diego.length);
Goleta[Goleta.length] = createMarker(new GPoint(-119.75200000,34.47100000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Waldorf School Of Santa Barbara",'Goleta=' + Goleta.length);
map.removeOverlays(Altadena);
map.removeOverlays(Azusa);
map.removeOverlays(Cardiff_By_The_Sea);
map.removeOverlays(Colfax);
map.removeOverlays(Costa_Mesa);
map.removeOverlays(Davis);
map.removeOverlays(El_Sobrante);
map.removeOverlays(Fair_Oaks);
map.removeOverlays(Goleta);
map.removeOverlays(Jamestown);
map.removeOverlays(Lake_Balboa);
map.removeOverlays(Los_Altos);
map.removeOverlays(Northridge);
map.removeOverlays(Placerville);
map.removeOverlays(San_Diego);
map.removeOverlays(San_Francisco);
map.removeOverlays(San_Gabriel);
map.removeOverlays(San_Rafael);
map.removeOverlays(Santa_Cruz);
setTimeout(function(){map.addOverlays(Altadena)},1000);
setTimeout(function(){map.addOverlays(Azusa)},1000);
setTimeout(function(){map.addOverlays(Cardiff_By_The_Sea)},1000);
setTimeout(function(){map.addOverlays(Colfax)},1000);
setTimeout(function(){map.addOverlays(Costa_Mesa)},1000);
setTimeout(function(){map.addOverlays(Davis)},1000);
setTimeout(function(){map.addOverlays(El_Sobrante)},1000);
setTimeout(function(){map.addOverlays(Fair_Oaks)},1000);
setTimeout(function(){map.addOverlays(Goleta)},1000);
setTimeout(function(){map.addOverlays(Jamestown)},1000);
setTimeout(function(){map.addOverlays(Lake_Balboa)},1000);
setTimeout(function(){map.addOverlays(Los_Altos)},1000);
setTimeout(function(){map.addOverlays(Northridge)},1000);
setTimeout(function(){map.addOverlays(Placerville)},1000);
setTimeout(function(){map.addOverlays(San_Diego)},1000);
setTimeout(function(){map.addOverlays(San_Francisco)},1000);
setTimeout(function(){map.addOverlays(San_Gabriel)},1000);
setTimeout(function(){map.addOverlays(San_Rafael)},1000);
setTimeout(function(){map.addOverlays(Santa_Cruz)},1000);
maxLng = -117.08600300;
maxLat = 39.07880000;
minLng = -122.55879500;
minLat = 32.74324200;
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(Altadena);
map.removeOverlays(Azusa);
map.removeOverlays(Cardiff_By_The_Sea);
map.removeOverlays(Colfax);
map.removeOverlays(Costa_Mesa);
map.removeOverlays(Davis);
map.removeOverlays(El_Sobrante);
map.removeOverlays(Fair_Oaks);
map.removeOverlays(Goleta);
map.removeOverlays(Jamestown);
map.removeOverlays(Lake_Balboa);
map.removeOverlays(Los_Altos);
map.removeOverlays(Northridge);
map.removeOverlays(Placerville);
map.removeOverlays(San_Diego);
map.removeOverlays(San_Francisco);
map.removeOverlays(San_Gabriel);
map.removeOverlays(San_Rafael);
map.removeOverlays(Santa_Cruz);
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(Azusa);map.removeOverlays(Altadena);
map.removeOverlays(Azusa);
map.removeOverlays(Cardiff_By_The_Sea);
map.removeOverlays(Colfax);
map.removeOverlays(Costa_Mesa);
map.removeOverlays(Davis);
map.removeOverlays(El_Sobrante);
map.removeOverlays(Fair_Oaks);
map.removeOverlays(Goleta);
map.removeOverlays(Jamestown);
map.removeOverlays(Lake_Balboa);
map.removeOverlays(Los_Altos);
map.removeOverlays(Northridge);
map.removeOverlays(Placerville);
map.removeOverlays(San_Diego);
map.removeOverlays(San_Francisco);
map.removeOverlays(San_Gabriel);
map.removeOverlays(San_Rafael);
map.removeOverlays(Santa_Cruz);
map.addOverlays(Altadena);
centerByArray(Altadena, false, false);
cntMarker += Altadena.length;
map.addOverlays(Azusa);
centerByArray(Azusa, false, false);
cntMarker += Azusa.length;
map.addOverlays(Cardiff_By_The_Sea);
centerByArray(Cardiff_By_The_Sea, false, false);
cntMarker += Cardiff_By_The_Sea.length;
map.addOverlays(Colfax);
centerByArray(Colfax, false, false);
cntMarker += Colfax.length;
map.addOverlays(Costa_Mesa);
centerByArray(Costa_Mesa, false, false);
cntMarker += Costa_Mesa.length;
map.addOverlays(Davis);
centerByArray(Davis, false, false);
cntMarker += Davis.length;
map.addOverlays(El_Sobrante);
centerByArray(El_Sobrante, false, false);
cntMarker += El_Sobrante.length;
map.addOverlays(Fair_Oaks);
centerByArray(Fair_Oaks, false, false);
cntMarker += Fair_Oaks.length;
map.addOverlays(Goleta);
centerByArray(Goleta, false, false);
cntMarker += Goleta.length;
map.addOverlays(Jamestown);
centerByArray(Jamestown, false, false);
cntMarker += Jamestown.length;
map.addOverlays(Lake_Balboa);
centerByArray(Lake_Balboa, false, false);
cntMarker += Lake_Balboa.length;
map.addOverlays(Los_Altos);
centerByArray(Los_Altos, false, false);
cntMarker += Los_Altos.length;
map.addOverlays(Northridge);
centerByArray(Northridge, false, false);
cntMarker += Northridge.length;
map.addOverlays(Placerville);
centerByArray(Placerville, false, false);
cntMarker += Placerville.length;
map.addOverlays(San_Diego);
centerByArray(San_Diego, false, false);
cntMarker += San_Diego.length;
map.addOverlays(San_Francisco);
centerByArray(San_Francisco, false, false);
cntMarker += San_Francisco.length;
map.addOverlays(San_Gabriel);
centerByArray(San_Gabriel, false, false);
cntMarker += San_Gabriel.length;
map.addOverlays(San_Rafael);
centerByArray(San_Rafael, false, false);
cntMarker += San_Rafael.length;
map.addOverlays(Santa_Cruz);
centerByArray(Santa_Cruz, false, false);
cntMarker += Santa_Cruz.length;
centerByArray(Azusa,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///3818,4435,3619,2383,3696,3726,3392,1358,1114,3818,4435,1929,1995,3619,4607,3798,35319,4605,2383,1634,4606,3696,35849,2825,3726,/all');
//window.open('/map.php?type=2&schools=3818,4435,3619,2383,3696,3726,3392,1358,1114,3818,4435,1929,1995,3619,4607,3798,35319,4605,2383,1634,4606,3696,35849,2825,3726,&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;
}