function addMarkers(){
mySelect = document.getElementById('selection');
Metairie = [];Marrero = [];New_Orleans = [];Baton_Rouge = [];Clinton = [];Covington = [];mySelect.options[mySelect.options.length] = new Option("Baton Rouge schools",'all=Baton_Rouge');
mySelect.options[mySelect.options.length] = new Option("Clinton schools",'all=Clinton');
mySelect.options[mySelect.options.length] = new Option("Covington schools",'all=Covington');
mySelect.options[mySelect.options.length] = new Option("Marrero schools",'all=Marrero');
mySelect.options[mySelect.options.length] = new Option("Metairie schools",'all=Metairie');
mySelect.options[mySelect.options.length] = new Option("New Orleans schools",'all=New_Orleans');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Metairie[Metairie.length] = createMarker(new GPoint(-90.16750000,29.98440000),"
",iconBl);
mySelect.options[mySelect.options.length] = new Option("Archbishop Rummel High School",'Metairie=' + Metairie.length);
Marrero[Marrero.length] = createMarker(new GPoint(-90.10018100,29.89297400),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Archbishop Shaw High School",'Marrero=' + Marrero.length);
Marrero[Marrero.length] = createMarker(new GPoint(-90.10024200,29.89295300),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Archbishop Shaw Jhs/hs",'Marrero=' + Marrero.length);
New_Orleans[New_Orleans.length] = createMarker(new GPoint(-90.05915500,30.00314800),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Brother Martin High School",'New_Orleans=' + New_Orleans.length);
Baton_Rouge[Baton_Rouge.length] = createMarker(new GPoint(-91.15694000,30.44062800),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Catholic High School",'Baton_Rouge=' + Baton_Rouge.length);
Clinton[Clinton.length] = createMarker(new GPoint(-90.95210000,30.84730000),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Challenge & Dev Ctr/feliciana Alternative School",'Clinton=' + Clinton.length);
New_Orleans[New_Orleans.length] = createMarker(new GPoint(-90.09235600,29.98812500),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Christian Bros School",'New_Orleans=' + New_Orleans.length);
New_Orleans[New_Orleans.length] = createMarker(new GPoint(-90.07495700,30.01247500),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Holy Cross Middle School",'New_Orleans=' + New_Orleans.length);
New_Orleans[New_Orleans.length] = createMarker(new GPoint(-90.07515500,30.01352500),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Holy Cross School",'New_Orleans=' + New_Orleans.length);
New_Orleans[New_Orleans.length] = createMarker(new GPoint(-90.10367500,29.97253700),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Jesuit High School",'New_Orleans=' + New_Orleans.length);
Covington[Covington.length] = createMarker(new GPoint(-90.13596000,30.45657900),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("New Directions Alternative School",'Covington=' + Covington.length);
New_Orleans[New_Orleans.length] = createMarker(new GPoint(-90.06776900,29.98332800),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("St. Augustine High School",'New_Orleans=' + New_Orleans.length);
Covington[Covington.length] = createMarker(new GPoint(-90.10080000,30.47520000),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("The Saint Pauls School",'Covington=' + Covington.length);
New_Orleans[New_Orleans.length] = createMarker(new GPoint(-90.12354700,29.95336900),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Stuart Hall School for Boys",'New_Orleans=' + New_Orleans.length);
map.removeOverlays(Baton_Rouge);
map.removeOverlays(Clinton);
map.removeOverlays(Covington);
map.removeOverlays(Marrero);
map.removeOverlays(Metairie);
map.removeOverlays(New_Orleans);
setTimeout(function(){map.addOverlays(Baton_Rouge)},1000);
setTimeout(function(){map.addOverlays(Clinton)},1000);
setTimeout(function(){map.addOverlays(Covington)},1000);
setTimeout(function(){map.addOverlays(Marrero)},1000);
setTimeout(function(){map.addOverlays(Metairie)},1000);
setTimeout(function(){map.addOverlays(New_Orleans)},1000);
maxLng = -90.05915500;
maxLat = 30.84730000;
minLng = -91.15694000;
minLat = 29.89295300;
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(Baton_Rouge);
map.removeOverlays(Clinton);
map.removeOverlays(Covington);
map.removeOverlays(Marrero);
map.removeOverlays(Metairie);
map.removeOverlays(New_Orleans);
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(Metairie);map.removeOverlays(Baton_Rouge);
map.removeOverlays(Clinton);
map.removeOverlays(Covington);
map.removeOverlays(Marrero);
map.removeOverlays(Metairie);
map.removeOverlays(New_Orleans);
map.addOverlays(Baton_Rouge);
centerByArray(Baton_Rouge, false, false);
cntMarker += Baton_Rouge.length;
map.addOverlays(Clinton);
centerByArray(Clinton, false, false);
cntMarker += Clinton.length;
map.addOverlays(Covington);
centerByArray(Covington, false, false);
cntMarker += Covington.length;
map.addOverlays(Marrero);
centerByArray(Marrero, false, false);
cntMarker += Marrero.length;
map.addOverlays(Metairie);
centerByArray(Metairie, false, false);
cntMarker += Metairie.length;
map.addOverlays(New_Orleans);
centerByArray(New_Orleans, false, false);
cntMarker += New_Orleans.length;
centerByArray(Metairie,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///11534,11580,11543,11855,34056,11495,11494,11523,11604,11605,11629,11750,11580,11543,11550,11604,11605,11847,/all');
//window.open('/map.php?type=2&schools=11534,11580,11543,11855,34056,11495,11494,11523,11604,11605,11629,11750,11580,11543,11550,11604,11605,11847,&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;
}