function addMarkers()
{
mySelect = document.getElementById('selection');
Wichita = [];Kansas_City = [];mySelect.options[mySelect.options.length] = new Option("Kansas City magnet schools",'all=Kansas_City');
mySelect.options[mySelect.options.length] = new Option("Wichita magnet schools",'all=Wichita');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Wichita[Wichita.length] = createMarker(new GPoint(-97.35301971,37.68275833),"
",iconBl);
mySelect.options[mySelect.options.length] = new Option("Allison Traditional Magnet Middle School",'Wichita=' + Wichita.length);
Wichita[Wichita.length] = createMarker(new GPoint(-97.38390350,37.70252991),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Black Traditional Magnet Elementary School",'Wichita=' + Wichita.length);
Wichita[Wichita.length] = createMarker(new GPoint(-97.24277496,37.67561340),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Bostic Traditional Magnet Elementary School",'Wichita=' + Wichita.length);
Wichita[Wichita.length] = createMarker(new GPoint(-97.29206085,37.73375702),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Brooks Magnet Middle School",'Wichita=' + Wichita.length);
Wichita[Wichita.length] = createMarker(new GPoint(-97.39735413,37.70164490),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Bryant Core Knowledge Magnet Elementary School",'Wichita=' + Wichita.length);
Wichita[Wichita.length] = createMarker(new GPoint(-97.29489136,37.73371124),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Buckner Performing Arts Magnet Elementary School",'Wichita=' + Wichita.length);
Wichita[Wichita.length] = createMarker(new GPoint(-97.31500244,37.61750031),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Carlton Math Science Magnet Elementary School",'Wichita=' + Wichita.length);
Wichita[Wichita.length] = createMarker(new GPoint(-97.38146210,37.63325882),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Cleaveland Traditional Magnet Elementary School",'Wichita=' + Wichita.length);
Wichita[Wichita.length] = createMarker(new GPoint(-97.43830109,37.70270157),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Dodge Literacy Magnet Elementary School",'Wichita=' + Wichita.length);
Wichita[Wichita.length] = createMarker(new GPoint(-97.39859772,37.68744278),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Dodge/edison Partnership Elementary School",'Wichita=' + Wichita.length);
Wichita[Wichita.length] = createMarker(new GPoint(-97.34490967,37.75329590),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Earhart Environ Magnet Elementary School",'Wichita=' + Wichita.length);
Wichita[Wichita.length] = createMarker(new GPoint(-97.36934662,37.71223068),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Emerson Open Magnet Elementary School",'Wichita=' + Wichita.length);
Wichita[Wichita.length] = createMarker(new GPoint(-97.33687592,37.70520020),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Horace Mann Foreign Language Elementary Magnet",'Wichita=' + Wichita.length);
Wichita[Wichita.length] = createMarker(new GPoint(-97.28052521,37.68853760),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Hyde Intl Studies/commun Elementary Magnet",'Wichita=' + Wichita.length);
Wichita[Wichita.length] = createMarker(new GPoint(-97.30918121,37.70276260),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Ingalls Edison Academy",'Wichita=' + Wichita.length);
Wichita[Wichita.length] = createMarker(new GPoint(-97.30682373,37.71743774),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Isely Traditional Magnet Elementary School",'Wichita=' + Wichita.length);
Wichita[Wichita.length] = createMarker(new GPoint(-97.26779938,37.63259888),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Jardine Middle School Magnet",'Wichita=' + Wichita.length);
Wichita[Wichita.length] = createMarker(new GPoint(-97.29502869,37.64191818),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Jardine/edison Partnership Middle School",'Wichita=' + Wichita.length);
Wichita[Wichita.length] = createMarker(new GPoint(-97.32341766,37.67927551),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Kellogg Science/tech Magnet Elementary School",'Wichita=' + Wichita.length);
Wichita[Wichita.length] = createMarker(new GPoint(-97.31671900,37.70447500),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("L'ouverture Computer Technology Magnet",'Wichita=' + Wichita.length);
Wichita[Wichita.length] = createMarker(new GPoint(-97.34802246,37.63966751),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Lewis Open Magnet Elementary School",'Wichita=' + Wichita.length);
Wichita[Wichita.length] = createMarker(new GPoint(-97.38034821,37.68206787),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Mayberry Magnet Middle School",'Wichita=' + Wichita.length);
Wichita[Wichita.length] = createMarker(new GPoint(-97.36721039,37.72492599),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Mclean Science/tech Magnet Elementary School",'Wichita=' + Wichita.length);
Wichita[Wichita.length] = createMarker(new GPoint(-97.22618103,37.69885254),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Minneha Elementary School",'Wichita=' + Wichita.length);
Wichita[Wichita.length] = createMarker(new GPoint(-97.30130768,37.71637726),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Northeast Magnet/downtown Campus High School",'Wichita=' + Wichita.length);
Wichita[Wichita.length] = createMarker(new GPoint(-97.25386900,37.70001100),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Price/harris Communications Magnet",'Wichita=' + Wichita.length);
Wichita[Wichita.length] = createMarker(new GPoint(-97.26547400,37.70560500),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Price/harris Communications Magnet Elementary School",'Wichita=' + Wichita.length);
Wichita[Wichita.length] = createMarker(new GPoint(-97.35788727,37.70117950),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Riverside Cultural Arts / History Magnet Elementary School",'Wichita=' + Wichita.length);
Wichita[Wichita.length] = createMarker(new GPoint(-97.30898285,37.70283890),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Spaght Accelerated Magnet Academy",'Wichita=' + Wichita.length);
Kansas_City[Kansas_City.length] = createMarker(new GPoint(-94.62977600,39.12201691),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sumner Academy Of Arts & Science",'Kansas_City=' + Kansas_City.length);
Wichita[Wichita.length] = createMarker(new GPoint(-97.35173798,37.71355438),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Woodland Health / Wellness Magnet Elementary Schoo",'Wichita=' + Wichita.length);
maxLng = -94.62977600;
maxLat = 39.12201691;
minLng = -97.43830109;
minLat = 37.61750031;
reCenterMap();
map.removeOverlays(Kansas_City);
map.removeOverlays(Wichita);
setTimeout(function(){map.addOverlays(Kansas_City)},1000);
setTimeout(function(){map.addOverlays(Wichita)},1000);
} // 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(Kansas_City);
map.removeOverlays(Wichita);
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(Wichita);map.removeOverlays(Kansas_City);
map.removeOverlays(Wichita);
map.addOverlays(Kansas_City);
centerByArray(Kansas_City, false, false);
cntMarker += Kansas_City.length;
map.addOverlays(Wichita);
centerByArray(Wichita, false, false);
cntMarker += Wichita.length;
centerByArray(Wichita,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');
}
}