function addMarkers()
{
mySelect = document.getElementById('selection');
Grambling = [];Sterlington = [];Berwick = [];Deville = [];Shreveport = [];Kentwood = [];New_Orleans = [];Baton_Rouge = [];Gramercy = [];Tioga = [];Sulphur = [];mySelect.options[mySelect.options.length] = new Option("Baton Rouge schools",'all=Baton_Rouge');
mySelect.options[mySelect.options.length] = new Option("Berwick schools",'all=Berwick');
mySelect.options[mySelect.options.length] = new Option("Deville schools",'all=Deville');
mySelect.options[mySelect.options.length] = new Option("Grambling schools",'all=Grambling');
mySelect.options[mySelect.options.length] = new Option("Gramercy schools",'all=Gramercy');
mySelect.options[mySelect.options.length] = new Option("Kentwood schools",'all=Kentwood');
mySelect.options[mySelect.options.length] = new Option("New Orleans schools",'all=New_Orleans');
mySelect.options[mySelect.options.length] = new Option("Shreveport schools",'all=Shreveport');
mySelect.options[mySelect.options.length] = new Option("Sterlington schools",'all=Sterlington');
mySelect.options[mySelect.options.length] = new Option("Sulphur schools",'all=Sulphur');
mySelect.options[mySelect.options.length] = new Option("Tioga schools",'all=Tioga');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Grambling[Grambling.length] = createMarker(new GPoint(-92.71408081,32.52711105),"
",iconRd);
mySelect.options[mySelect.options.length] = new Option("A. J. Brown Elementary School",'Grambling=' + Grambling.length);
Sterlington[Sterlington.length] = createMarker(new GPoint(-92.05410004,32.69350052),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("A.l. Smith School",'Sterlington=' + Sterlington.length);
Berwick[Berwick.length] = createMarker(new GPoint(-91.21917725,29.69541931),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Berwick Elementary School",'Berwick=' + Berwick.length);
Deville[Deville.length] = createMarker(new GPoint(-92.19989777,31.35759926),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Buckeye Elementary School",'Deville=' + Deville.length);
Shreveport[Shreveport.length] = createMarker(new GPoint(-93.72013855,32.49615479),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Caddo Parish Magnet High School",'Shreveport=' + Shreveport.length);
Shreveport[Shreveport.length] = createMarker(new GPoint(-93.74419403,32.43592834),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Caddo Parish Middle Magnet School",'Shreveport=' + Shreveport.length);
Kentwood[Kentwood.length] = createMarker(new GPoint(-90.45661926,30.84874725),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Chesbrough Elementary School",'Kentwood=' + Kentwood.length);
New_Orleans[New_Orleans.length] = createMarker(new GPoint(-90.00457001,29.92015648),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Edna Karr Magnet School",'New_Orleans=' + New_Orleans.length);
Baton_Rouge[Baton_Rouge.length] = createMarker(new GPoint(-91.11646271,30.51413727),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Forest Heights Elementary School",'Baton_Rouge=' + Baton_Rouge.length);
Baton_Rouge[Baton_Rouge.length] = createMarker(new GPoint(-91.14370728,30.40876579),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Glasgow Middle School",'Baton_Rouge=' + Baton_Rouge.length);
Gramercy[Gramercy.length] = createMarker(new GPoint(-90.69409943,30.06419945),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Gramercy Elementary School",'Gramercy=' + Gramercy.length);
Shreveport[Shreveport.length] = createMarker(new GPoint(-93.79929352,32.48850632),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Judson Fundamental Elementary School",'Shreveport=' + Shreveport.length);
Shreveport[Shreveport.length] = createMarker(new GPoint(-93.73844147,32.46043777),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("South Highlands Elementary Magnet School",'Shreveport=' + Shreveport.length);
Tioga[Tioga.length] = createMarker(new GPoint(-92.41598511,31.37789726),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Tioga Elementary School",'Tioga=' + Tioga.length);
Sulphur[Sulphur.length] = createMarker(new GPoint(-93.35925293,30.14806366),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Vincent Settlement Elementary School",'Sulphur=' + Sulphur.length);
Baton_Rouge[Baton_Rouge.length] = createMarker(new GPoint(-91.13548279,30.43018532),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Westdale Elementary School",'Baton_Rouge=' + Baton_Rouge.length);
map.removeOverlays(Baton_Rouge);
map.removeOverlays(Berwick);
map.removeOverlays(Deville);
map.removeOverlays(Grambling);
map.removeOverlays(Gramercy);
map.removeOverlays(Kentwood);
map.removeOverlays(New_Orleans);
map.removeOverlays(Shreveport);
map.removeOverlays(Sterlington);
map.removeOverlays(Sulphur);
map.removeOverlays(Tioga);
setTimeout(function(){map.addOverlays(Baton_Rouge)},1000);
setTimeout(function(){map.addOverlays(Berwick)},1000);
setTimeout(function(){map.addOverlays(Deville)},1000);
setTimeout(function(){map.addOverlays(Grambling)},1000);
setTimeout(function(){map.addOverlays(Gramercy)},1000);
setTimeout(function(){map.addOverlays(Kentwood)},1000);
setTimeout(function(){map.addOverlays(New_Orleans)},1000);
setTimeout(function(){map.addOverlays(Shreveport)},1000);
setTimeout(function(){map.addOverlays(Sterlington)},1000);
setTimeout(function(){map.addOverlays(Sulphur)},1000);
setTimeout(function(){map.addOverlays(Tioga)},1000);
maxLng = -90.00457001;
maxLat = 32.69350052;
minLng = -93.79929352;
minLat = 29.69541931;
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,10);
/*
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(Berwick);
map.removeOverlays(Deville);
map.removeOverlays(Grambling);
map.removeOverlays(Gramercy);
map.removeOverlays(Kentwood);
map.removeOverlays(New_Orleans);
map.removeOverlays(Shreveport);
map.removeOverlays(Sterlington);
map.removeOverlays(Sulphur);
map.removeOverlays(Tioga);
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(Grambling);map.removeOverlays(Baton_Rouge);
map.removeOverlays(Berwick);
map.removeOverlays(Deville);
map.removeOverlays(Grambling);
map.removeOverlays(Gramercy);
map.removeOverlays(Kentwood);
map.removeOverlays(New_Orleans);
map.removeOverlays(Shreveport);
map.removeOverlays(Sterlington);
map.removeOverlays(Sulphur);
map.removeOverlays(Tioga);
map.addOverlays(Baton_Rouge);
centerByArray(Baton_Rouge, false, false);
cntMarker += Baton_Rouge.length;
map.addOverlays(Berwick);
centerByArray(Berwick, false, false);
cntMarker += Berwick.length;
map.addOverlays(Deville);
centerByArray(Deville, false, false);
cntMarker += Deville.length;
map.addOverlays(Grambling);
centerByArray(Grambling, false, false);
cntMarker += Grambling.length;
map.addOverlays(Gramercy);
centerByArray(Gramercy, false, false);
cntMarker += Gramercy.length;
map.addOverlays(Kentwood);
centerByArray(Kentwood, false, false);
cntMarker += Kentwood.length;
map.addOverlays(New_Orleans);
centerByArray(New_Orleans, false, false);
cntMarker += New_Orleans.length;
map.addOverlays(Shreveport);
centerByArray(Shreveport, false, false);
cntMarker += Shreveport.length;
map.addOverlays(Sterlington);
centerByArray(Sterlington, false, false);
cntMarker += Sterlington.length;
map.addOverlays(Sulphur);
centerByArray(Sulphur, false, false);
cntMarker += Sulphur.length;
map.addOverlays(Tioga);
centerByArray(Tioga, false, false);
cntMarker += Tioga.length;
centerByArray(Grambling,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///34393,33731,33955,33682,33888,33941,34718,34528,34230,34637,34799,33693,33710,34484,33792,34563,/all');
}
}