function addMarkers(){
mySelect = document.getElementById('selection');
Lafayette = [];Shreveport = [];Covington = [];Baton_Rouge = [];Port_Barre = [];Sulphur = [];Houma = [];Slidell = [];Alexandria = [];Mandeville = [];New_Orleans = [];Pearl_River = [];Hammond = [];Gretna = [];Ruston = [];mySelect.options[mySelect.options.length] = new Option("Alexandria schools",'all=Alexandria');
mySelect.options[mySelect.options.length] = new Option("Baton Rouge schools",'all=Baton_Rouge');
mySelect.options[mySelect.options.length] = new Option("Covington schools",'all=Covington');
mySelect.options[mySelect.options.length] = new Option("Gretna schools",'all=Gretna');
mySelect.options[mySelect.options.length] = new Option("Hammond schools",'all=Hammond');
mySelect.options[mySelect.options.length] = new Option("Houma schools",'all=Houma');
mySelect.options[mySelect.options.length] = new Option("Lafayette schools",'all=Lafayette');
mySelect.options[mySelect.options.length] = new Option("Mandeville schools",'all=Mandeville');
mySelect.options[mySelect.options.length] = new Option("New Orleans schools",'all=New_Orleans');
mySelect.options[mySelect.options.length] = new Option("Pearl River schools",'all=Pearl_River');
mySelect.options[mySelect.options.length] = new Option("Port Barre schools",'all=Port_Barre');
mySelect.options[mySelect.options.length] = new Option("Ruston schools",'all=Ruston');
mySelect.options[mySelect.options.length] = new Option("Shreveport schools",'all=Shreveport');
mySelect.options[mySelect.options.length] = new Option("Slidell schools",'all=Slidell');
mySelect.options[mySelect.options.length] = new Option("Sulphur schools",'all=Sulphur');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Lafayette[Lafayette.length] = createMarker(new GPoint(-92.01705500,30.22032300),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Ashton Grace Montessori School",'Lafayette=' + Lafayette.length);
Shreveport[Shreveport.length] = createMarker(new GPoint(-93.75962400,32.41816300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Christian Center School",'Shreveport=' + Shreveport.length);
Covington[Covington.length] = createMarker(new GPoint(-90.10249400,30.47662000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Covington Montessori School",'Covington=' + Covington.length);
Baton_Rouge[Baton_Rouge.length] = createMarker(new GPoint(-91.13545000,30.41275700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Élan Vital Montessori School, Inc.",'Baton_Rouge=' + Baton_Rouge.length);
Port_Barre[Port_Barre.length] = createMarker(new GPoint(-91.91590000,30.57120000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Good Shepherd Montessori School",'Port_Barre=' + Port_Barre.length);
Baton_Rouge[Baton_Rouge.length] = createMarker(new GPoint(-91.13609400,30.41310200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("La Printaniere Montessori School",'Baton_Rouge=' + Baton_Rouge.length);
Sulphur[Sulphur.length] = createMarker(new GPoint(-93.31933900,30.22973800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Little Learners Montessori",'Sulphur=' + Sulphur.length);
Houma[Houma.length] = createMarker(new GPoint(-90.73253900,29.57730000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Messiah Montessori",'Houma=' + Houma.length);
Slidell[Slidell.length] = createMarker(new GPoint(-89.71947800,30.28284500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Montessori Chateau",'Slidell=' + Slidell.length);
Baton_Rouge[Baton_Rouge.length] = createMarker(new GPoint(-91.15625100,30.39107900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Montessori Children's House",'Baton_Rouge=' + Baton_Rouge.length);
Alexandria[Alexandria.length] = createMarker(new GPoint(-92.49065300,31.33139600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Montessori Educational Center",'Alexandria=' + Alexandria.length);
Shreveport[Shreveport.length] = createMarker(new GPoint(-93.71993700,32.48701800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Montessori School For Shreveport",'Shreveport=' + Shreveport.length);
Mandeville[Mandeville.length] = createMarker(new GPoint(-90.10032300,30.39781400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("New Covenant Presbyterian Weekday School",'Mandeville=' + Mandeville.length);
New_Orleans[New_Orleans.length] = createMarker(new GPoint(-90.12141900,30.00917700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("New Orleans Montessori School",'New_Orleans=' + New_Orleans.length);
Pearl_River[Pearl_River.length] = createMarker(new GPoint(-89.73896000,30.35224000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Northminster Montessori",'Pearl_River=' + Pearl_River.length);
Hammond[Hammond.length] = createMarker(new GPoint(-90.44650000,30.46455300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Oaks Montessori School",'Hammond=' + Hammond.length);
Gretna[Gretna.length] = createMarker(new GPoint(-90.03030200,29.90609800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Stepping Stones Montessori",'Gretna=' + Gretna.length);
New_Orleans[New_Orleans.length] = createMarker(new GPoint(-90.12746600,29.94132100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("University Montessori School",'New_Orleans=' + New_Orleans.length);
Hammond[Hammond.length] = createMarker(new GPoint(-90.46509500,30.50958500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("University Montessori School",'Hammond=' + Hammond.length);
Baton_Rouge[Baton_Rouge.length] = createMarker(new GPoint(-91.12757200,30.46084300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Warren Academy",'Baton_Rouge=' + Baton_Rouge.length);
Ruston[Ruston.length] = createMarker(new GPoint(-92.64345300,32.54086800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Wildflower Montessori School",'Ruston=' + Ruston.length);
map.removeOverlays(Alexandria);
map.removeOverlays(Baton_Rouge);
map.removeOverlays(Covington);
map.removeOverlays(Gretna);
map.removeOverlays(Hammond);
map.removeOverlays(Houma);
map.removeOverlays(Lafayette);
map.removeOverlays(Mandeville);
map.removeOverlays(New_Orleans);
map.removeOverlays(Pearl_River);
map.removeOverlays(Port_Barre);
map.removeOverlays(Ruston);
map.removeOverlays(Shreveport);
map.removeOverlays(Slidell);
map.removeOverlays(Sulphur);
setTimeout(function(){map.addOverlays(Alexandria)},1000);
setTimeout(function(){map.addOverlays(Baton_Rouge)},1000);
setTimeout(function(){map.addOverlays(Covington)},1000);
setTimeout(function(){map.addOverlays(Gretna)},1000);
setTimeout(function(){map.addOverlays(Hammond)},1000);
setTimeout(function(){map.addOverlays(Houma)},1000);
setTimeout(function(){map.addOverlays(Lafayette)},1000);
setTimeout(function(){map.addOverlays(Mandeville)},1000);
setTimeout(function(){map.addOverlays(New_Orleans)},1000);
setTimeout(function(){map.addOverlays(Pearl_River)},1000);
setTimeout(function(){map.addOverlays(Port_Barre)},1000);
setTimeout(function(){map.addOverlays(Ruston)},1000);
setTimeout(function(){map.addOverlays(Shreveport)},1000);
setTimeout(function(){map.addOverlays(Slidell)},1000);
setTimeout(function(){map.addOverlays(Sulphur)},1000);
maxLng = -89.71947800;
maxLat = 32.54086800;
minLng = -93.75962400;
minLat = 29.57730000;
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(Alexandria);
map.removeOverlays(Baton_Rouge);
map.removeOverlays(Covington);
map.removeOverlays(Gretna);
map.removeOverlays(Hammond);
map.removeOverlays(Houma);
map.removeOverlays(Lafayette);
map.removeOverlays(Mandeville);
map.removeOverlays(New_Orleans);
map.removeOverlays(Pearl_River);
map.removeOverlays(Port_Barre);
map.removeOverlays(Ruston);
map.removeOverlays(Shreveport);
map.removeOverlays(Slidell);
map.removeOverlays(Sulphur);
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(Lafayette);map.removeOverlays(Alexandria);
map.removeOverlays(Baton_Rouge);
map.removeOverlays(Covington);
map.removeOverlays(Gretna);
map.removeOverlays(Hammond);
map.removeOverlays(Houma);
map.removeOverlays(Lafayette);
map.removeOverlays(Mandeville);
map.removeOverlays(New_Orleans);
map.removeOverlays(Pearl_River);
map.removeOverlays(Port_Barre);
map.removeOverlays(Ruston);
map.removeOverlays(Shreveport);
map.removeOverlays(Slidell);
map.removeOverlays(Sulphur);
map.addOverlays(Alexandria);
centerByArray(Alexandria, false, false);
cntMarker += Alexandria.length;
map.addOverlays(Baton_Rouge);
centerByArray(Baton_Rouge, false, false);
cntMarker += Baton_Rouge.length;
map.addOverlays(Covington);
centerByArray(Covington, false, false);
cntMarker += Covington.length;
map.addOverlays(Gretna);
centerByArray(Gretna, false, false);
cntMarker += Gretna.length;
map.addOverlays(Hammond);
centerByArray(Hammond, false, false);
cntMarker += Hammond.length;
map.addOverlays(Houma);
centerByArray(Houma, false, false);
cntMarker += Houma.length;
map.addOverlays(Lafayette);
centerByArray(Lafayette, false, false);
cntMarker += Lafayette.length;
map.addOverlays(Mandeville);
centerByArray(Mandeville, false, false);
cntMarker += Mandeville.length;
map.addOverlays(New_Orleans);
centerByArray(New_Orleans, false, false);
cntMarker += New_Orleans.length;
map.addOverlays(Pearl_River);
centerByArray(Pearl_River, false, false);
cntMarker += Pearl_River.length;
map.addOverlays(Port_Barre);
centerByArray(Port_Barre, false, false);
cntMarker += Port_Barre.length;
map.addOverlays(Ruston);
centerByArray(Ruston, false, false);
cntMarker += Ruston.length;
map.addOverlays(Shreveport);
centerByArray(Shreveport, false, false);
cntMarker += Shreveport.length;
map.addOverlays(Slidell);
centerByArray(Slidell, false, false);
cntMarker += Slidell.length;
map.addOverlays(Sulphur);
centerByArray(Sulphur, false, false);
cntMarker += Sulphur.length;
centerByArray(Lafayette,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///11665,30519,11635,11664,35406,11561,11844,11680,11863,34765,34764,35065,11672,11862,11883,11881,11875,11551,11853,11663,11642,/all');
//window.open('/map.php?type=2&schools=11665,30519,11635,11664,35406,11561,11844,11680,11863,34765,34764,35065,11672,11862,11883,11881,11875,11551,11853,11663,11642,&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;
}