function addMarkers(){
mySelect = document.getElementById('selection');
Forestville = [];Santa_Rosa = [];Rohnert_Park = [];Petaluma = [];Sonoma = [];Sebastopol = [];Novato = [];Graton = [];Cotati = [];Penngrove = [];Healdsburg = [];Occidental = [];mySelect.options[mySelect.options.length] = new Option("Cotati schools",'all=Cotati');
mySelect.options[mySelect.options.length] = new Option("Forestville schools",'all=Forestville');
mySelect.options[mySelect.options.length] = new Option("Graton schools",'all=Graton');
mySelect.options[mySelect.options.length] = new Option("Healdsburg schools",'all=Healdsburg');
mySelect.options[mySelect.options.length] = new Option("Novato schools",'all=Novato');
mySelect.options[mySelect.options.length] = new Option("Occidental schools",'all=Occidental');
mySelect.options[mySelect.options.length] = new Option("Penngrove schools",'all=Penngrove');
mySelect.options[mySelect.options.length] = new Option("Petaluma schools",'all=Petaluma');
mySelect.options[mySelect.options.length] = new Option("Rohnert Park schools",'all=Rohnert_Park');
mySelect.options[mySelect.options.length] = new Option("Santa Rosa schools",'all=Santa_Rosa');
mySelect.options[mySelect.options.length] = new Option("Sebastopol schools",'all=Sebastopol');
mySelect.options[mySelect.options.length] = new Option("Sonoma schools",'all=Sonoma');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Forestville[Forestville.length] = createMarker(new GPoint(-122.89168900,38.47528100),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("American Christian Academy Ext",'Forestville=' + Forestville.length);
Santa_Rosa[Santa_Rosa.length] = createMarker(new GPoint(-122.72863300,38.46731100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Anova Center For Education",'Santa_Rosa=' + Santa_Rosa.length);
Rohnert_Park[Rohnert_Park.length] = createMarker(new GPoint(-122.69401600,38.34651700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Berean Baptist Christian Academy",'Rohnert_Park=' + Rohnert_Park.length);
Santa_Rosa[Santa_Rosa.length] = createMarker(new GPoint(-122.57949900,38.43354600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bridges Of Sonoma",'Santa_Rosa=' + Santa_Rosa.length);
Santa_Rosa[Santa_Rosa.length] = createMarker(new GPoint(-122.74182400,38.49335300),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Cardinal Newman High School",'Santa_Rosa=' + Santa_Rosa.length);
Petaluma[Petaluma.length] = createMarker(new GPoint(-122.71262600,38.25761900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Family Life Center",'Petaluma=' + Petaluma.length);
Sonoma[Sonoma.length] = createMarker(new GPoint(-122.47200000,38.28940000),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Hanna Boys Center School",'Sonoma=' + Sonoma.length);
Sebastopol[Sebastopol.length] = createMarker(new GPoint(-122.82270000,38.40220000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Journey High School",'Sebastopol=' + Sebastopol.length);
Santa_Rosa[Santa_Rosa.length] = createMarker(new GPoint(-122.73827400,38.47341000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lattice Educational Services",'Santa_Rosa=' + Santa_Rosa.length);
Santa_Rosa[Santa_Rosa.length] = createMarker(new GPoint(-122.74169000,38.38829000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("New Directions Adolescent Services",'Santa_Rosa=' + Santa_Rosa.length);
Santa_Rosa[Santa_Rosa.length] = createMarker(new GPoint(-122.72310200,38.39855200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("New Hope Baptist Church",'Santa_Rosa=' + Santa_Rosa.length);
Santa_Rosa[Santa_Rosa.length] = createMarker(new GPoint(-122.70963200,38.44149600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("New Horizon School & Learning Center",'Santa_Rosa=' + Santa_Rosa.length);
Sonoma[Sonoma.length] = createMarker(new GPoint(-122.48520200,38.31669300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("New Song/Olive Tree School",'Sonoma=' + Sonoma.length);
Sebastopol[Sebastopol.length] = createMarker(new GPoint(-122.90867400,38.44356500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Nonesuch School",'Sebastopol=' + Sebastopol.length);
Novato[Novato.length] = createMarker(new GPoint(-122.60489300,38.11016100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("North Bay Academy of Communication and Design",'Novato=' + Novato.length);
Santa_Rosa[Santa_Rosa.length] = createMarker(new GPoint(-122.74232400,38.46800600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("North Valley School",'Santa_Rosa=' + Santa_Rosa.length);
Graton[Graton.length] = createMarker(new GPoint(-122.84320000,38.39420000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Pacific Christian Academy",'Graton=' + Graton.length);
Santa_Rosa[Santa_Rosa.length] = createMarker(new GPoint(-122.75878300,38.44263500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Paideia Educational Heritage",'Santa_Rosa=' + Santa_Rosa.length);
Sebastopol[Sebastopol.length] = createMarker(new GPoint(-122.86766200,38.42258500),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Plumfield Academy",'Sebastopol=' + Sebastopol.length);
Cotati[Cotati.length] = createMarker(new GPoint(-122.70457100,38.32428600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Rancho Bodega School",'Cotati=' + Cotati.length);
Santa_Rosa[Santa_Rosa.length] = createMarker(new GPoint(-122.73852700,38.50143500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Redwood Adventist Academy",'Santa_Rosa=' + Santa_Rosa.length);
Santa_Rosa[Santa_Rosa.length] = createMarker(new GPoint(-122.70960000,38.43990000),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Redwood Isititute For Designed",'Santa_Rosa=' + Santa_Rosa.length);
Penngrove[Penngrove.length] = createMarker(new GPoint(-122.65688800,38.31419500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Redwood Montessori School",'Penngrove=' + Penngrove.length);
Santa_Rosa[Santa_Rosa.length] = createMarker(new GPoint(-122.67426500,38.48229800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Rincon Valley Christian School",'Santa_Rosa=' + Santa_Rosa.length);
Healdsburg[Healdsburg.length] = createMarker(new GPoint(-122.83593200,38.62947200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Rio Lindo Adventist Academy",'Healdsburg=' + Healdsburg.length);
Occidental[Occidental.length] = createMarker(new GPoint(-122.99310000,38.40890000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Russian River Christian Academy",'Occidental=' + Occidental.length);
Petaluma[Petaluma.length] = createMarker(new GPoint(-122.64968300,38.24332100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Vincent De Paul High School",'Petaluma=' + Petaluma.length);
Santa_Rosa[Santa_Rosa.length] = createMarker(new GPoint(-122.75120900,38.49623800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Santa Rosa Christian School",'Santa_Rosa=' + Santa_Rosa.length);
Rohnert_Park[Rohnert_Park.length] = createMarker(new GPoint(-122.70745500,38.33589800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sierra School Of Sonoma County",'Rohnert_Park=' + Rohnert_Park.length);
Sonoma[Sonoma.length] = createMarker(new GPoint(-122.46622700,38.29288900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Solo Quest Learning Center",'Sonoma=' + Sonoma.length);
Santa_Rosa[Santa_Rosa.length] = createMarker(new GPoint(-122.68957900,38.41811000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sonoma Academy",'Santa_Rosa=' + Santa_Rosa.length);
Sonoma[Sonoma.length] = createMarker(new GPoint(-122.45267300,38.29152000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sonoma Valley Academy",'Sonoma=' + Sonoma.length);
Santa_Rosa[Santa_Rosa.length] = createMarker(new GPoint(-122.73655000,38.42627600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Michael's Orthodox School",'Santa_Rosa=' + Santa_Rosa.length);
Santa_Rosa[Santa_Rosa.length] = createMarker(new GPoint(-122.71356200,38.44213300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Stuart Preparatory School",'Santa_Rosa=' + Santa_Rosa.length);
Santa_Rosa[Santa_Rosa.length] = createMarker(new GPoint(-122.80690800,38.44405900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Summerfield Waldorf School",'Santa_Rosa=' + Santa_Rosa.length);
Santa_Rosa[Santa_Rosa.length] = createMarker(new GPoint(-122.74182400,38.49426400),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Ursuline High School",'Santa_Rosa=' + Santa_Rosa.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(Cotati);
map.removeOverlays(Forestville);
map.removeOverlays(Graton);
map.removeOverlays(Healdsburg);
map.removeOverlays(Novato);
map.removeOverlays(Occidental);
map.removeOverlays(Penngrove);
map.removeOverlays(Petaluma);
map.removeOverlays(Rohnert_Park);
map.removeOverlays(Santa_Rosa);
map.removeOverlays(Sebastopol);
map.removeOverlays(Sonoma);
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(Forestville);map.removeOverlays(Cotati);
map.removeOverlays(Forestville);
map.removeOverlays(Graton);
map.removeOverlays(Healdsburg);
map.removeOverlays(Novato);
map.removeOverlays(Occidental);
map.removeOverlays(Penngrove);
map.removeOverlays(Petaluma);
map.removeOverlays(Rohnert_Park);
map.removeOverlays(Santa_Rosa);
map.removeOverlays(Sebastopol);
map.removeOverlays(Sonoma);
map.addOverlays(Cotati);
centerByArray(Cotati, false, false);
cntMarker += Cotati.length;
map.addOverlays(Forestville);
centerByArray(Forestville, false, false);
cntMarker += Forestville.length;
map.addOverlays(Graton);
centerByArray(Graton, false, false);
cntMarker += Graton.length;
map.addOverlays(Healdsburg);
centerByArray(Healdsburg, false, false);
cntMarker += Healdsburg.length;
map.addOverlays(Novato);
centerByArray(Novato, false, false);
cntMarker += Novato.length;
map.addOverlays(Occidental);
centerByArray(Occidental, false, false);
cntMarker += Occidental.length;
map.addOverlays(Penngrove);
centerByArray(Penngrove, false, false);
cntMarker += Penngrove.length;
map.addOverlays(Petaluma);
centerByArray(Petaluma, false, false);
cntMarker += Petaluma.length;
map.addOverlays(Rohnert_Park);
centerByArray(Rohnert_Park, false, false);
cntMarker += Rohnert_Park.length;
map.addOverlays(Santa_Rosa);
centerByArray(Santa_Rosa, false, false);
cntMarker += Santa_Rosa.length;
map.addOverlays(Sebastopol);
centerByArray(Sebastopol, false, false);
cntMarker += Sebastopol.length;
map.addOverlays(Sonoma);
centerByArray(Sonoma, false, false);
cntMarker += Sonoma.length;
centerByArray(Forestville,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;
}