function addMarkers()
{
mySelect = document.getElementById('selection');
Newport = [];California = [];Bellevue = [];Alexandria = [];Dayton = [];Cold_Spring = [];Highland_Heights = [];Fort_Thomas = [];Silver_Grove = [];Southgate = [];mySelect.options[mySelect.options.length] = new Option("Alexandria schools",'all=Alexandria');
mySelect.options[mySelect.options.length] = new Option("Bellevue schools",'all=Bellevue');
mySelect.options[mySelect.options.length] = new Option("California schools",'all=California');
mySelect.options[mySelect.options.length] = new Option("Cold Spring schools",'all=Cold_Spring');
mySelect.options[mySelect.options.length] = new Option("Dayton schools",'all=Dayton');
mySelect.options[mySelect.options.length] = new Option("Fort Thomas schools",'all=Fort_Thomas');
mySelect.options[mySelect.options.length] = new Option("Highland Heights schools",'all=Highland_Heights');
mySelect.options[mySelect.options.length] = new Option("Newport schools",'all=Newport');
mySelect.options[mySelect.options.length] = new Option("Silver Grove schools",'all=Silver_Grove');
mySelect.options[mySelect.options.length] = new Option("Southgate schools",'all=Southgate');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Newport[Newport.length] = createMarker(new GPoint(-84.48955536,39.08494949),"
",iconRd);
mySelect.options[mySelect.options.length] = new Option("A D Owens Elementary School",'Newport=' + Newport.length);
California[California.length] = createMarker(new GPoint(-84.28530121,38.89979935),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("A.j. Jolly Elementary School",'California=' + California.length);
Bellevue[Bellevue.length] = createMarker(new GPoint(-84.48209381,39.10187912),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bellevue High School",'Bellevue=' + Bellevue.length);
Newport[Newport.length] = createMarker(new GPoint(-84.49625397,39.09002686),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Campbell Co Reg Juvenile Det Ctr Alt School",'Newport=' + Newport.length);
Alexandria[Alexandria.length] = createMarker(new GPoint(-84.39394900,38.95726100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Campbell County Central",'Alexandria=' + Alexandria.length);
Alexandria[Alexandria.length] = createMarker(new GPoint(-84.43480682,39.01856613),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Campbell County Day Treatment Ctr Alt",'Alexandria=' + Alexandria.length);
Alexandria[Alexandria.length] = createMarker(new GPoint(-84.39277649,38.92036057),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Campbell County High School",'Alexandria=' + Alexandria.length);
Alexandria[Alexandria.length] = createMarker(new GPoint(-84.39283752,38.96456528),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Campbell County Middle School",'Alexandria=' + Alexandria.length);
Alexandria[Alexandria.length] = createMarker(new GPoint(-84.35639500,38.95944200),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Campbell Ridge Elementary School",'Alexandria=' + Alexandria.length);
Dayton[Dayton.length] = createMarker(new GPoint(-84.47114563,39.11697769),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Dayton High School",'Dayton=' + Dayton.length);
Cold_Spring[Cold_Spring.length] = createMarker(new GPoint(-84.43351746,39.01897812),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Donald E. Cline Elementary School",'Cold_Spring=' + Cold_Spring.length);
Newport[Newport.length] = createMarker(new GPoint(-84.49487305,39.09302139),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Fourth Street Elementary School",'Newport=' + Newport.length);
Bellevue[Bellevue.length] = createMarker(new GPoint(-84.47651672,39.10216904),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Grandview Elementary School",'Bellevue=' + Bellevue.length);
Alexandria[Alexandria.length] = createMarker(new GPoint(-84.39437866,38.86150742),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Grant's Lick Elementary School",'Alexandria=' + Alexandria.length);
Highland_Heights[Highland_Heights.length] = createMarker(new GPoint(-84.45159912,39.04460144),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Highland Heights Elementary School",'Highland_Heights=' + Highland_Heights.length);
Fort_Thomas[Fort_Thomas.length] = createMarker(new GPoint(-84.45104980,39.08402634),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Highlands High School",'Fort_Thomas=' + Fort_Thomas.length);
Fort_Thomas[Fort_Thomas.length] = createMarker(new GPoint(-84.45069885,39.08495712),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Highlands Middle School",'Fort_Thomas=' + Fort_Thomas.length);
Alexandria[Alexandria.length] = createMarker(new GPoint(-84.38646698,38.90328217),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("John W. Reiley Elementary School",'Alexandria=' + Alexandria.length);
Fort_Thomas[Fort_Thomas.length] = createMarker(new GPoint(-84.44730377,39.09189987),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Johnson Elementary School",'Fort_Thomas=' + Fort_Thomas.length);
Dayton[Dayton.length] = createMarker(new GPoint(-84.46334076,39.11407852),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Lincoln Elementary School",'Dayton=' + Dayton.length);
Newport[Newport.length] = createMarker(new GPoint(-84.48876190,39.09096146),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Marquette Elementary School",'Newport=' + Newport.length);
Newport[Newport.length] = createMarker(new GPoint(-84.47710419,39.08822632),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Mildred Dean Elementary School",'Newport=' + Newport.length);
Fort_Thomas[Fort_Thomas.length] = createMarker(new GPoint(-84.45354462,39.07649231),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Moyer Elementary School",'Fort_Thomas=' + Fort_Thomas.length);
Newport[Newport.length] = createMarker(new GPoint(-84.48522949,39.09613037),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Newport High School",'Newport=' + Newport.length);
Newport[Newport.length] = createMarker(new GPoint(-84.49364471,39.08822632),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Newport Middle School",'Newport=' + Newport.length);
Newport[Newport.length] = createMarker(new GPoint(-84.48876190,39.09096146),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Northern Ky Learning Academy Alt School",'Newport=' + Newport.length);
Alexandria[Alexandria.length] = createMarker(new GPoint(-84.39052000,38.96453900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Northern Ky Learning Academy Alt School",'Alexandria=' + Alexandria.length);
Cold_Spring[Cold_Spring.length] = createMarker(new GPoint(-84.43480682,39.01856613),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Phoenix Program Special Education",'Cold_Spring=' + Cold_Spring.length);
Silver_Grove[Silver_Grove.length] = createMarker(new GPoint(-84.39044189,39.03377914),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Silver Grove School",'Silver_Grove=' + Silver_Grove.length);
Southgate[Southgate.length] = createMarker(new GPoint(-84.47332001,39.07265854),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Southgate Elementary School",'Southgate=' + Southgate.length);
Fort_Thomas[Fort_Thomas.length] = createMarker(new GPoint(-84.45144653,39.05905533),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Woodfill Elementary School",'Fort_Thomas=' + Fort_Thomas.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(Alexandria);
map.removeOverlays(Bellevue);
map.removeOverlays(California);
map.removeOverlays(Cold_Spring);
map.removeOverlays(Dayton);
map.removeOverlays(Fort_Thomas);
map.removeOverlays(Highland_Heights);
map.removeOverlays(Newport);
map.removeOverlays(Silver_Grove);
map.removeOverlays(Southgate);
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(Newport);map.removeOverlays(Alexandria);
map.removeOverlays(Bellevue);
map.removeOverlays(California);
map.removeOverlays(Cold_Spring);
map.removeOverlays(Dayton);
map.removeOverlays(Fort_Thomas);
map.removeOverlays(Highland_Heights);
map.removeOverlays(Newport);
map.removeOverlays(Silver_Grove);
map.removeOverlays(Southgate);
map.addOverlays(Alexandria);
centerByArray(Alexandria, false, false);
cntMarker += Alexandria.length;
map.addOverlays(Bellevue);
centerByArray(Bellevue, false, false);
cntMarker += Bellevue.length;
map.addOverlays(California);
centerByArray(California, false, false);
cntMarker += California.length;
map.addOverlays(Cold_Spring);
centerByArray(Cold_Spring, false, false);
cntMarker += Cold_Spring.length;
map.addOverlays(Dayton);
centerByArray(Dayton, false, false);
cntMarker += Dayton.length;
map.addOverlays(Fort_Thomas);
centerByArray(Fort_Thomas, false, false);
cntMarker += Fort_Thomas.length;
map.addOverlays(Highland_Heights);
centerByArray(Highland_Heights, false, false);
cntMarker += Highland_Heights.length;
map.addOverlays(Newport);
centerByArray(Newport, false, false);
cntMarker += Newport.length;
map.addOverlays(Silver_Grove);
centerByArray(Silver_Grove, false, false);
cntMarker += Silver_Grove.length;
map.addOverlays(Southgate);
centerByArray(Southgate, false, false);
cntMarker += Southgate.length;
centerByArray(Newport,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');
}
}