function addMarkers()
{
mySelect = document.getElementById('selection');
Centralia = [];Salem = [];Iuka = [];Kell = [];Odin = [];Patoka = [];Sandoval = [];Farina = [];Kinmundy = [];mySelect.options[mySelect.options.length] = new Option("Centralia schools",'all=Centralia');
mySelect.options[mySelect.options.length] = new Option("Farina schools",'all=Farina');
mySelect.options[mySelect.options.length] = new Option("Iuka schools",'all=Iuka');
mySelect.options[mySelect.options.length] = new Option("Kell schools",'all=Kell');
mySelect.options[mySelect.options.length] = new Option("Kinmundy schools",'all=Kinmundy');
mySelect.options[mySelect.options.length] = new Option("Odin schools",'all=Odin');
mySelect.options[mySelect.options.length] = new Option("Patoka schools",'all=Patoka');
mySelect.options[mySelect.options.length] = new Option("Salem schools",'all=Salem');
mySelect.options[mySelect.options.length] = new Option("Sandoval schools",'all=Sandoval');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Centralia[Centralia.length] = createMarker(new GPoint(-89.13816071,38.50493622),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bronson Center",'Centralia=' + Centralia.length);
Centralia[Centralia.length] = createMarker(new GPoint(-89.12808990,38.54787827),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Central City Elementary School",'Centralia=' + Centralia.length);
Salem[Salem.length] = createMarker(new GPoint(-88.94777679,38.62462997),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Central Elementary School",'Salem=' + Salem.length);
Centralia[Centralia.length] = createMarker(new GPoint(-89.12922668,38.54959869),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Centralia Alternative School",'Centralia=' + Centralia.length);
Centralia[Centralia.length] = createMarker(new GPoint(-89.12879944,38.52619934),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Centralia Correctional Center",'Centralia=' + Centralia.length);
Centralia[Centralia.length] = createMarker(new GPoint(-89.12062073,38.52413559),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Centralia High School",'Centralia=' + Centralia.length);
Centralia[Centralia.length] = createMarker(new GPoint(-89.13047028,38.51766205),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Centralia Junior High School",'Centralia=' + Centralia.length);
Centralia[Centralia.length] = createMarker(new GPoint(-89.13278198,38.52299500),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Centralia Pre-kindergarten Center",'Centralia=' + Centralia.length);
Salem[Salem.length] = createMarker(new GPoint(-88.95897675,38.62833786),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Clnton/mrn/wshngtn Pre-kind Prog Elementary School",'Salem=' + Salem.length);
Salem[Salem.length] = createMarker(new GPoint(-88.94561400,38.62666000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Clnton/mrn/wshngtn Truant Alt School",'Salem=' + Salem.length);
Centralia[Centralia.length] = createMarker(new GPoint(-89.13702393,38.51585770),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Field Kindergarten Center",'Centralia=' + Centralia.length);
Salem[Salem.length] = createMarker(new GPoint(-88.95117187,38.63930130),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Franklin Park Middle School",'Salem=' + Salem.length);
Salem[Salem.length] = createMarker(new GPoint(-88.95897675,38.63753891),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Hawthorn Elementary School",'Salem=' + Salem.length);
Centralia[Centralia.length] = createMarker(new GPoint(-89.12879944,38.52619934),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Hudelson Education Center",'Centralia=' + Centralia.length);
Centralia[Centralia.length] = createMarker(new GPoint(-89.12751007,38.52490234),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Irving Elementary School",'Centralia=' + Centralia.length);
Iuka[Iuka.length] = createMarker(new GPoint(-88.77230072,38.59469986),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Iuka Community Consolidated School",'Iuka=' + Iuka.length);
Centralia[Centralia.length] = createMarker(new GPoint(-89.09822083,38.48541641),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Jordan Elementary School",'Centralia=' + Centralia.length);
Kell[Kell.length] = createMarker(new GPoint(-88.91500092,38.51459885),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Kell Grade School",'Kell=' + Kell.length);
Centralia[Centralia.length] = createMarker(new GPoint(-89.12962341,38.53224182),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Lincoln Elementary School",'Centralia=' + Centralia.length);
Salem[Salem.length] = createMarker(new GPoint(-88.95897675,38.62833786),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mar/clin/wash Co Rds",'Salem=' + Salem.length);
Odin[Odin.length] = createMarker(new GPoint(-89.04900360,38.61610031),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Odin Elementary School",'Odin=' + Odin.length);
Odin[Odin.length] = createMarker(new GPoint(-89.04900360,38.61610031),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Odin High School",'Odin=' + Odin.length);
Patoka[Patoka.length] = createMarker(new GPoint(-89.08608246,38.76494980),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Patoka Elementary School",'Patoka=' + Patoka.length);
Patoka[Patoka.length] = createMarker(new GPoint(-89.08608246,38.76494980),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Patoka Junior High School",'Patoka=' + Patoka.length);
Patoka[Patoka.length] = createMarker(new GPoint(-89.08608246,38.76494980),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Patoka Senior High School",'Patoka=' + Patoka.length);
Centralia[Centralia.length] = createMarker(new GPoint(-88.97868347,38.51927185),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Raccoon Consolidated Elementary School",'Centralia=' + Centralia.length);
Centralia[Centralia.length] = createMarker(new GPoint(-89.13816071,38.50493622),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Safe School Program Centralia",'Centralia=' + Centralia.length);
Salem[Salem.length] = createMarker(new GPoint(-88.94456482,38.63742828),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Salem Community High School",'Salem=' + Salem.length);
Sandoval[Sandoval.length] = createMarker(new GPoint(-89.11660767,38.61467743),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Sandoval Elementary School",'Sandoval=' + Sandoval.length);
Sandoval[Sandoval.length] = createMarker(new GPoint(-89.13101959,38.61643600),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Sandoval Junior High School",'Sandoval=' + Sandoval.length);
Sandoval[Sandoval.length] = createMarker(new GPoint(-89.13101959,38.61643600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sandoval Senior High School",'Sandoval=' + Sandoval.length);
Salem[Salem.length] = createMarker(new GPoint(-88.99588013,38.62237167),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Selmaville North Elementary School",'Salem=' + Salem.length);
Salem[Salem.length] = createMarker(new GPoint(-88.99962616,38.59079361),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Selmaville South Elementary School",'Salem=' + Salem.length);
Farina[Farina.length] = createMarker(new GPoint(-88.76979828,38.84529877),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("South Central Elementary-farina Middle School",'Farina=' + Farina.length);
Kinmundy[Kinmundy.length] = createMarker(new GPoint(-88.84018707,38.77363586),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("South Central Elementary-kinmundy Elementary School",'Kinmundy=' + Kinmundy.length);
Farina[Farina.length] = createMarker(new GPoint(-88.76979828,38.84529877),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("South Central High School",'Farina=' + Farina.length);
Kinmundy[Kinmundy.length] = createMarker(new GPoint(-88.81770325,38.76710129),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("South Central Middle School",'Kinmundy=' + Kinmundy.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(Centralia);
map.removeOverlays(Farina);
map.removeOverlays(Iuka);
map.removeOverlays(Kell);
map.removeOverlays(Kinmundy);
map.removeOverlays(Odin);
map.removeOverlays(Patoka);
map.removeOverlays(Salem);
map.removeOverlays(Sandoval);
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(Centralia);map.removeOverlays(Centralia);
map.removeOverlays(Farina);
map.removeOverlays(Iuka);
map.removeOverlays(Kell);
map.removeOverlays(Kinmundy);
map.removeOverlays(Odin);
map.removeOverlays(Patoka);
map.removeOverlays(Salem);
map.removeOverlays(Sandoval);
map.addOverlays(Centralia);
centerByArray(Centralia, false, false);
cntMarker += Centralia.length;
map.addOverlays(Farina);
centerByArray(Farina, false, false);
cntMarker += Farina.length;
map.addOverlays(Iuka);
centerByArray(Iuka, false, false);
cntMarker += Iuka.length;
map.addOverlays(Kell);
centerByArray(Kell, false, false);
cntMarker += Kell.length;
map.addOverlays(Kinmundy);
centerByArray(Kinmundy, false, false);
cntMarker += Kinmundy.length;
map.addOverlays(Odin);
centerByArray(Odin, false, false);
cntMarker += Odin.length;
map.addOverlays(Patoka);
centerByArray(Patoka, false, false);
cntMarker += Patoka.length;
map.addOverlays(Salem);
centerByArray(Salem, false, false);
cntMarker += Salem.length;
map.addOverlays(Sandoval);
centerByArray(Sandoval, false, false);
cntMarker += Sandoval.length;
centerByArray(Centralia,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');
}
}