function addMarkers(){
mySelect = document.getElementById('selection');
Arleta = [];Downey = [];San_Leandro = [];Imperial = [];Citrus_Heights = [];Gardena = [];Watsonville = [];Clearlake = [];Stockton = [];Los_Angeles = [];Montclair = [];Sacramento = [];San_Diego = [];Arroyo_Grande = [];Whittier = [];Redwood_City = [];Riverdale = [];Chula_Vista = [];Delano = [];San_Clemente = [];San_Jose = [];Tracy = [];Wilmington = [];mySelect.options[mySelect.options.length] = new Option("Arleta schools",'all=Arleta');
mySelect.options[mySelect.options.length] = new Option("Arroyo Grande schools",'all=Arroyo_Grande');
mySelect.options[mySelect.options.length] = new Option("Chula Vista schools",'all=Chula_Vista');
mySelect.options[mySelect.options.length] = new Option("Citrus Heights schools",'all=Citrus_Heights');
mySelect.options[mySelect.options.length] = new Option("Clearlake schools",'all=Clearlake');
mySelect.options[mySelect.options.length] = new Option("Delano schools",'all=Delano');
mySelect.options[mySelect.options.length] = new Option("Downey schools",'all=Downey');
mySelect.options[mySelect.options.length] = new Option("Gardena schools",'all=Gardena');
mySelect.options[mySelect.options.length] = new Option("Imperial schools",'all=Imperial');
mySelect.options[mySelect.options.length] = new Option("Los Angeles schools",'all=Los_Angeles');
mySelect.options[mySelect.options.length] = new Option("Montclair schools",'all=Montclair');
mySelect.options[mySelect.options.length] = new Option("Redwood City schools",'all=Redwood_City');
mySelect.options[mySelect.options.length] = new Option("Riverdale schools",'all=Riverdale');
mySelect.options[mySelect.options.length] = new Option("Sacramento schools",'all=Sacramento');
mySelect.options[mySelect.options.length] = new Option("San Clemente schools",'all=San_Clemente');
mySelect.options[mySelect.options.length] = new Option("San Diego schools",'all=San_Diego');
mySelect.options[mySelect.options.length] = new Option("San Jose schools",'all=San_Jose');
mySelect.options[mySelect.options.length] = new Option("San Leandro schools",'all=San_Leandro');
mySelect.options[mySelect.options.length] = new Option("Stockton schools",'all=Stockton');
mySelect.options[mySelect.options.length] = new Option("Tracy schools",'all=Tracy');
mySelect.options[mySelect.options.length] = new Option("Watsonville schools",'all=Watsonville');
mySelect.options[mySelect.options.length] = new Option("Whittier schools",'all=Whittier');
mySelect.options[mySelect.options.length] = new Option("Wilmington schools",'all=Wilmington');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Arleta[Arleta.length] = createMarker(new GPoint(-118.43442600,34.23612700),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Areeta Christian School",'Arleta=' + Arleta.length);
Downey[Downey.length] = createMarker(new GPoint(-118.11651500,33.91538100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Calvary Chapel Christian School",'Downey=' + Downey.length);
San_Leandro[San_Leandro.length] = createMarker(new GPoint(-122.13526600,37.68652000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Community Christian School",'San_Leandro=' + San_Leandro.length);
Imperial[Imperial.length] = createMarker(new GPoint(-115.56855600,32.84515400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Faith Academy",'Imperial=' + Imperial.length);
Citrus_Heights[Citrus_Heights.length] = createMarker(new GPoint(-121.27943100,38.68938800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Faith Christian Academy",'Citrus_Heights=' + Citrus_Heights.length);
Gardena[Gardena.length] = createMarker(new GPoint(-118.30171400,33.86575100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Gardena Valley Christian School",'Gardena=' + Gardena.length);
Watsonville[Watsonville.length] = createMarker(new GPoint(-121.77663000,36.93061400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Green Valley Christian School",'Watsonville=' + Watsonville.length);
Clearlake[Clearlake.length] = createMarker(new GPoint(-122.62710000,38.95070000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Hilltop Christian School",'Clearlake=' + Clearlake.length);
Stockton[Stockton.length] = createMarker(new GPoint(-121.29072400,37.95361900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Inner City Christian Academy",'Stockton=' + Stockton.length);
Los_Angeles[Los_Angeles.length] = createMarker(new GPoint(-118.26939200,34.07418100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("L.a. Dream Center Academy",'Los_Angeles=' + Los_Angeles.length);
Los_Angeles[Los_Angeles.length] = createMarker(new GPoint(-118.27959100,34.05680500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("La Western School",'Los_Angeles=' + Los_Angeles.length);
Montclair[Montclair.length] = createMarker(new GPoint(-117.69850000,34.07170000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Montclair Christian Elementary School",'Montclair=' + Montclair.length);
Sacramento[Sacramento.length] = createMarker(new GPoint(-121.39064200,38.49340100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Noah's Ark Christian Academy",'Sacramento=' + Sacramento.length);
San_Diego[San_Diego.length] = createMarker(new GPoint(-117.13089000,32.74727500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("North Park Christian School",'San_Diego=' + San_Diego.length);
Arroyo_Grande[Arroyo_Grande.length] = createMarker(new GPoint(-120.57564500,35.11593700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Pacific Coast Christian School",'Arroyo_Grande=' + Arroyo_Grande.length);
Whittier[Whittier.length] = createMarker(new GPoint(-118.05415100,33.97667900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Palm View Christian Schools (PK-8)",'Whittier=' + Whittier.length);
Redwood_City[Redwood_City.length] = createMarker(new GPoint(-122.22463200,37.48363100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Peninsula Christian School",'Redwood_City=' + Redwood_City.length);
Whittier[Whittier.length] = createMarker(new GPoint(-118.04912200,33.98919200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Plymouth Christian School",'Whittier=' + Whittier.length);
Riverdale[Riverdale.length] = createMarker(new GPoint(-119.89160900,36.43081000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Riverdale Christian Academy",'Riverdale=' + Riverdale.length);
Chula_Vista[Chula_Vista.length] = createMarker(new GPoint(-117.08639400,32.64726200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("South Bay Christian Academy",'Chula_Vista=' + Chula_Vista.length);
Delano[Delano.length] = createMarker(new GPoint(-119.22407400,35.76856300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("South San Joaquin Christian School",'Delano=' + Delano.length);
San_Clemente[San_Clemente.length] = createMarker(new GPoint(-117.61750700,33.42933900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Michael's Academy",'San_Clemente=' + San_Clemente.length);
San_Jose[San_Jose.length] = createMarker(new GPoint(-121.82735600,37.27388300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Valley Christian Junior High School",'San_Jose=' + San_Jose.length);
Redwood_City[Redwood_City.length] = createMarker(new GPoint(-122.23610500,37.47568300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("West Bay Christian Academy",'Redwood_City=' + Redwood_City.length);
Tracy[Tracy.length] = createMarker(new GPoint(-121.44868400,37.73866300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("West Valley Christian Academy",'Tracy=' + Tracy.length);
Wilmington[Wilmington.length] = createMarker(new GPoint(-118.26381200,33.79991300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Wilmington Christian School",'Wilmington=' + Wilmington.length);
map.removeOverlays(Arleta);
map.removeOverlays(Arroyo_Grande);
map.removeOverlays(Chula_Vista);
map.removeOverlays(Citrus_Heights);
map.removeOverlays(Clearlake);
map.removeOverlays(Delano);
map.removeOverlays(Downey);
map.removeOverlays(Gardena);
map.removeOverlays(Imperial);
map.removeOverlays(Los_Angeles);
map.removeOverlays(Montclair);
map.removeOverlays(Redwood_City);
map.removeOverlays(Riverdale);
map.removeOverlays(Sacramento);
map.removeOverlays(San_Clemente);
map.removeOverlays(San_Diego);
map.removeOverlays(San_Jose);
map.removeOverlays(San_Leandro);
map.removeOverlays(Stockton);
map.removeOverlays(Tracy);
map.removeOverlays(Watsonville);
map.removeOverlays(Whittier);
map.removeOverlays(Wilmington);
setTimeout(function(){map.addOverlays(Arleta)},1000);
setTimeout(function(){map.addOverlays(Arroyo_Grande)},1000);
setTimeout(function(){map.addOverlays(Chula_Vista)},1000);
setTimeout(function(){map.addOverlays(Citrus_Heights)},1000);
setTimeout(function(){map.addOverlays(Clearlake)},1000);
setTimeout(function(){map.addOverlays(Delano)},1000);
setTimeout(function(){map.addOverlays(Downey)},1000);
setTimeout(function(){map.addOverlays(Gardena)},1000);
setTimeout(function(){map.addOverlays(Imperial)},1000);
setTimeout(function(){map.addOverlays(Los_Angeles)},1000);
setTimeout(function(){map.addOverlays(Montclair)},1000);
setTimeout(function(){map.addOverlays(Redwood_City)},1000);
setTimeout(function(){map.addOverlays(Riverdale)},1000);
setTimeout(function(){map.addOverlays(Sacramento)},1000);
setTimeout(function(){map.addOverlays(San_Clemente)},1000);
setTimeout(function(){map.addOverlays(San_Diego)},1000);
setTimeout(function(){map.addOverlays(San_Jose)},1000);
setTimeout(function(){map.addOverlays(San_Leandro)},1000);
setTimeout(function(){map.addOverlays(Stockton)},1000);
setTimeout(function(){map.addOverlays(Tracy)},1000);
setTimeout(function(){map.addOverlays(Watsonville)},1000);
setTimeout(function(){map.addOverlays(Whittier)},1000);
setTimeout(function(){map.addOverlays(Wilmington)},1000);
maxLng = -115.56855600;
maxLat = 38.95070000;
minLng = -122.62710000;
minLat = 32.64726200;
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(Arleta);
map.removeOverlays(Arroyo_Grande);
map.removeOverlays(Chula_Vista);
map.removeOverlays(Citrus_Heights);
map.removeOverlays(Clearlake);
map.removeOverlays(Delano);
map.removeOverlays(Downey);
map.removeOverlays(Gardena);
map.removeOverlays(Imperial);
map.removeOverlays(Los_Angeles);
map.removeOverlays(Montclair);
map.removeOverlays(Redwood_City);
map.removeOverlays(Riverdale);
map.removeOverlays(Sacramento);
map.removeOverlays(San_Clemente);
map.removeOverlays(San_Diego);
map.removeOverlays(San_Jose);
map.removeOverlays(San_Leandro);
map.removeOverlays(Stockton);
map.removeOverlays(Tracy);
map.removeOverlays(Watsonville);
map.removeOverlays(Whittier);
map.removeOverlays(Wilmington);
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(Arleta);map.removeOverlays(Arleta);
map.removeOverlays(Arroyo_Grande);
map.removeOverlays(Chula_Vista);
map.removeOverlays(Citrus_Heights);
map.removeOverlays(Clearlake);
map.removeOverlays(Delano);
map.removeOverlays(Downey);
map.removeOverlays(Gardena);
map.removeOverlays(Imperial);
map.removeOverlays(Los_Angeles);
map.removeOverlays(Montclair);
map.removeOverlays(Redwood_City);
map.removeOverlays(Riverdale);
map.removeOverlays(Sacramento);
map.removeOverlays(San_Clemente);
map.removeOverlays(San_Diego);
map.removeOverlays(San_Jose);
map.removeOverlays(San_Leandro);
map.removeOverlays(Stockton);
map.removeOverlays(Tracy);
map.removeOverlays(Watsonville);
map.removeOverlays(Whittier);
map.removeOverlays(Wilmington);
map.addOverlays(Arleta);
centerByArray(Arleta, false, false);
cntMarker += Arleta.length;
map.addOverlays(Arroyo_Grande);
centerByArray(Arroyo_Grande, false, false);
cntMarker += Arroyo_Grande.length;
map.addOverlays(Chula_Vista);
centerByArray(Chula_Vista, false, false);
cntMarker += Chula_Vista.length;
map.addOverlays(Citrus_Heights);
centerByArray(Citrus_Heights, false, false);
cntMarker += Citrus_Heights.length;
map.addOverlays(Clearlake);
centerByArray(Clearlake, false, false);
cntMarker += Clearlake.length;
map.addOverlays(Delano);
centerByArray(Delano, false, false);
cntMarker += Delano.length;
map.addOverlays(Downey);
centerByArray(Downey, false, false);
cntMarker += Downey.length;
map.addOverlays(Gardena);
centerByArray(Gardena, false, false);
cntMarker += Gardena.length;
map.addOverlays(Imperial);
centerByArray(Imperial, false, false);
cntMarker += Imperial.length;
map.addOverlays(Los_Angeles);
centerByArray(Los_Angeles, false, false);
cntMarker += Los_Angeles.length;
map.addOverlays(Montclair);
centerByArray(Montclair, false, false);
cntMarker += Montclair.length;
map.addOverlays(Redwood_City);
centerByArray(Redwood_City, false, false);
cntMarker += Redwood_City.length;
map.addOverlays(Riverdale);
centerByArray(Riverdale, false, false);
cntMarker += Riverdale.length;
map.addOverlays(Sacramento);
centerByArray(Sacramento, false, false);
cntMarker += Sacramento.length;
map.addOverlays(San_Clemente);
centerByArray(San_Clemente, false, false);
cntMarker += San_Clemente.length;
map.addOverlays(San_Diego);
centerByArray(San_Diego, false, false);
cntMarker += San_Diego.length;
map.addOverlays(San_Jose);
centerByArray(San_Jose, false, false);
cntMarker += San_Jose.length;
map.addOverlays(San_Leandro);
centerByArray(San_Leandro, false, false);
cntMarker += San_Leandro.length;
map.addOverlays(Stockton);
centerByArray(Stockton, false, false);
cntMarker += Stockton.length;
map.addOverlays(Tracy);
centerByArray(Tracy, false, false);
cntMarker += Tracy.length;
map.addOverlays(Watsonville);
centerByArray(Watsonville, false, false);
cntMarker += Watsonville.length;
map.addOverlays(Whittier);
centerByArray(Whittier, false, false);
cntMarker += Whittier.length;
map.addOverlays(Wilmington);
centerByArray(Wilmington, false, false);
cntMarker += Wilmington.length;
centerByArray(Arleta,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///1318,1116,2398,1538,2210,2609,3586,4285,1818,33791,2305,1318,3347,1116,2081,2398,3836,1538,2210,2071,2609,4645,2927,33792,4622,3586,4822,4285,4823,4534,1818,33791,4633,2305,3370,3469,4680,/all');
//window.open('/map.php?type=2&schools=1318,1116,2398,1538,2210,2609,3586,4285,1818,33791,2305,1318,3347,1116,2081,2398,3836,1538,2210,2071,2609,4645,2927,33792,4622,3586,4822,4285,4823,4534,1818,33791,4633,2305,3370,3469,4680,&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;
}