function addMarkers()
{
mySelect = document.getElementById('selection');
Richmond = [];Midlothian = [];Bon_Air = [];Chester = [];Chesterfield = [];Ettrick = [];Moseley = [];Colonial_Heights = [];Matoaca = [];mySelect.options[mySelect.options.length] = new Option("Bon Air schools",'all=Bon_Air');
mySelect.options[mySelect.options.length] = new Option("Chester schools",'all=Chester');
mySelect.options[mySelect.options.length] = new Option("Chesterfield schools",'all=Chesterfield');
mySelect.options[mySelect.options.length] = new Option("Colonial Heights schools",'all=Colonial_Heights');
mySelect.options[mySelect.options.length] = new Option("Ettrick schools",'all=Ettrick');
mySelect.options[mySelect.options.length] = new Option("Matoaca schools",'all=Matoaca');
mySelect.options[mySelect.options.length] = new Option("Midlothian schools",'all=Midlothian');
mySelect.options[mySelect.options.length] = new Option("Moseley schools",'all=Moseley');
mySelect.options[mySelect.options.length] = new Option("Richmond schools",'all=Richmond');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Richmond[Richmond.length] = createMarker(new GPoint(-77.54689789,37.49160004),"
",iconRd);
mySelect.options[mySelect.options.length] = new Option("A. M. Davis Elementary School",'Richmond=' + Richmond.length);
Midlothian[Midlothian.length] = createMarker(new GPoint(-77.63885498,37.39755630),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Alberta Smith Elementary School",'Midlothian=' + Midlothian.length);
Midlothian[Midlothian.length] = createMarker(new GPoint(-77.62200928,37.40898895),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Bailey Bridge Middle School",'Midlothian=' + Midlothian.length);
Richmond[Richmond.length] = createMarker(new GPoint(-77.43959808,37.39126968),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Bellwood Elementary School",'Richmond=' + Richmond.length);
Richmond[Richmond.length] = createMarker(new GPoint(-77.45048523,37.43587494),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Bensley Elementary School",'Richmond=' + Richmond.length);
Midlothian[Midlothian.length] = createMarker(new GPoint(-77.65301514,37.54748154),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Bettie Weaver Elementary School",'Midlothian=' + Midlothian.length);
Richmond[Richmond.length] = createMarker(new GPoint(-77.46928406,37.42495346),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Beulah Elementary School",'Richmond=' + Richmond.length);
Bon_Air[Bon_Air.length] = createMarker(new GPoint(-77.56030273,37.53044891),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Bon Air Elementary School",'Bon_Air=' + Bon_Air.length);
Bon_Air[Bon_Air.length] = createMarker(new GPoint(-77.57643890,37.51455307),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bon Air Expansion Corr Center",'Bon_Air=' + Bon_Air.length);
Chester[Chester.length] = createMarker(new GPoint(-77.44069672,37.33707047),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("C. C. Wells Elementary School",'Chester=' + Chester.length);
Chester[Chester.length] = createMarker(new GPoint(-77.43442535,37.35996628),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("C. E. Curtis Elementary School",'Chester=' + Chester.length);
Chester[Chester.length] = createMarker(new GPoint(-77.42632294,37.30307770),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Carver Middle School",'Chester=' + Chester.length);
Chester[Chester.length] = createMarker(new GPoint(-77.44002533,37.35863876),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Chester Middle School",'Chester=' + Chester.length);
Chester[Chester.length] = createMarker(new GPoint(-77.47154236,37.34841537),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Chesterfield Community High School",'Chester=' + Chester.length);
Chesterfield[Chesterfield.length] = createMarker(new GPoint(-77.49888700,37.38142900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Chesterfield Juvenile Detention Home",'Chesterfield=' + Chesterfield.length);
Chesterfield[Chesterfield.length] = createMarker(new GPoint(-77.50110626,37.38743591),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Chesterfield Tech.",'Chesterfield=' + Chesterfield.length);
Midlothian[Midlothian.length] = createMarker(new GPoint(-77.67176819,37.41923523),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Clover Hill Elementary School",'Midlothian=' + Midlothian.length);
Midlothian[Midlothian.length] = createMarker(new GPoint(-77.66183472,37.40554428),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Clover Hill High School",'Midlothian=' + Midlothian.length);
Richmond[Richmond.length] = createMarker(new GPoint(-77.50664900,37.51747000),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Crestwood Elementary School",'Richmond=' + Richmond.length);
Chester[Chester.length] = createMarker(new GPoint(-77.46253967,37.35959244),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Ecoff Elementary School",'Chester=' + Chester.length);
Chester[Chester.length] = createMarker(new GPoint(-77.32321167,37.33070755),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Enon Elementary School",'Chester=' + Chester.length);
Ettrick[Ettrick.length] = createMarker(new GPoint(-77.42692566,37.23844528),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Ettrick Elementary School",'Ettrick=' + Ettrick.length);
Midlothian[Midlothian.length] = createMarker(new GPoint(-77.63283539,37.46456909),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Evergreen Elementary School",'Midlothian=' + Midlothian.length);
Richmond[Richmond.length] = createMarker(new GPoint(-77.46888733,37.45727158),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Falling Creek Elementary School",'Richmond=' + Richmond.length);
Richmond[Richmond.length] = createMarker(new GPoint(-77.46871185,37.45899582),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Falling Creek Middle School",'Richmond=' + Richmond.length);
Moseley[Moseley.length] = createMarker(new GPoint(-77.76512909,37.38943481),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Grange Hall Elementary School",'Moseley=' + Moseley.length);
Richmond[Richmond.length] = createMarker(new GPoint(-77.59129333,37.51987457),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Greenfield Elementary School",'Richmond=' + Richmond.length);
Chester[Chester.length] = createMarker(new GPoint(-77.42717743,37.30609512),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Harrowgate Elementary School",'Chester=' + Chester.length);
Richmond[Richmond.length] = createMarker(new GPoint(-77.47338867,37.43692780),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Hopkins Road Elementary School",'Richmond=' + Richmond.length);
Chesterfield[Chesterfield.length] = createMarker(new GPoint(-77.51965332,37.46425629),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("J. A. Chalkley Elementary School",'Chesterfield=' + Chesterfield.length);
Midlothian[Midlothian.length] = createMarker(new GPoint(-77.65353394,37.49464035),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("J. B. Watkins Elementary School",'Midlothian=' + Midlothian.length);
Richmond[Richmond.length] = createMarker(new GPoint(-77.48904419,37.44631958),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("J. G. Hening Elementary School",'Richmond=' + Richmond.length);
Chesterfield[Chesterfield.length] = createMarker(new GPoint(-77.55293274,37.43363571),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Jacobs Road Elementary School",'Chesterfield=' + Chesterfield.length);
Midlothian[Midlothian.length] = createMarker(new GPoint(-77.64855957,37.55100250),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("James River High School",'Midlothian=' + Midlothian.length);
Bon_Air[Bon_Air.length] = createMarker(new GPoint(-77.57643890,37.51455307),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Joseph Mastin School @ Bon Air",'Bon_Air=' + Bon_Air.length);
Chesterfield[Chesterfield.length] = createMarker(new GPoint(-77.49720001,37.38743591),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lloyd C. Bird High School",'Chesterfield=' + Chesterfield.length);
Midlothian[Midlothian.length] = createMarker(new GPoint(-77.62416077,37.40771103),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Manchester High School",'Midlothian=' + Midlothian.length);
Richmond[Richmond.length] = createMarker(new GPoint(-77.52919769,37.47025681),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Manchester Middle School",'Richmond=' + Richmond.length);
Colonial_Heights[Colonial_Heights.length] = createMarker(new GPoint(-77.39226532,37.32209015),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Marguerite F. Christian Elementary School",'Colonial_Heights=' + Colonial_Heights.length);
Matoaca[Matoaca.length] = createMarker(new GPoint(-77.48205900,37.23087000),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Matoaca Elementary School",'Matoaca=' + Matoaca.length);
Chesterfield[Chesterfield.length] = createMarker(new GPoint(-77.48480225,37.28710175),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Matoaca High School",'Chesterfield=' + Chesterfield.length);
Matoaca[Matoaca.length] = createMarker(new GPoint(-77.47493744,37.24614334),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Matoaca Middle School",'Matoaca=' + Matoaca.length);
Richmond[Richmond.length] = createMarker(new GPoint(-77.48297119,37.43680191),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Meadowbrook High School",'Richmond=' + Richmond.length);
Midlothian[Midlothian.length] = createMarker(new GPoint(-77.66159058,37.49886703),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Midlothian High School",'Midlothian=' + Midlothian.length);
Midlothian[Midlothian.length] = createMarker(new GPoint(-77.64926147,37.50292587),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Midlothian Middle School",'Midlothian=' + Midlothian.length);
Richmond[Richmond.length] = createMarker(new GPoint(-77.61213684,37.48196411),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Monacan High School",'Richmond=' + Richmond.length);
Chesterfield[Chesterfield.length] = createMarker(new GPoint(-77.50602722,37.37704849),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("O. B. Gates Elementary School",'Chesterfield=' + Chesterfield.length);
Bon_Air[Bon_Air.length] = createMarker(new GPoint(-77.57369995,37.51844025),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Oak Ridge Juvenile Correctional Center",'Bon_Air=' + Bon_Air.length);
Richmond[Richmond.length] = createMarker(new GPoint(-77.43566895,37.40586472),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Perrymont Middle School",'Richmond=' + Richmond.length);
Richmond[Richmond.length] = createMarker(new GPoint(-77.60169983,37.45926666),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Providence Elementary School",'Richmond=' + Richmond.length);
Richmond[Richmond.length] = createMarker(new GPoint(-77.54207611,37.48840332),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Providence Middle School",'Richmond=' + Richmond.length);
Richmond[Richmond.length] = createMarker(new GPoint(-77.58553314,37.48763657),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Reams Road Elementary School",'Richmond=' + Richmond.length);
Bon_Air[Bon_Air.length] = createMarker(new GPoint(-77.57486725,37.51684952),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Reception And Diagnostic Cntr",'Bon_Air=' + Bon_Air.length);
Midlothian[Midlothian.length] = createMarker(new GPoint(-77.61454773,37.53072739),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Robious Elementary School",'Midlothian=' + Midlothian.length);
Midlothian[Midlothian.length] = createMarker(new GPoint(-77.61470795,37.52923965),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Robious Middle School",'Midlothian=' + Midlothian.length);
Richmond[Richmond.length] = createMarker(new GPoint(-77.48344421,37.38470840),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Salem Church Elementary School",'Richmond=' + Richmond.length);
Richmond[Richmond.length] = createMarker(new GPoint(-77.48583984,37.38283920),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Salem Church Middle School",'Richmond=' + Richmond.length);
Richmond[Richmond.length] = createMarker(new GPoint(-77.41156006,37.57770157),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Specialized Programs - Headstart Elementary School",'Richmond=' + Richmond.length);
Midlothian[Midlothian.length] = createMarker(new GPoint(-77.65274048,37.38423157),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Spring Run Elementary School",'Midlothian=' + Midlothian.length);
Midlothian[Midlothian.length] = createMarker(new GPoint(-77.64968600,37.42558100),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Swift Creek Elementary School",'Midlothian=' + Midlothian.length);
Midlothian[Midlothian.length] = createMarker(new GPoint(-77.64452362,37.44180679),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Swift Creek Middle School",'Midlothian=' + Midlothian.length);
Midlothian[Midlothian.length] = createMarker(new GPoint(-77.61016846,37.41847610),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Thelma Crenshaw Elementary School",'Midlothian=' + Midlothian.length);
Chester[Chester.length] = createMarker(new GPoint(-77.43490601,37.36003876),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Thomas Dale High School",'Chester=' + Chester.length);
Richmond[Richmond.length] = createMarker(new GPoint(-77.61624908,37.47880173),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("W. W. Gordon Elementary School",'Richmond=' + Richmond.length);
Midlothian[Midlothian.length] = createMarker(new GPoint(-77.69290161,37.42688370),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Woolridge Elementary School",'Midlothian=' + Midlothian.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(Bon_Air);
map.removeOverlays(Chester);
map.removeOverlays(Chesterfield);
map.removeOverlays(Colonial_Heights);
map.removeOverlays(Ettrick);
map.removeOverlays(Matoaca);
map.removeOverlays(Midlothian);
map.removeOverlays(Moseley);
map.removeOverlays(Richmond);
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(Richmond);map.removeOverlays(Bon_Air);
map.removeOverlays(Chester);
map.removeOverlays(Chesterfield);
map.removeOverlays(Colonial_Heights);
map.removeOverlays(Ettrick);
map.removeOverlays(Matoaca);
map.removeOverlays(Midlothian);
map.removeOverlays(Moseley);
map.removeOverlays(Richmond);
map.addOverlays(Bon_Air);
centerByArray(Bon_Air, false, false);
cntMarker += Bon_Air.length;
map.addOverlays(Chester);
centerByArray(Chester, false, false);
cntMarker += Chester.length;
map.addOverlays(Chesterfield);
centerByArray(Chesterfield, false, false);
cntMarker += Chesterfield.length;
map.addOverlays(Colonial_Heights);
centerByArray(Colonial_Heights, false, false);
cntMarker += Colonial_Heights.length;
map.addOverlays(Ettrick);
centerByArray(Ettrick, false, false);
cntMarker += Ettrick.length;
map.addOverlays(Matoaca);
centerByArray(Matoaca, false, false);
cntMarker += Matoaca.length;
map.addOverlays(Midlothian);
centerByArray(Midlothian, false, false);
cntMarker += Midlothian.length;
map.addOverlays(Moseley);
centerByArray(Moseley, false, false);
cntMarker += Moseley.length;
map.addOverlays(Richmond);
centerByArray(Richmond, false, false);
cntMarker += Richmond.length;
centerByArray(Richmond,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');
}
}