function addMarkers(){
mySelect = document.getElementById('selection');
Corte_Madera = [];San_Rafael = [];Fairfax = [];Sausalito = [];Bolinas = [];Novato = [];Mill_Valley = [];Larkspur = [];San_Anselmo = [];Tiburon = [];Marin_City = [];mySelect.options[mySelect.options.length] = new Option("Bolinas schools",'all=Bolinas');
mySelect.options[mySelect.options.length] = new Option("Corte Madera schools",'all=Corte_Madera');
mySelect.options[mySelect.options.length] = new Option("Fairfax schools",'all=Fairfax');
mySelect.options[mySelect.options.length] = new Option("Larkspur schools",'all=Larkspur');
mySelect.options[mySelect.options.length] = new Option("Marin City schools",'all=Marin_City');
mySelect.options[mySelect.options.length] = new Option("Mill Valley schools",'all=Mill_Valley');
mySelect.options[mySelect.options.length] = new Option("Novato schools",'all=Novato');
mySelect.options[mySelect.options.length] = new Option("San Anselmo schools",'all=San_Anselmo');
mySelect.options[mySelect.options.length] = new Option("San Rafael schools",'all=San_Rafael');
mySelect.options[mySelect.options.length] = new Option("Sausalito schools",'all=Sausalito');
mySelect.options[mySelect.options.length] = new Option("Tiburon schools",'all=Tiburon');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Corte_Madera[Corte_Madera.length] = createMarker(new GPoint(-122.50543800,37.91638600),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Allaire School",'Corte_Madera=' + Corte_Madera.length);
San_Rafael[San_Rafael.length] = createMarker(new GPoint(-122.52393900,38.00009400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Brandeis Hillel Day School",'San_Rafael=' + San_Rafael.length);
Fairfax[Fairfax.length] = createMarker(new GPoint(-122.59981100,37.99841700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cascade Canyon School",'Fairfax=' + Fairfax.length);
Sausalito[Sausalito.length] = createMarker(new GPoint(-122.51405700,37.87148100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Childrens Cultural Cntr-marin",'Sausalito=' + Sausalito.length);
Corte_Madera[Corte_Madera.length] = createMarker(new GPoint(-122.50543800,37.91638600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Corte Madera Montessori",'Corte_Madera=' + Corte_Madera.length);
San_Rafael[San_Rafael.length] = createMarker(new GPoint(-122.52772500,37.99584400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Dunham Academy",'San_Rafael=' + San_Rafael.length);
San_Rafael[San_Rafael.length] = createMarker(new GPoint(-122.54702900,38.01968600),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Full Circle",'San_Rafael=' + San_Rafael.length);
Bolinas[Bolinas.length] = createMarker(new GPoint(-122.70040000,37.90760000),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Full Circle School Marin",'Bolinas=' + Bolinas.length);
Novato[Novato.length] = createMarker(new GPoint(-122.55772100,38.08080600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Good Shepherd Lutheran School",'Novato=' + Novato.length);
Mill_Valley[Mill_Valley.length] = createMarker(new GPoint(-122.54565400,37.90707100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Greenwood School",'Mill_Valley=' + Mill_Valley.length);
Mill_Valley[Mill_Valley.length] = createMarker(new GPoint(-122.54395000,37.87988200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Kumara School",'Mill_Valley=' + Mill_Valley.length);
Novato[Novato.length] = createMarker(new GPoint(-122.57080000,38.10090000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Living Epistle Christian",'Novato=' + Novato.length);
Corte_Madera[Corte_Madera.length] = createMarker(new GPoint(-122.49834500,37.92124200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lycee Francais La Perouse",'Corte_Madera=' + Corte_Madera.length);
Novato[Novato.length] = createMarker(new GPoint(-122.56411800,38.08718600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Marin Christian Academy",'Novato=' + Novato.length);
Corte_Madera[Corte_Madera.length] = createMarker(new GPoint(-122.49186100,37.91990800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Marin Country Day School",'Corte_Madera=' + Corte_Madera.length);
Mill_Valley[Mill_Valley.length] = createMarker(new GPoint(-122.54362800,37.89686600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Marin Horizon School",'Mill_Valley=' + Mill_Valley.length);
Corte_Madera[Corte_Madera.length] = createMarker(new GPoint(-122.49087200,37.92004000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Marin Montessori School",'Corte_Madera=' + Corte_Madera.length);
Larkspur[Larkspur.length] = createMarker(new GPoint(-122.53236300,37.92847500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Marin Primary & Middle School",'Larkspur=' + Larkspur.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);
San_Rafael[San_Rafael.length] = createMarker(new GPoint(-122.53521900,37.99554100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Merry Times Preschool Academy",'San_Rafael=' + San_Rafael.length);
San_Rafael[San_Rafael.length] = createMarker(new GPoint(-122.54627900,38.01295000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Montessori De Terra Linda",'San_Rafael=' + San_Rafael.length);
San_Rafael[San_Rafael.length] = createMarker(new GPoint(-122.55751100,38.00356300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Montessori In Motion",'San_Rafael=' + San_Rafael.length);
San_Rafael[San_Rafael.length] = createMarker(new GPoint(-122.51099800,37.95704000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Montessori School Of Central Marin",'San_Rafael=' + San_Rafael.length);
Novato[Novato.length] = createMarker(new GPoint(-122.58420000,38.09730000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Montessori School Of Novato",'Novato=' + Novato.length);
Mill_Valley[Mill_Valley.length] = createMarker(new GPoint(-122.53275200,37.88874800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mount Tamalpais School",'Mill_Valley=' + Mill_Valley.length);
Corte_Madera[Corte_Madera.length] = createMarker(new GPoint(-122.50538400,37.91640200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Mountain School",'Corte_Madera=' + Corte_Madera.length);
Novato[Novato.length] = createMarker(new GPoint(-122.56465600,38.09733600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("North Bay Christian Academy",'Novato=' + Novato.length);
Novato[Novato.length] = createMarker(new GPoint(-122.58517700,38.12194400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Novato Christian School",'Novato=' + Novato.length);
Novato[Novato.length] = createMarker(new GPoint(-122.58366100,38.10970800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Our Lady Of Loretto School",'Novato=' + Novato.length);
Mill_Valley[Mill_Valley.length] = createMarker(new GPoint(-122.52238000,37.90743700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Ring Mountain Day School",'Mill_Valley=' + Mill_Valley.length);
Mill_Valley[Mill_Valley.length] = createMarker(new GPoint(-122.51396900,37.90663500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Ross Academy Montessori School",'Mill_Valley=' + Mill_Valley.length);
San_Anselmo[San_Anselmo.length] = createMarker(new GPoint(-122.56227900,37.97029400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Anselm School",'San_Anselmo=' + San_Anselmo.length);
Tiburon[Tiburon.length] = createMarker(new GPoint(-122.47482500,37.88800200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Hilary School",'Tiburon=' + Tiburon.length);
San_Rafael[San_Rafael.length] = createMarker(new GPoint(-122.54440000,38.01440000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Isabella School",'San_Rafael=' + San_Rafael.length);
San_Rafael[San_Rafael.length] = createMarker(new GPoint(-122.55583700,38.00748800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Saint Mark's School",'San_Rafael=' + San_Rafael.length);
Larkspur[Larkspur.length] = createMarker(new GPoint(-122.53652000,37.93445800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Patrick School",'Larkspur=' + Larkspur.length);
San_Rafael[San_Rafael.length] = createMarker(new GPoint(-122.52823300,37.97426500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Raphael School",'San_Rafael=' + San_Rafael.length);
Fairfax[Fairfax.length] = createMarker(new GPoint(-122.59110800,37.99068200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Rita Elementary School",'Fairfax=' + Fairfax.length);
San_Anselmo[San_Anselmo.length] = createMarker(new GPoint(-122.56050000,37.97060000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("San Anselmo Montessori School",'San_Anselmo=' + San_Anselmo.length);
San_Anselmo[San_Anselmo.length] = createMarker(new GPoint(-122.58544900,38.01318200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("San Domenico School",'San_Anselmo=' + San_Anselmo.length);
San_Anselmo[San_Anselmo.length] = createMarker(new GPoint(-122.56645600,37.98069400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Star Academy",'San_Anselmo=' + San_Anselmo.length);
San_Rafael[San_Rafael.length] = createMarker(new GPoint(-122.52829400,38.03465900),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Timothy Murphy School",'San_Rafael=' + San_Rafael.length);
San_Rafael[San_Rafael.length] = createMarker(new GPoint(-122.52763200,37.96628900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Trinity Preschool And Kindergarten",'San_Rafael=' + San_Rafael.length);
Marin_City[Marin_City.length] = createMarker(new GPoint(-122.51010700,37.86765200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Women Helping All People Scholastic Academy",'Marin_City=' + Marin_City.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/////1/' + showArray);
map.removeOverlays(Bolinas);
map.removeOverlays(Corte_Madera);
map.removeOverlays(Fairfax);
map.removeOverlays(Larkspur);
map.removeOverlays(Marin_City);
map.removeOverlays(Mill_Valley);
map.removeOverlays(Novato);
map.removeOverlays(San_Anselmo);
map.removeOverlays(San_Rafael);
map.removeOverlays(Sausalito);
map.removeOverlays(Tiburon);
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(Corte_Madera);map.removeOverlays(Bolinas);
map.removeOverlays(Corte_Madera);
map.removeOverlays(Fairfax);
map.removeOverlays(Larkspur);
map.removeOverlays(Marin_City);
map.removeOverlays(Mill_Valley);
map.removeOverlays(Novato);
map.removeOverlays(San_Anselmo);
map.removeOverlays(San_Rafael);
map.removeOverlays(Sausalito);
map.removeOverlays(Tiburon);
map.addOverlays(Bolinas);
centerByArray(Bolinas, false, false);
cntMarker += Bolinas.length;
map.addOverlays(Corte_Madera);
centerByArray(Corte_Madera, false, false);
cntMarker += Corte_Madera.length;
map.addOverlays(Fairfax);
centerByArray(Fairfax, false, false);
cntMarker += Fairfax.length;
map.addOverlays(Larkspur);
centerByArray(Larkspur, false, false);
cntMarker += Larkspur.length;
map.addOverlays(Marin_City);
centerByArray(Marin_City, false, false);
cntMarker += Marin_City.length;
map.addOverlays(Mill_Valley);
centerByArray(Mill_Valley, false, false);
cntMarker += Mill_Valley.length;
map.addOverlays(Novato);
centerByArray(Novato, false, false);
cntMarker += Novato.length;
map.addOverlays(San_Anselmo);
centerByArray(San_Anselmo, false, false);
cntMarker += San_Anselmo.length;
map.addOverlays(San_Rafael);
centerByArray(San_Rafael, false, false);
cntMarker += San_Rafael.length;
map.addOverlays(Sausalito);
centerByArray(Sausalito, false, false);
cntMarker += Sausalito.length;
map.addOverlays(Tiburon);
centerByArray(Tiburon, false, false);
cntMarker += Tiburon.length;
centerByArray(Corte_Madera,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=1&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;
}