function addMarkers()
{
mySelect = document.getElementById('selection');
Bossier_City = [];Benton = [];Plain_Dealing = [];Elm_Grove = [];Haughton = [];Princeton = [];mySelect.options[mySelect.options.length] = new Option("Benton schools",'all=Benton');
mySelect.options[mySelect.options.length] = new Option("Bossier City schools",'all=Bossier_City');
mySelect.options[mySelect.options.length] = new Option("Elm Grove schools",'all=Elm_Grove');
mySelect.options[mySelect.options.length] = new Option("Haughton schools",'all=Haughton');
mySelect.options[mySelect.options.length] = new Option("Plain Dealing schools",'all=Plain_Dealing');
mySelect.options[mySelect.options.length] = new Option("Princeton schools",'all=Princeton');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Bossier_City[Bossier_City.length] = createMarker(new GPoint(-93.70929718,32.54872131),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Airline High School",'Bossier_City=' + Bossier_City.length);
Bossier_City[Bossier_City.length] = createMarker(new GPoint(-93.72547913,32.55464935),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Apollo Elementary School",'Bossier_City=' + Bossier_City.length);
Bossier_City[Bossier_City.length] = createMarker(new GPoint(-93.67797852,32.48607635),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Bellaire Elementary School",'Bossier_City=' + Bossier_City.length);
Benton[Benton.length] = createMarker(new GPoint(-93.71733856,32.69705582),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Benton Elementary School",'Benton=' + Benton.length);
Benton[Benton.length] = createMarker(new GPoint(-93.74737549,32.66674423),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Benton High School",'Benton=' + Benton.length);
Benton[Benton.length] = createMarker(new GPoint(-93.74733734,32.66704559),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Benton Middle School",'Benton=' + Benton.length);
Bossier_City[Bossier_City.length] = createMarker(new GPoint(-93.73748016,32.52194977),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Bossier Elementary School",'Bossier_City=' + Bossier_City.length);
Bossier_City[Bossier_City.length] = createMarker(new GPoint(-93.72884369,32.51845551),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bossier High School",'Bossier_City=' + Bossier_City.length);
Bossier_City[Bossier_City.length] = createMarker(new GPoint(-93.73134613,32.52396774),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Butler Educational Complex High School",'Bossier_City=' + Bossier_City.length);
Bossier_City[Bossier_City.length] = createMarker(new GPoint(-93.72941589,32.52240372),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Butler Elementary School",'Bossier_City=' + Bossier_City.length);
Plain_Dealing[Plain_Dealing.length] = createMarker(new GPoint(-93.68689728,32.91049957),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Carrie Martin Elementary School",'Plain_Dealing=' + Plain_Dealing.length);
Bossier_City[Bossier_City.length] = createMarker(new GPoint(-93.71447754,32.51015091),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Central Park Elementary School",'Bossier_City=' + Bossier_City.length);
Bossier_City[Bossier_City.length] = createMarker(new GPoint(-93.72055817,32.52165222),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Charlotte Ann Mitchell Educational Center",'Bossier_City=' + Bossier_City.length);
Bossier_City[Bossier_City.length] = createMarker(new GPoint(-93.66913605,32.54465103),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Cope Middle School",'Bossier_City=' + Bossier_City.length);
Bossier_City[Bossier_City.length] = createMarker(new GPoint(-93.65023041,32.44490051),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Curtis Elementary School",'Bossier_City=' + Bossier_City.length);
Elm_Grove[Elm_Grove.length] = createMarker(new GPoint(-93.55853400,32.35332500),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Elm Grove Middle School",'Elm_Grove=' + Elm_Grove.length);
Bossier_City[Bossier_City.length] = createMarker(new GPoint(-93.70386505,32.53045654),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Greenacres Middle School",'Bossier_City=' + Bossier_City.length);
Haughton[Haughton.length] = createMarker(new GPoint(-93.49273682,32.53498077),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Haughton High School",'Haughton=' + Haughton.length);
Haughton[Haughton.length] = createMarker(new GPoint(-93.51592255,32.52002716),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Haughton Middle School",'Haughton=' + Haughton.length);
Bossier_City[Bossier_City.length] = createMarker(new GPoint(-93.67028046,32.54415131),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Johnny Gray Jones Youth Shltr & Detention Cntr",'Bossier_City=' + Bossier_City.length);
Bossier_City[Bossier_City.length] = createMarker(new GPoint(-93.67958069,32.54298019),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Life Skills Center",'Bossier_City=' + Bossier_City.length);
Bossier_City[Bossier_City.length] = createMarker(new GPoint(-93.68107605,32.54244995),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Meadowview Elementary School",'Bossier_City=' + Bossier_City.length);
Bossier_City[Bossier_City.length] = createMarker(new GPoint(-93.65511322,32.55980682),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Northwest Developmental Center",'Bossier_City=' + Bossier_City.length);
Bossier_City[Bossier_City.length] = createMarker(new GPoint(-93.67087555,32.47255325),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Parkway High School",'Bossier_City=' + Bossier_City.length);
Plain_Dealing[Plain_Dealing.length] = createMarker(new GPoint(-93.68689728,32.91049957),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Plain Dealing High School",'Plain_Dealing=' + Plain_Dealing.length);
Plain_Dealing[Plain_Dealing.length] = createMarker(new GPoint(-93.68689728,32.91049957),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Plain Dealing Middle School",'Plain_Dealing=' + Plain_Dealing.length);
Bossier_City[Bossier_City.length] = createMarker(new GPoint(-93.71549225,32.54126358),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Plantation Park Elementary School",'Bossier_City=' + Bossier_City.length);
Haughton[Haughton.length] = createMarker(new GPoint(-93.56805420,32.55614853),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Platt Elementary School",'Haughton=' + Haughton.length);
Princeton[Princeton.length] = createMarker(new GPoint(-93.53257751,32.58648682),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Princeton Elementary School",'Princeton=' + Princeton.length);
Bossier_City[Bossier_City.length] = createMarker(new GPoint(-93.69554138,32.51835251),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("R. V. Kerr Elementary School",'Bossier_City=' + Bossier_City.length);
Bossier_City[Bossier_City.length] = createMarker(new GPoint(-93.70645905,32.54405212),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Red River Marine Institute, Inc.",'Bossier_City=' + Bossier_City.length);
Bossier_City[Bossier_City.length] = createMarker(new GPoint(-93.70462036,32.51903152),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Rusheon Middle School",'Bossier_City=' + Bossier_City.length);
Bossier_City[Bossier_City.length] = createMarker(new GPoint(-93.64527893,32.56144714),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Stockwell Place Elementary School",'Bossier_City=' + Bossier_City.length);
Bossier_City[Bossier_City.length] = createMarker(new GPoint(-93.66756439,32.47517395),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Sun City Elementary School",'Bossier_City=' + Bossier_City.length);
Haughton[Haughton.length] = createMarker(new GPoint(-93.56838226,32.55613327),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("T.l. Rodes Elementary School",'Haughton=' + Haughton.length);
Bossier_City[Bossier_City.length] = createMarker(new GPoint(-93.69847870,32.50855255),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Waller Elementary School",'Bossier_City=' + Bossier_City.length);
} // 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(Benton);
map.removeOverlays(Bossier_City);
map.removeOverlays(Elm_Grove);
map.removeOverlays(Haughton);
map.removeOverlays(Plain_Dealing);
map.removeOverlays(Princeton);
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(Bossier_City);map.removeOverlays(Benton);
map.removeOverlays(Bossier_City);
map.removeOverlays(Elm_Grove);
map.removeOverlays(Haughton);
map.removeOverlays(Plain_Dealing);
map.removeOverlays(Princeton);
map.addOverlays(Benton);
centerByArray(Benton, false, false);
cntMarker += Benton.length;
map.addOverlays(Bossier_City);
centerByArray(Bossier_City, false, false);
cntMarker += Bossier_City.length;
map.addOverlays(Elm_Grove);
centerByArray(Elm_Grove, false, false);
cntMarker += Elm_Grove.length;
map.addOverlays(Haughton);
centerByArray(Haughton, false, false);
cntMarker += Haughton.length;
map.addOverlays(Plain_Dealing);
centerByArray(Plain_Dealing, false, false);
cntMarker += Plain_Dealing.length;
map.addOverlays(Princeton);
centerByArray(Princeton, false, false);
cntMarker += Princeton.length;
centerByArray(Bossier_City,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////all');
}
}