function addMarkers()
{
mySelect = document.getElementById('selection');
Phoenix = [];Pima = [];Safford = [];Thatcher = [];Fort_Thomas = [];Ft_Thomas = [];Sfford = [];Solomon = [];mySelect.options[mySelect.options.length] = new Option("Fort Thomas schools",'all=Fort_Thomas');
mySelect.options[mySelect.options.length] = new Option("Ft Thomas schools",'all=Ft_Thomas');
mySelect.options[mySelect.options.length] = new Option("Phoenix schools",'all=Phoenix');
mySelect.options[mySelect.options.length] = new Option("Pima schools",'all=Pima');
mySelect.options[mySelect.options.length] = new Option("Safford schools",'all=Safford');
mySelect.options[mySelect.options.length] = new Option("Sfford schools",'all=Sfford');
mySelect.options[mySelect.options.length] = new Option("Solomon schools",'all=Solomon');
mySelect.options[mySelect.options.length] = new Option("Thatcher schools",'all=Thatcher');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Phoenix[Phoenix.length] = createMarker(new GPoint(-112.13844200,33.47670000),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Aspc - Safford/ft. Grant/a.c.i.",'Phoenix=' + Phoenix.length);
Pima[Pima.length] = createMarker(new GPoint(-109.92459869,32.92610168),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Brighter Day Preschool",'Pima=' + Pima.length);
Pima[Pima.length] = createMarker(new GPoint(-109.90879822,32.94850159),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Dan Hinton Accommodation School",'Pima=' + Pima.length);
Pima[Pima.length] = createMarker(new GPoint(-109.90879822,32.94850159),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Discovery Plus Academy",'Pima=' + Pima.length);
Pima[Pima.length] = createMarker(new GPoint(-109.92459869,32.92610168),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Discovery Plus Academy (charter)",'Pima=' + Pima.length);
Safford[Safford.length] = createMarker(new GPoint(-109.71546173,32.82773590),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Dorothy Stinson School",'Safford=' + Safford.length);
Thatcher[Thatcher.length] = createMarker(new GPoint(-109.76001900,32.84915000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Duncan High School Satellite Campus",'Thatcher=' + Thatcher.length);
Fort_Thomas[Fort_Thomas.length] = createMarker(new GPoint(-109.96579742,33.03860092),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Fort Thomas Elementary School",'Fort_Thomas=' + Fort_Thomas.length);
Ft_Thomas[Ft_Thomas.length] = createMarker(new GPoint(-109.96579742,33.03860092),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Fort Thomas High School",'Ft_Thomas=' + Ft_Thomas.length);
Thatcher[Thatcher.length] = createMarker(new GPoint(-109.76148224,32.84593582),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Ft. Thomas High School Satellite Campus",'Thatcher=' + Thatcher.length);
Safford[Safford.length] = createMarker(new GPoint(-112.55400085,34.59519958),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Gila Preparatory Academy",'Safford=' + Safford.length);
Thatcher[Thatcher.length] = createMarker(new GPoint(-109.47190094,32.70420074),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Gila Institute For Technology",'Thatcher=' + Thatcher.length);
Safford[Safford.length] = createMarker(new GPoint(-109.73255157,32.83612442),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Gila Preparatory Academy Middle School",'Safford=' + Safford.length);
Thatcher[Thatcher.length] = createMarker(new GPoint(-109.76110077,32.82979965),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Jack Daley Primary School",'Thatcher=' + Thatcher.length);
Safford[Safford.length] = createMarker(new GPoint(-109.71546173,32.82773590),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Lafe Nelson School",'Safford=' + Safford.length);
Safford[Safford.length] = createMarker(new GPoint(-109.70483398,32.86150742),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Los Milagros Academy",'Safford=' + Safford.length);
Sfford[Sfford.length] = createMarker(new GPoint(-109.71546173,32.82773590),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mt Graham High School",'Sfford=' + Sfford.length);
Thatcher[Thatcher.length] = createMarker(new GPoint(-109.76001900,32.84915000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mt. Graham High School Satellite Campus",'Thatcher=' + Thatcher.length);
Pima[Pima.length] = createMarker(new GPoint(-109.90879822,32.94850159),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Pima Elementary School",'Pima=' + Pima.length);
Thatcher[Thatcher.length] = createMarker(new GPoint(-109.76148224,32.84593582),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Pima High School Satellite Campus",'Thatcher=' + Thatcher.length);
Pima[Pima.length] = createMarker(new GPoint(-109.93090057,32.92800140),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Pima Junior High School",'Pima=' + Pima.length);
Pima[Pima.length] = createMarker(new GPoint(-109.90879822,32.94850159),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Pima Junior/senior High School",'Pima=' + Pima.length);
Safford[Safford.length] = createMarker(new GPoint(-109.72453308,32.82842255),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Ruth Powell Elementary School",'Safford=' + Safford.length);
Safford[Safford.length] = createMarker(new GPoint(-109.71546173,32.82773590),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Safford High School",'Safford=' + Safford.length);
Thatcher[Thatcher.length] = createMarker(new GPoint(-109.76148224,32.84593582),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Safford High School Satellite Campus",'Thatcher=' + Thatcher.length);
Safford[Safford.length] = createMarker(new GPoint(-109.71546173,32.82773590),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Safford Middle School",'Safford=' + Safford.length);
Solomon[Solomon.length] = createMarker(new GPoint(-109.54489899,32.74390030),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Solomon Elementary School",'Solomon=' + Solomon.length);
Thatcher[Thatcher.length] = createMarker(new GPoint(-109.76110077,32.82979965),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Thatcher Elementary School",'Thatcher=' + Thatcher.length);
Thatcher[Thatcher.length] = createMarker(new GPoint(-109.76110077,32.82979965),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Thatcher High School",'Thatcher=' + Thatcher.length);
Thatcher[Thatcher.length] = createMarker(new GPoint(-109.76148224,32.84593582),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Thatcher High School Satellite Campus",'Thatcher=' + Thatcher.length);
Thatcher[Thatcher.length] = createMarker(new GPoint(-109.76110077,32.82979965),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Thatcher Middle School",'Thatcher=' + Thatcher.length);
Safford[Safford.length] = createMarker(new GPoint(-109.70482635,32.83316422),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Triumphant Learning Center",'Safford=' + Safford.length);
Safford[Safford.length] = createMarker(new GPoint(-109.70525360,32.83319855),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Triumphant Learning Center (charter)",'Safford=' + Safford.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(Fort_Thomas);
map.removeOverlays(Ft_Thomas);
map.removeOverlays(Phoenix);
map.removeOverlays(Pima);
map.removeOverlays(Safford);
map.removeOverlays(Sfford);
map.removeOverlays(Solomon);
map.removeOverlays(Thatcher);
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(Phoenix);map.removeOverlays(Fort_Thomas);
map.removeOverlays(Ft_Thomas);
map.removeOverlays(Phoenix);
map.removeOverlays(Pima);
map.removeOverlays(Safford);
map.removeOverlays(Sfford);
map.removeOverlays(Solomon);
map.removeOverlays(Thatcher);
map.addOverlays(Fort_Thomas);
centerByArray(Fort_Thomas, false, false);
cntMarker += Fort_Thomas.length;
map.addOverlays(Ft_Thomas);
centerByArray(Ft_Thomas, false, false);
cntMarker += Ft_Thomas.length;
map.addOverlays(Phoenix);
centerByArray(Phoenix, false, false);
cntMarker += Phoenix.length;
map.addOverlays(Pima);
centerByArray(Pima, false, false);
cntMarker += Pima.length;
map.addOverlays(Safford);
centerByArray(Safford, false, false);
cntMarker += Safford.length;
map.addOverlays(Sfford);
centerByArray(Sfford, false, false);
cntMarker += Sfford.length;
map.addOverlays(Solomon);
centerByArray(Solomon, false, false);
cntMarker += Solomon.length;
map.addOverlays(Thatcher);
centerByArray(Thatcher, false, false);
cntMarker += Thatcher.length;
centerByArray(Phoenix,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');
}
}