function addMarkers()
{
mySelect = document.getElementById('selection');
Baskin = [];Crowville = [];Fort_Necessity = [];Winnsboro = [];Gilbert = [];Wisner = [];mySelect.options[mySelect.options.length] = new Option("Baskin schools",'all=Baskin');
mySelect.options[mySelect.options.length] = new Option("Crowville schools",'all=Crowville');
mySelect.options[mySelect.options.length] = new Option("Fort Necessity schools",'all=Fort_Necessity');
mySelect.options[mySelect.options.length] = new Option("Gilbert schools",'all=Gilbert');
mySelect.options[mySelect.options.length] = new Option("Winnsboro schools",'all=Winnsboro');
mySelect.options[mySelect.options.length] = new Option("Wisner schools",'all=Wisner');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Baskin[Baskin.length] = createMarker(new GPoint(-91.71990204,32.29710007),"
",iconRd);
mySelect.options[mySelect.options.length] = new Option("Baskin School",'Baskin=' + Baskin.length);
Crowville[Crowville.length] = createMarker(new GPoint(-91.58999634,32.24050140),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Crowville High School",'Crowville=' + Crowville.length);
Fort_Necessity[Fort_Necessity.length] = createMarker(new GPoint(-91.79949951,31.95800018),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Fort Necessity Junior High School",'Fort_Necessity=' + Fort_Necessity.length);
Winnsboro[Winnsboro.length] = createMarker(new GPoint(-91.72863007,32.15269852),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Franklin Alternative School",'Winnsboro=' + Winnsboro.length);
Winnsboro[Winnsboro.length] = createMarker(new GPoint(-91.72209167,32.16446686),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Franklin Parish Head Start Elementary School",'Winnsboro=' + Winnsboro.length);
Gilbert[Gilbert.length] = createMarker(new GPoint(-91.63310242,32.04079819),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Gilbert Junior High School",'Gilbert=' + Gilbert.length);
Winnsboro[Winnsboro.length] = createMarker(new GPoint(-91.84507751,32.13744354),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Ogden Primary School",'Winnsboro=' + Winnsboro.length);
Crowville[Crowville.length] = createMarker(new GPoint(-91.60385132,32.17201614),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Ward Iii School",'Crowville=' + Crowville.length);
Winnsboro[Winnsboro.length] = createMarker(new GPoint(-91.72209167,32.16446686),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Winnsboro Elementary School",'Winnsboro=' + Winnsboro.length);
Winnsboro[Winnsboro.length] = createMarker(new GPoint(-91.72836304,32.14994049),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Winnsboro High School",'Winnsboro=' + Winnsboro.length);
Winnsboro[Winnsboro.length] = createMarker(new GPoint(-91.68890381,32.16335297),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Winnsboro Junior High School",'Winnsboro=' + Winnsboro.length);
Wisner[Wisner.length] = createMarker(new GPoint(-91.68569946,31.96590042),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Wisner Elementary School",'Wisner=' + Wisner.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(Baskin);
map.removeOverlays(Crowville);
map.removeOverlays(Fort_Necessity);
map.removeOverlays(Gilbert);
map.removeOverlays(Winnsboro);
map.removeOverlays(Wisner);
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(Baskin);map.removeOverlays(Baskin);
map.removeOverlays(Crowville);
map.removeOverlays(Fort_Necessity);
map.removeOverlays(Gilbert);
map.removeOverlays(Winnsboro);
map.removeOverlays(Wisner);
map.addOverlays(Baskin);
centerByArray(Baskin, false, false);
cntMarker += Baskin.length;
map.addOverlays(Crowville);
centerByArray(Crowville, false, false);
cntMarker += Crowville.length;
map.addOverlays(Fort_Necessity);
centerByArray(Fort_Necessity, false, false);
cntMarker += Fort_Necessity.length;
map.addOverlays(Gilbert);
centerByArray(Gilbert, false, false);
cntMarker += Gilbert.length;
map.addOverlays(Winnsboro);
centerByArray(Winnsboro, false, false);
cntMarker += Winnsboro.length;
map.addOverlays(Wisner);
centerByArray(Wisner, false, false);
cntMarker += Wisner.length;
centerByArray(Baskin,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');
}
}