function addMarkers(){
mySelect = document.getElementById('selection');
Danville = [];Lafayette = [];Walnut_Creek = [];El_Sobrante = [];Concord = [];Pittsburg = [];Richmond = [];Antioch = [];Brentwood = [];Orinda = [];Martinez = [];Moraga = [];Pleasant_Hill = [];San_Pablo = [];mySelect.options[mySelect.options.length] = new Option("Antioch schools",'all=Antioch');
mySelect.options[mySelect.options.length] = new Option("Brentwood schools",'all=Brentwood');
mySelect.options[mySelect.options.length] = new Option("Concord schools",'all=Concord');
mySelect.options[mySelect.options.length] = new Option("Danville schools",'all=Danville');
mySelect.options[mySelect.options.length] = new Option("El Sobrante schools",'all=El_Sobrante');
mySelect.options[mySelect.options.length] = new Option("Lafayette schools",'all=Lafayette');
mySelect.options[mySelect.options.length] = new Option("Martinez schools",'all=Martinez');
mySelect.options[mySelect.options.length] = new Option("Moraga schools",'all=Moraga');
mySelect.options[mySelect.options.length] = new Option("Orinda schools",'all=Orinda');
mySelect.options[mySelect.options.length] = new Option("Pittsburg schools",'all=Pittsburg');
mySelect.options[mySelect.options.length] = new Option("Pleasant Hill schools",'all=Pleasant_Hill');
mySelect.options[mySelect.options.length] = new Option("Richmond schools",'all=Richmond');
mySelect.options[mySelect.options.length] = new Option("San Pablo schools",'all=San_Pablo');
mySelect.options[mySelect.options.length] = new Option("Walnut Creek schools",'all=Walnut_Creek');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Danville[Danville.length] = createMarker(new GPoint(-121.95170500,37.83321900),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Athenian School",'Danville=' + Danville.length);
Lafayette[Lafayette.length] = createMarker(new GPoint(-122.15142400,37.89280900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bentley School",'Lafayette=' + Lafayette.length);
Walnut_Creek[Walnut_Creek.length] = createMarker(new GPoint(-122.03289100,37.91410400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Berean Christian High School",'Walnut_Creek=' + Walnut_Creek.length);
El_Sobrante[El_Sobrante.length] = createMarker(new GPoint(-122.29823100,37.97706700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bethel Christian Academy",'El_Sobrante=' + El_Sobrante.length);
El_Sobrante[El_Sobrante.length] = createMarker(new GPoint(-122.29265900,37.96326700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Calvary Christian Academy",'El_Sobrante=' + El_Sobrante.length);
Concord[Concord.length] = createMarker(new GPoint(-122.03233600,37.93332300),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Carondelet High School",'Concord=' + Concord.length);
Pittsburg[Pittsburg.length] = createMarker(new GPoint(-121.87526800,38.00321000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Christian Center School",'Pittsburg=' + Pittsburg.length);
Richmond[Richmond.length] = createMarker(new GPoint(-122.34114500,37.97512900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Community Christian Academy",'Richmond=' + Richmond.length);
Concord[Concord.length] = createMarker(new GPoint(-122.04064500,37.99720600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Concord Christian School",'Concord=' + Concord.length);
Walnut_Creek[Walnut_Creek.length] = createMarker(new GPoint(-122.07827300,37.92205200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Contra Costa Christian School",'Walnut_Creek=' + Walnut_Creek.length);
Antioch[Antioch.length] = createMarker(new GPoint(-121.77922400,38.00503700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cornerstone Christian School",'Antioch=' + Antioch.length);
Concord[Concord.length] = createMarker(new GPoint(-122.03200700,37.93342700),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("De La Salle High School",'Concord=' + Concord.length);
Antioch[Antioch.length] = createMarker(new GPoint(-121.83783500,38.00106100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Delta Christian Jr/sr High School",'Antioch=' + Antioch.length);
Concord[Concord.length] = createMarker(new GPoint(-122.01150000,37.98350000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Diablo Valley School",'Concord=' + Concord.length);
Walnut_Creek[Walnut_Creek.length] = createMarker(new GPoint(-122.06656600,37.88903700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Dorris-Eaton School",'Walnut_Creek=' + Walnut_Creek.length);
El_Sobrante[El_Sobrante.length] = createMarker(new GPoint(-122.29656200,37.98052200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("El Sobrante Christian School -",'El_Sobrante=' + El_Sobrante.length);
Richmond[Richmond.length] = createMarker(new GPoint(-122.34515300,37.93319500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Family Christian Academy",'Richmond=' + Richmond.length);
Brentwood[Brentwood.length] = createMarker(new GPoint(-121.73716800,37.95968800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Gateway Christian",'Brentwood=' + Brentwood.length);
Antioch[Antioch.length] = createMarker(new GPoint(-121.75398900,37.97526000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Gateway Christian School",'Antioch=' + Antioch.length);
Antioch[Antioch.length] = createMarker(new GPoint(-121.75096800,37.94876000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Heritage Baptist Academy",'Antioch=' + Antioch.length);
Antioch[Antioch.length] = createMarker(new GPoint(-121.78566800,37.96816700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Hilltop Christian School",'Antioch=' + Antioch.length);
Orinda[Orinda.length] = createMarker(new GPoint(-122.18893400,37.88486600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Holden High School",'Orinda=' + Orinda.length);
Antioch[Antioch.length] = createMarker(new GPoint(-122.07400000,37.95370000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("La Cheim School",'Antioch=' + Antioch.length);
Richmond[Richmond.length] = createMarker(new GPoint(-122.33391000,37.97543900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("La Cheim School-richmond",'Richmond=' + Richmond.length);
Richmond[Richmond.length] = createMarker(new GPoint(-122.36152800,37.93556300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("New Faith Christian Academy",'Richmond=' + Richmond.length);
Martinez[Martinez.length] = createMarker(new GPoint(-122.10162500,38.00817300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("New Vistas Christian School",'Martinez=' + Martinez.length);
Orinda[Orinda.length] = createMarker(new GPoint(-122.18460800,37.88261900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Orinda Academy",'Orinda=' + Orinda.length);
Moraga[Moraga.length] = createMarker(new GPoint(-122.12818300,37.86117000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Orion Academy",'Moraga=' + Moraga.length);
Pleasant_Hill[Pleasant_Hill.length] = createMarker(new GPoint(-122.08870800,37.94766300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Pleasant Hill Adventist Academy",'Pleasant_Hill=' + Pleasant_Hill.length);
Richmond[Richmond.length] = createMarker(new GPoint(-122.35593900,37.93157400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Richmond Educ Learning Center",'Richmond=' + Richmond.length);
Moraga[Moraga.length] = createMarker(new GPoint(-122.13248700,37.83335600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Saklan Valley School",'Moraga=' + Moraga.length);
Richmond[Richmond.length] = createMarker(new GPoint(-122.33921100,37.95287200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Salesian High School",'Richmond=' + Richmond.length);
Concord[Concord.length] = createMarker(new GPoint(-121.96191000,37.53501800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Seneca Center",'Concord=' + Concord.length);
Pittsburg[Pittsburg.length] = createMarker(new GPoint(-121.89044100,38.01218000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Spectrum Center",'Pittsburg=' + Pittsburg.length);
Concord[Concord.length] = createMarker(new GPoint(-122.03562300,37.95038500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Spectrum Center Valley School",'Concord=' + Concord.length);
San_Pablo[San_Pablo.length] = createMarker(new GPoint(-122.32425300,37.99820500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Spectrum Center-tara Hills",'San_Pablo=' + San_Pablo.length);
Lafayette[Lafayette.length] = createMarker(new GPoint(-122.10295100,37.89226800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Springstone, The",'Lafayette=' + Lafayette.length);
San_Pablo[San_Pablo.length] = createMarker(new GPoint(-122.31649200,37.99689500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Tara Hills Christian Academy",'San_Pablo=' + San_Pablo.length);
Brentwood[Brentwood.length] = createMarker(new GPoint(-121.69852500,37.93538700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Tobinworld Ii",'Brentwood=' + Brentwood.length);
Walnut_Creek[Walnut_Creek.length] = createMarker(new GPoint(-122.07031300,37.91053300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Walnut Creek Christian Academy",'Walnut_Creek=' + Walnut_Creek.length);
El_Sobrante[El_Sobrante.length] = createMarker(new GPoint(-122.31354200,37.96509200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("West County Christian Academy",'El_Sobrante=' + El_Sobrante.length);
Concord[Concord.length] = createMarker(new GPoint(-121.97534500,37.95749900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Wood Rose Preparatory",'Concord=' + Concord.length);
Antioch[Antioch.length] = createMarker(new GPoint(-121.82640300,38.00428600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Zion Christian Academy",'Antioch=' + Antioch.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(Antioch);
map.removeOverlays(Brentwood);
map.removeOverlays(Concord);
map.removeOverlays(Danville);
map.removeOverlays(El_Sobrante);
map.removeOverlays(Lafayette);
map.removeOverlays(Martinez);
map.removeOverlays(Moraga);
map.removeOverlays(Orinda);
map.removeOverlays(Pittsburg);
map.removeOverlays(Pleasant_Hill);
map.removeOverlays(Richmond);
map.removeOverlays(San_Pablo);
map.removeOverlays(Walnut_Creek);
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(Danville);map.removeOverlays(Antioch);
map.removeOverlays(Brentwood);
map.removeOverlays(Concord);
map.removeOverlays(Danville);
map.removeOverlays(El_Sobrante);
map.removeOverlays(Lafayette);
map.removeOverlays(Martinez);
map.removeOverlays(Moraga);
map.removeOverlays(Orinda);
map.removeOverlays(Pittsburg);
map.removeOverlays(Pleasant_Hill);
map.removeOverlays(Richmond);
map.removeOverlays(San_Pablo);
map.removeOverlays(Walnut_Creek);
map.addOverlays(Antioch);
centerByArray(Antioch, false, false);
cntMarker += Antioch.length;
map.addOverlays(Brentwood);
centerByArray(Brentwood, false, false);
cntMarker += Brentwood.length;
map.addOverlays(Concord);
centerByArray(Concord, false, false);
cntMarker += Concord.length;
map.addOverlays(Danville);
centerByArray(Danville, false, false);
cntMarker += Danville.length;
map.addOverlays(El_Sobrante);
centerByArray(El_Sobrante, false, false);
cntMarker += El_Sobrante.length;
map.addOverlays(Lafayette);
centerByArray(Lafayette, false, false);
cntMarker += Lafayette.length;
map.addOverlays(Martinez);
centerByArray(Martinez, false, false);
cntMarker += Martinez.length;
map.addOverlays(Moraga);
centerByArray(Moraga, false, false);
cntMarker += Moraga.length;
map.addOverlays(Orinda);
centerByArray(Orinda, false, false);
cntMarker += Orinda.length;
map.addOverlays(Pittsburg);
centerByArray(Pittsburg, false, false);
cntMarker += Pittsburg.length;
map.addOverlays(Pleasant_Hill);
centerByArray(Pleasant_Hill, false, false);
cntMarker += Pleasant_Hill.length;
map.addOverlays(Richmond);
centerByArray(Richmond, false, false);
cntMarker += Richmond.length;
map.addOverlays(San_Pablo);
centerByArray(San_Pablo, false, false);
cntMarker += San_Pablo.length;
map.addOverlays(Walnut_Creek);
centerByArray(Walnut_Creek, false, false);
cntMarker += Walnut_Creek.length;
centerByArray(Danville,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;
}