function addMarkers()
{
mySelect = document.getElementById('selection');
Winston_Salem = [];Winston_Salem[Winston_Salem.length] = createMarker(new GPoint(-80.26432037,36.03951645),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("12th Street Academy",'Winston_Salem=' + Winston_Salem.length);
Winston_Salem[Winston_Salem.length] = createMarker(new GPoint(-80.29011536,36.07463455),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Bolton Elementary School",'Winston_Salem=' + Winston_Salem.length);
Winston_Salem[Winston_Salem.length] = createMarker(new GPoint(-80.26552582,36.09478760),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Brunson Elementary School",'Winston_Salem=' + Winston_Salem.length);
Winston_Salem[Winston_Salem.length] = createMarker(new GPoint(-80.30999756,36.06549835),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Career Center",'Winston_Salem=' + Winston_Salem.length);
Winston_Salem[Winston_Salem.length] = createMarker(new GPoint(-80.20881653,36.13463211),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Carver High School",'Winston_Salem=' + Winston_Salem.length);
Winston_Salem[Winston_Salem.length] = createMarker(new GPoint(-80.27966309,36.11649323),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Children's Center",'Winston_Salem=' + Winston_Salem.length);
Winston_Salem[Winston_Salem.length] = createMarker(new GPoint(-80.23202515,36.07880783),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Diggs Elementary School",'Winston_Salem=' + Winston_Salem.length);
Winston_Salem[Winston_Salem.length] = createMarker(new GPoint(-80.24745941,36.10127258),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Downtown School",'Winston_Salem=' + Winston_Salem.length);
Winston_Salem[Winston_Salem.length] = createMarker(new GPoint(-80.22335052,36.05631638),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Easton Elementary School",'Winston_Salem=' + Winston_Salem.length);
Winston_Salem[Winston_Salem.length] = createMarker(new GPoint(-80.21717072,36.07296371),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Forest Park Elementary School",'Winston_Salem=' + Winston_Salem.length);
Winston_Salem[Winston_Salem.length] = createMarker(new GPoint(-80.23867035,36.06286240),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Forsyth Vocational High School",'Winston_Salem=' + Winston_Salem.length);
Winston_Salem[Winston_Salem.length] = createMarker(new GPoint(-80.26366425,36.03968811),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Griffith Elementary School",'Winston_Salem=' + Winston_Salem.length);
Winston_Salem[Winston_Salem.length] = createMarker(new GPoint(-80.17613220,36.07914352),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Hall-woodward Elementary School",'Winston_Salem=' + Winston_Salem.length);
Winston_Salem[Winston_Salem.length] = createMarker(new GPoint(-80.23683167,36.12676239),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Hanes Middle School",'Winston_Salem=' + Winston_Salem.length);
Winston_Salem[Winston_Salem.length] = createMarker(new GPoint(-80.20565796,36.06866074),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Hill Middle School",'Winston_Salem=' + Winston_Salem.length);
Winston_Salem[Winston_Salem.length] = createMarker(new GPoint(-80.20282745,36.15800095),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Ibraham Elementary School",'Winston_Salem=' + Winston_Salem.length);
Winston_Salem[Winston_Salem.length] = createMarker(new GPoint(-80.24334717,36.09997940),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Kimberley Park Elementary School",'Winston_Salem=' + Winston_Salem.length);
Winston_Salem[Winston_Salem.length] = createMarker(new GPoint(-80.24593353,36.05144882),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Konnoak Elementary School",'Winston_Salem=' + Winston_Salem.length);
Winston_Salem[Winston_Salem.length] = createMarker(new GPoint(-80.25534058,36.07809830),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Latham Elementary School",'Winston_Salem=' + Winston_Salem.length);
Winston_Salem[Winston_Salem.length] = createMarker(new GPoint(-80.23332214,36.10676193),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Leap At Kennedy Middle School",'Winston_Salem=' + Winston_Salem.length);
Winston_Salem[Winston_Salem.length] = createMarker(new GPoint(-80.23683167,36.12676239),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lowrance Middle School",'Winston_Salem=' + Winston_Salem.length);
Winston_Salem[Winston_Salem.length] = createMarker(new GPoint(-80.23612976,36.15644073),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Mineral Springs Elementary School",'Winston_Salem=' + Winston_Salem.length);
Winston_Salem[Winston_Salem.length] = createMarker(new GPoint(-80.23612976,36.15742493),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Mineral Springs Middle School",'Winston_Salem=' + Winston_Salem.length);
Winston_Salem[Winston_Salem.length] = createMarker(new GPoint(-80.28607941,36.08742905),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Moore Elementary School",'Winston_Salem=' + Winston_Salem.length);
Winston_Salem[Winston_Salem.length] = createMarker(new GPoint(-80.31346893,36.12781525),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mount Tabor High School",'Winston_Salem=' + Winston_Salem.length);
Winston_Salem[Winston_Salem.length] = createMarker(new GPoint(-80.28405762,36.16902924),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("North Forsyth High School",'Winston_Salem=' + Winston_Salem.length);
Winston_Salem[Winston_Salem.length] = createMarker(new GPoint(-80.30927277,36.19181824),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Northwest Middle School",'Winston_Salem=' + Winston_Salem.length);
Winston_Salem[Winston_Salem.length] = createMarker(new GPoint(-80.33181763,36.16542816),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Old Town Elementary School",'Winston_Salem=' + Winston_Salem.length);
Winston_Salem[Winston_Salem.length] = createMarker(new GPoint(-80.25827026,36.11346436),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Paisley Middle School",'Winston_Salem=' + Winston_Salem.length);
Winston_Salem[Winston_Salem.length] = createMarker(new GPoint(-80.25767517,36.05537033),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Parkland High School",'Winston_Salem=' + Winston_Salem.length);
Winston_Salem[Winston_Salem.length] = createMarker(new GPoint(-80.24623871,36.05347443),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Philo Middle School",'Winston_Salem=' + Winston_Salem.length);
Winston_Salem[Winston_Salem.length] = createMarker(new GPoint(-80.26654053,36.10085678),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Reynolds High School",'Winston_Salem=' + Winston_Salem.length);
Winston_Salem[Winston_Salem.length] = createMarker(new GPoint(-80.31029510,36.10551071),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Sherwood Forest Elementary School",'Winston_Salem=' + Winston_Salem.length);
Winston_Salem[Winston_Salem.length] = createMarker(new GPoint(-80.32467651,36.08504868),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("South Fork Elementary School",'Winston_Salem=' + Winston_Salem.length);
Winston_Salem[Winston_Salem.length] = createMarker(new GPoint(-80.29653931,36.13100433),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Speas Elementary School",'Winston_Salem=' + Winston_Salem.length);
Winston_Salem[Winston_Salem.length] = createMarker(new GPoint(-80.28433228,36.10675049),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Whitaker Elementary School",'Winston_Salem=' + Winston_Salem.length);
Winston_Salem[Winston_Salem.length] = createMarker(new GPoint(-80.26243591,36.10200882),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Wiley Middle School",'Winston_Salem=' + Winston_Salem.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(Winston_Salem);
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(Winston_Salem);map.removeOverlays(Winston_Salem);
map.addOverlays(Winston_Salem);
centerByArray(Winston_Salem, false, false);
cntMarker += Winston_Salem.length;
centerByArray(Winston_Salem,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');
}
}