function addMarkers(){
mySelect = document.getElementById('selection');
Los_Angeles = [];Sacramento = [];Hawthorne = [];Mission_Viejo = [];Bell_Gardens = [];Fountain_Valley = [];Pomona = [];Stockton = [];Oakland = [];Sunnyvale = [];Santa_Clara = [];Granada_Hills = [];Riverside = [];Anaheim = [];San_Diego = [];Chatsworth = [];Irvine = [];Pasadena = [];Hayward = [];Garden_Grove = [];Fremont = [];West_Covina = [];Clovis = [];mySelect.options[mySelect.options.length] = new Option("Anaheim schools",'all=Anaheim');
mySelect.options[mySelect.options.length] = new Option("Bell Gardens schools",'all=Bell_Gardens');
mySelect.options[mySelect.options.length] = new Option("Chatsworth schools",'all=Chatsworth');
mySelect.options[mySelect.options.length] = new Option("Clovis schools",'all=Clovis');
mySelect.options[mySelect.options.length] = new Option("Fountain Valley schools",'all=Fountain_Valley');
mySelect.options[mySelect.options.length] = new Option("Fremont schools",'all=Fremont');
mySelect.options[mySelect.options.length] = new Option("Garden Grove schools",'all=Garden_Grove');
mySelect.options[mySelect.options.length] = new Option("Granada Hills schools",'all=Granada_Hills');
mySelect.options[mySelect.options.length] = new Option("Hawthorne schools",'all=Hawthorne');
mySelect.options[mySelect.options.length] = new Option("Hayward schools",'all=Hayward');
mySelect.options[mySelect.options.length] = new Option("Irvine schools",'all=Irvine');
mySelect.options[mySelect.options.length] = new Option("Los Angeles schools",'all=Los_Angeles');
mySelect.options[mySelect.options.length] = new Option("Mission Viejo schools",'all=Mission_Viejo');
mySelect.options[mySelect.options.length] = new Option("Oakland schools",'all=Oakland');
mySelect.options[mySelect.options.length] = new Option("Pasadena schools",'all=Pasadena');
mySelect.options[mySelect.options.length] = new Option("Pomona schools",'all=Pomona');
mySelect.options[mySelect.options.length] = new Option("Riverside schools",'all=Riverside');
mySelect.options[mySelect.options.length] = new Option("Sacramento schools",'all=Sacramento');
mySelect.options[mySelect.options.length] = new Option("San Diego schools",'all=San_Diego');
mySelect.options[mySelect.options.length] = new Option("Santa Clara schools",'all=Santa_Clara');
mySelect.options[mySelect.options.length] = new Option("Stockton schools",'all=Stockton');
mySelect.options[mySelect.options.length] = new Option("Sunnyvale schools",'all=Sunnyvale');
mySelect.options[mySelect.options.length] = new Option("West Covina schools",'all=West_Covina');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Los_Angeles[Los_Angeles.length] = createMarker(new GPoint(-118.33467300,34.02217500),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Al Madinah School",'Los_Angeles=' + Los_Angeles.length);
Sacramento[Sacramento.length] = createMarker(new GPoint(-121.43733900,38.50024300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Al-arqam Islamic School",'Sacramento=' + Sacramento.length);
Hawthorne[Hawthorne.length] = createMarker(new GPoint(-118.20330000,34.12080000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Al-huda Islamic School",'Hawthorne=' + Hawthorne.length);
Mission_Viejo[Mission_Viejo.length] = createMarker(new GPoint(-117.67552100,33.62081800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Al-ridah Academy",'Mission_Viejo=' + Mission_Viejo.length);
Bell_Gardens[Bell_Gardens.length] = createMarker(new GPoint(-118.17317800,33.97642500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Alhadi School",'Bell_Gardens=' + Bell_Gardens.length);
Fountain_Valley[Fountain_Valley.length] = createMarker(new GPoint(-117.96694000,33.72173600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("California Science Academy",'Fountain_Valley=' + Fountain_Valley.length);
Pomona[Pomona.length] = createMarker(new GPoint(-117.74873200,34.10656000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("City Of Knowledge",'Pomona=' + Pomona.length);
Stockton[Stockton.length] = createMarker(new GPoint(-121.25373700,37.93447000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Clara Mohammed",'Stockton=' + Stockton.length);
Oakland[Oakland.length] = createMarker(new GPoint(-122.21940000,37.77660000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Clara Mohammed School",'Oakland=' + Oakland.length);
Sunnyvale[Sunnyvale.length] = createMarker(new GPoint(-122.00369100,37.34548700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Darul Hikmah Silicon Valley Academy",'Sunnyvale=' + Sunnyvale.length);
Sacramento[Sacramento.length] = createMarker(new GPoint(-121.47951800,38.49384200),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Darul Uloom Al Islamiyah Sacramento",'Sacramento=' + Sacramento.length);
Santa_Clara[Santa_Clara.length] = createMarker(new GPoint(-121.95975100,37.37622400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Granada Islamic School",'Santa_Clara=' + Santa_Clara.length);
Pomona[Pomona.length] = createMarker(new GPoint(-117.74876500,34.10883100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Icc Community",'Pomona=' + Pomona.length);
Granada_Hills[Granada_Hills.length] = createMarker(new GPoint(-118.51547600,34.27849100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Igra Elementary School",'Granada_Hills=' + Granada_Hills.length);
Riverside[Riverside.length] = createMarker(new GPoint(-117.33490000,33.97460000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Islamic Academy Of Riverside",'Riverside=' + Riverside.length);
Anaheim[Anaheim.length] = createMarker(new GPoint(-117.95903400,33.84870800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Islamic Edu School",'Anaheim=' + Anaheim.length);
San_Diego[San_Diego.length] = createMarker(new GPoint(-117.16644500,32.82033700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Islamic School Of San Diego",'San_Diego=' + San_Diego.length);
Los_Angeles[Los_Angeles.length] = createMarker(new GPoint(-118.23329100,33.93416300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Los Angeles Computer Science Academy",'Los_Angeles=' + Los_Angeles.length);
Chatsworth[Chatsworth.length] = createMarker(new GPoint(-118.60529400,34.27175500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Meraj Academy",'Chatsworth=' + Chatsworth.length);
Irvine[Irvine.length] = createMarker(new GPoint(-117.76632600,33.69643700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("New Horizon Elem., Irvine",'Irvine=' + Irvine.length);
Pasadena[Pasadena.length] = createMarker(new GPoint(-118.15583000,34.15505800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("New Horizon School",'Pasadena=' + Pasadena.length);
Pasadena[Pasadena.length] = createMarker(new GPoint(-118.15588100,34.15517000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("New Horizon School Pasadena",'Pasadena=' + Pasadena.length);
Los_Angeles[Los_Angeles.length] = createMarker(new GPoint(-118.44604500,34.04348300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("New Horizon School Westside",'Los_Angeles=' + Los_Angeles.length);
Los_Angeles[Los_Angeles.length] = createMarker(new GPoint(-118.29153300,34.06660600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("New Horizon School-los Angeles Campus",'Los_Angeles=' + Los_Angeles.length);
Hayward[Hayward.length] = createMarker(new GPoint(-122.09005800,37.65223600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Northstar",'Hayward=' + Hayward.length);
Garden_Grove[Garden_Grove.length] = createMarker(new GPoint(-117.97134200,33.76545800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Orange Crescent School",'Garden_Grove=' + Garden_Grove.length);
Fremont[Fremont.length] = createMarker(new GPoint(-122.05543200,37.58024800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Peace Terrace Academy",'Fremont=' + Fremont.length);
West_Covina[West_Covina.length] = createMarker(new GPoint(-117.95269300,34.06595900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Straight Way School",'West_Covina=' + West_Covina.length);
Clovis[Clovis.length] = createMarker(new GPoint(-119.72484400,36.85230800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Valley Crescent School",'Clovis=' + Clovis.length);
map.removeOverlays(Anaheim);
map.removeOverlays(Bell_Gardens);
map.removeOverlays(Chatsworth);
map.removeOverlays(Clovis);
map.removeOverlays(Fountain_Valley);
map.removeOverlays(Fremont);
map.removeOverlays(Garden_Grove);
map.removeOverlays(Granada_Hills);
map.removeOverlays(Hawthorne);
map.removeOverlays(Hayward);
map.removeOverlays(Irvine);
map.removeOverlays(Los_Angeles);
map.removeOverlays(Mission_Viejo);
map.removeOverlays(Oakland);
map.removeOverlays(Pasadena);
map.removeOverlays(Pomona);
map.removeOverlays(Riverside);
map.removeOverlays(Sacramento);
map.removeOverlays(San_Diego);
map.removeOverlays(Santa_Clara);
map.removeOverlays(Stockton);
map.removeOverlays(Sunnyvale);
map.removeOverlays(West_Covina);
setTimeout(function(){map.addOverlays(Anaheim)},1000);
setTimeout(function(){map.addOverlays(Bell_Gardens)},1000);
setTimeout(function(){map.addOverlays(Chatsworth)},1000);
setTimeout(function(){map.addOverlays(Clovis)},1000);
setTimeout(function(){map.addOverlays(Fountain_Valley)},1000);
setTimeout(function(){map.addOverlays(Fremont)},1000);
setTimeout(function(){map.addOverlays(Garden_Grove)},1000);
setTimeout(function(){map.addOverlays(Granada_Hills)},1000);
setTimeout(function(){map.addOverlays(Hawthorne)},1000);
setTimeout(function(){map.addOverlays(Hayward)},1000);
setTimeout(function(){map.addOverlays(Irvine)},1000);
setTimeout(function(){map.addOverlays(Los_Angeles)},1000);
setTimeout(function(){map.addOverlays(Mission_Viejo)},1000);
setTimeout(function(){map.addOverlays(Oakland)},1000);
setTimeout(function(){map.addOverlays(Pasadena)},1000);
setTimeout(function(){map.addOverlays(Pomona)},1000);
setTimeout(function(){map.addOverlays(Riverside)},1000);
setTimeout(function(){map.addOverlays(Sacramento)},1000);
setTimeout(function(){map.addOverlays(San_Diego)},1000);
setTimeout(function(){map.addOverlays(Santa_Clara)},1000);
setTimeout(function(){map.addOverlays(Stockton)},1000);
setTimeout(function(){map.addOverlays(Sunnyvale)},1000);
setTimeout(function(){map.addOverlays(West_Covina)},1000);
maxLng = -117.16644500;
maxLat = 38.50024300;
minLng = -122.21940000;
minLat = 32.82033700;
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(Anaheim);
map.removeOverlays(Bell_Gardens);
map.removeOverlays(Chatsworth);
map.removeOverlays(Clovis);
map.removeOverlays(Fountain_Valley);
map.removeOverlays(Fremont);
map.removeOverlays(Garden_Grove);
map.removeOverlays(Granada_Hills);
map.removeOverlays(Hawthorne);
map.removeOverlays(Hayward);
map.removeOverlays(Irvine);
map.removeOverlays(Los_Angeles);
map.removeOverlays(Mission_Viejo);
map.removeOverlays(Oakland);
map.removeOverlays(Pasadena);
map.removeOverlays(Pomona);
map.removeOverlays(Riverside);
map.removeOverlays(Sacramento);
map.removeOverlays(San_Diego);
map.removeOverlays(Santa_Clara);
map.removeOverlays(Stockton);
map.removeOverlays(Sunnyvale);
map.removeOverlays(West_Covina);
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(Los_Angeles);map.removeOverlays(Anaheim);
map.removeOverlays(Bell_Gardens);
map.removeOverlays(Chatsworth);
map.removeOverlays(Clovis);
map.removeOverlays(Fountain_Valley);
map.removeOverlays(Fremont);
map.removeOverlays(Garden_Grove);
map.removeOverlays(Granada_Hills);
map.removeOverlays(Hawthorne);
map.removeOverlays(Hayward);
map.removeOverlays(Irvine);
map.removeOverlays(Los_Angeles);
map.removeOverlays(Mission_Viejo);
map.removeOverlays(Oakland);
map.removeOverlays(Pasadena);
map.removeOverlays(Pomona);
map.removeOverlays(Riverside);
map.removeOverlays(Sacramento);
map.removeOverlays(San_Diego);
map.removeOverlays(Santa_Clara);
map.removeOverlays(Stockton);
map.removeOverlays(Sunnyvale);
map.removeOverlays(West_Covina);
map.addOverlays(Anaheim);
centerByArray(Anaheim, false, false);
cntMarker += Anaheim.length;
map.addOverlays(Bell_Gardens);
centerByArray(Bell_Gardens, false, false);
cntMarker += Bell_Gardens.length;
map.addOverlays(Chatsworth);
centerByArray(Chatsworth, false, false);
cntMarker += Chatsworth.length;
map.addOverlays(Clovis);
centerByArray(Clovis, false, false);
cntMarker += Clovis.length;
map.addOverlays(Fountain_Valley);
centerByArray(Fountain_Valley, false, false);
cntMarker += Fountain_Valley.length;
map.addOverlays(Fremont);
centerByArray(Fremont, false, false);
cntMarker += Fremont.length;
map.addOverlays(Garden_Grove);
centerByArray(Garden_Grove, false, false);
cntMarker += Garden_Grove.length;
map.addOverlays(Granada_Hills);
centerByArray(Granada_Hills, false, false);
cntMarker += Granada_Hills.length;
map.addOverlays(Hawthorne);
centerByArray(Hawthorne, false, false);
cntMarker += Hawthorne.length;
map.addOverlays(Hayward);
centerByArray(Hayward, false, false);
cntMarker += Hayward.length;
map.addOverlays(Irvine);
centerByArray(Irvine, false, false);
cntMarker += Irvine.length;
map.addOverlays(Los_Angeles);
centerByArray(Los_Angeles, false, false);
cntMarker += Los_Angeles.length;
map.addOverlays(Mission_Viejo);
centerByArray(Mission_Viejo, false, false);
cntMarker += Mission_Viejo.length;
map.addOverlays(Oakland);
centerByArray(Oakland, false, false);
cntMarker += Oakland.length;
map.addOverlays(Pasadena);
centerByArray(Pasadena, false, false);
cntMarker += Pasadena.length;
map.addOverlays(Pomona);
centerByArray(Pomona, false, false);
cntMarker += Pomona.length;
map.addOverlays(Riverside);
centerByArray(Riverside, false, false);
cntMarker += Riverside.length;
map.addOverlays(Sacramento);
centerByArray(Sacramento, false, false);
cntMarker += Sacramento.length;
map.addOverlays(San_Diego);
centerByArray(San_Diego, false, false);
cntMarker += San_Diego.length;
map.addOverlays(Santa_Clara);
centerByArray(Santa_Clara, false, false);
cntMarker += Santa_Clara.length;
map.addOverlays(Stockton);
centerByArray(Stockton, false, false);
cntMarker += Stockton.length;
map.addOverlays(Sunnyvale);
centerByArray(Sunnyvale, false, false);
cntMarker += Sunnyvale.length;
map.addOverlays(West_Covina);
centerByArray(West_Covina, false, false);
cntMarker += West_Covina.length;
centerByArray(Los_Angeles,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///1046,30844,1219,2767,30518,1783,1096,1046,2861,34258,1286,35834,30793,1221,30929,32113,1219,2767,3118,3122,33971,1789,30518,3119,1783,1079,2494,1220,35305,2495,2297,1788,35820,4314,/all');
//window.open('/map.php?type=2&schools=1046,30844,1219,2767,30518,1783,1096,1046,2861,34258,1286,35834,30793,1221,30929,32113,1219,2767,3118,3122,33971,1789,30518,3119,1783,1079,2494,1220,35305,2495,2297,1788,35820,4314,&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;
}