function addMarkers()
{
mySelect = document.getElementById('selection');
Firth = [];Aberdeen = [];Blackfoot = [];Shelley = [];Pocatello = [];Pingree = [];Moreland = [];Fort_Hall = [];mySelect.options[mySelect.options.length] = new Option("Aberdeen schools",'all=Aberdeen');
mySelect.options[mySelect.options.length] = new Option("Blackfoot schools",'all=Blackfoot');
mySelect.options[mySelect.options.length] = new Option("Firth schools",'all=Firth');
mySelect.options[mySelect.options.length] = new Option("Fort Hall schools",'all=Fort_Hall');
mySelect.options[mySelect.options.length] = new Option("Moreland schools",'all=Moreland');
mySelect.options[mySelect.options.length] = new Option("Pingree schools",'all=Pingree');
mySelect.options[mySelect.options.length] = new Option("Pocatello schools",'all=Pocatello');
mySelect.options[mySelect.options.length] = new Option("Shelley schools",'all=Shelley');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Firth[Firth.length] = createMarker(new GPoint(-112.17823029,43.30138779),"
",iconRd);
mySelect.options[mySelect.options.length] = new Option("A W Johnson Elementary School",'Firth=' + Firth.length);
Aberdeen[Aberdeen.length] = createMarker(new GPoint(-112.83200073,42.97449875),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Aberdeen Elementary Middle School",'Aberdeen=' + Aberdeen.length);
Aberdeen[Aberdeen.length] = createMarker(new GPoint(-112.83200073,42.97449875),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Aberdeen High School",'Aberdeen=' + Aberdeen.length);
Aberdeen[Aberdeen.length] = createMarker(new GPoint(-112.83874200,42.94414800),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Aberdeen Middle School",'Aberdeen=' + Aberdeen.length);
Blackfoot[Blackfoot.length] = createMarker(new GPoint(-112.34177399,43.18701172),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Blackfoot Community Learning",'Blackfoot=' + Blackfoot.length);
Blackfoot[Blackfoot.length] = createMarker(new GPoint(-112.34740448,43.17905426),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Blackfoot High School",'Blackfoot=' + Blackfoot.length);
Blackfoot[Blackfoot.length] = createMarker(new GPoint(-112.34337616,43.18721008),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Blackfoot Sixth Grade Elementary School",'Blackfoot=' + Blackfoot.length);
Shelley[Shelley.length] = createMarker(new GPoint(-112.12533569,43.38153839),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Dean Goodsell Primary School",'Shelley=' + Shelley.length);
Blackfoot[Blackfoot.length] = createMarker(new GPoint(-112.36354828,43.18778992),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Donald D. Stalker Elementary School",'Blackfoot=' + Blackfoot.length);
Shelley[Shelley.length] = createMarker(new GPoint(-112.11819458,43.37956238),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Donald J Hobbs Middle School",'Shelley=' + Shelley.length);
Firth[Firth.length] = createMarker(new GPoint(-112.07289886,43.25839996),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Firth High School",'Firth=' + Firth.length);
Firth[Firth.length] = createMarker(new GPoint(-112.18795776,43.30635071),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Firth Middle School",'Firth=' + Firth.length);
Pocatello[Pocatello.length] = createMarker(new GPoint(-112.41809845,43.02769852),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Fort Hall Elementary School",'Pocatello=' + Pocatello.length);
Blackfoot[Blackfoot.length] = createMarker(new GPoint(-112.46326447,43.25325012),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Groveland Elementary School",'Blackfoot=' + Blackfoot.length);
Shelley[Shelley.length] = createMarker(new GPoint(-112.13262939,43.38153839),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Hazel Stuart Elementary School",'Shelley=' + Shelley.length);
Blackfoot[Blackfoot.length] = createMarker(new GPoint(-112.34518433,43.18070221),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("I T Stoddard Elementary School",'Blackfoot=' + Blackfoot.length);
Pingree[Pingree.length] = createMarker(new GPoint(-112.47498322,43.21212769),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Idaho Leadership Academy",'Pingree=' + Pingree.length);
Blackfoot[Blackfoot.length] = createMarker(new GPoint(-112.33925629,43.19004059),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Independence Alternate High School",'Blackfoot=' + Blackfoot.length);
Blackfoot[Blackfoot.length] = createMarker(new GPoint(-112.35011292,43.19063950),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Irving Kindergarten Center",'Blackfoot=' + Blackfoot.length);
Moreland[Moreland.length] = createMarker(new GPoint(-112.44309998,43.22150040),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Moreland Elementary School",'Moreland=' + Moreland.length);
Blackfoot[Blackfoot.length] = createMarker(new GPoint(-112.28718567,43.18262100),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Mountain View Middle School",'Blackfoot=' + Blackfoot.length);
Blackfoot[Blackfoot.length] = createMarker(new GPoint(-112.28718567,43.18262100),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Mountain View Middle School (alt)",'Blackfoot=' + Blackfoot.length);
Pingree[Pingree.length] = createMarker(new GPoint(-112.64080048,43.13219833),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Pingree Elementary School",'Pingree=' + Pingree.length);
Blackfoot[Blackfoot.length] = createMarker(new GPoint(-112.33872223,43.20724869),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Ridge Crest Elementary School",'Blackfoot=' + Blackfoot.length);
Blackfoot[Blackfoot.length] = createMarker(new GPoint(-112.43548584,43.19411087),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Riverside Elementary School",'Blackfoot=' + Blackfoot.length);
Blackfoot[Blackfoot.length] = createMarker(new GPoint(-112.52622223,43.19732666),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Rockford Elementary School",'Blackfoot=' + Blackfoot.length);
Shelley[Shelley.length] = createMarker(new GPoint(-112.12091064,43.37416458),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Shelley Junior High School",'Shelley=' + Shelley.length);
Shelley[Shelley.length] = createMarker(new GPoint(-112.13414001,43.37416458),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Shelley Senior High School",'Shelley=' + Shelley.length);
Fort_Hall[Fort_Hall.length] = createMarker(new GPoint(-112.41010284,42.99829865),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sho-ban School District No. 512",'Fort_Hall=' + Fort_Hall.length);
Blackfoot[Blackfoot.length] = createMarker(new GPoint(-112.47973633,43.19710541),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Snake River High School",'Blackfoot=' + Blackfoot.length);
Blackfoot[Blackfoot.length] = createMarker(new GPoint(-112.47886658,43.19709396),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Snake River Junior High School",'Blackfoot=' + Blackfoot.length);
Blackfoot[Blackfoot.length] = createMarker(new GPoint(-112.50782776,43.18103790),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Snake River Middle School",'Blackfoot=' + Blackfoot.length);
Blackfoot[Blackfoot.length] = createMarker(new GPoint(-112.39520264,43.20539856),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("State Hospital South",'Blackfoot=' + Blackfoot.length);
Blackfoot[Blackfoot.length] = createMarker(new GPoint(-112.35346985,43.19614029),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Vaughn Hugie Family Ed Center",'Blackfoot=' + Blackfoot.length);
Blackfoot[Blackfoot.length] = createMarker(new GPoint(-112.34514618,43.19013977),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Wapello Elementary School",'Blackfoot=' + Blackfoot.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(Aberdeen);
map.removeOverlays(Blackfoot);
map.removeOverlays(Firth);
map.removeOverlays(Fort_Hall);
map.removeOverlays(Moreland);
map.removeOverlays(Pingree);
map.removeOverlays(Pocatello);
map.removeOverlays(Shelley);
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(Firth);map.removeOverlays(Aberdeen);
map.removeOverlays(Blackfoot);
map.removeOverlays(Firth);
map.removeOverlays(Fort_Hall);
map.removeOverlays(Moreland);
map.removeOverlays(Pingree);
map.removeOverlays(Pocatello);
map.removeOverlays(Shelley);
map.addOverlays(Aberdeen);
centerByArray(Aberdeen, false, false);
cntMarker += Aberdeen.length;
map.addOverlays(Blackfoot);
centerByArray(Blackfoot, false, false);
cntMarker += Blackfoot.length;
map.addOverlays(Firth);
centerByArray(Firth, false, false);
cntMarker += Firth.length;
map.addOverlays(Fort_Hall);
centerByArray(Fort_Hall, false, false);
cntMarker += Fort_Hall.length;
map.addOverlays(Moreland);
centerByArray(Moreland, false, false);
cntMarker += Moreland.length;
map.addOverlays(Pingree);
centerByArray(Pingree, false, false);
cntMarker += Pingree.length;
map.addOverlays(Pocatello);
centerByArray(Pocatello, false, false);
cntMarker += Pocatello.length;
map.addOverlays(Shelley);
centerByArray(Shelley, false, false);
cntMarker += Shelley.length;
centerByArray(Firth,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');
}
}