function addMarkers(){
mySelect = document.getElementById('selection');
Clemmons = [];Winston_Salem = [];Kernersville = [];Lewisville = [];Walkertown = [];mySelect.options[mySelect.options.length] = new Option("Clemmons schools",'all=Clemmons');
mySelect.options[mySelect.options.length] = new Option("Kernersville schools",'all=Kernersville');
mySelect.options[mySelect.options.length] = new Option("Lewisville schools",'all=Lewisville');
mySelect.options[mySelect.options.length] = new Option("Walkertown schools",'all=Walkertown');
mySelect.options[mySelect.options.length] = new Option("Winston Salem schools",'all=Winston_Salem');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Clemmons[Clemmons.length] = createMarker(new GPoint(-80.37930000,36.01840000),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Agape Faith Christian Academy",'Clemmons=' + Clemmons.length);
Winston_Salem[Winston_Salem.length] = createMarker(new GPoint(-80.18197900,36.04028900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Berean Baptist Christian School",'Winston_Salem=' + Winston_Salem.length);
Kernersville[Kernersville.length] = createMarker(new GPoint(-80.06258700,36.07803000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bishop Mc Guinness High School",'Kernersville=' + Kernersville.length);
Kernersville[Kernersville.length] = createMarker(new GPoint(-80.07055800,36.13601400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Brookside Montessori School",'Kernersville=' + Kernersville.length);
Winston_Salem[Winston_Salem.length] = createMarker(new GPoint(-80.34825700,36.08446100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Calvary Baptist Day School",'Winston_Salem=' + Winston_Salem.length);
Winston_Salem[Winston_Salem.length] = createMarker(new GPoint(-80.33436900,36.16135400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cedar Forest Christian School",'Winston_Salem=' + Winston_Salem.length);
Winston_Salem[Winston_Salem.length] = createMarker(new GPoint(-80.23048700,36.10995000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Ephesus Jr Academy",'Winston_Salem=' + Winston_Salem.length);
Winston_Salem[Winston_Salem.length] = createMarker(new GPoint(-80.27678100,36.14177800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("First Assembly Christian School",'Winston_Salem=' + Winston_Salem.length);
Kernersville[Kernersville.length] = createMarker(new GPoint(-80.05058200,36.13902600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("First Christian Academy & Preschool",'Kernersville=' + Kernersville.length);
Lewisville[Lewisville.length] = createMarker(new GPoint(-80.42401100,36.09513300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Forsyth Country Day School",'Lewisville=' + Lewisville.length);
Kernersville[Kernersville.length] = createMarker(new GPoint(-80.09967600,36.11779700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Fountain Of Life Lutheran Ps",'Kernersville=' + Kernersville.length);
Walkertown[Walkertown.length] = createMarker(new GPoint(-80.15870000,36.17900000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Gospel Light Christian School",'Walkertown=' + Walkertown.length);
Winston_Salem[Winston_Salem.length] = createMarker(new GPoint(-80.37393400,36.11789300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Greenhills School",'Winston_Salem=' + Winston_Salem.length);
Winston_Salem[Winston_Salem.length] = createMarker(new GPoint(-80.31030000,36.07580000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Jefferson Day School",'Winston_Salem=' + Winston_Salem.length);
Winston_Salem[Winston_Salem.length] = createMarker(new GPoint(-80.26468900,36.10461000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Kingswood School",'Winston_Salem=' + Winston_Salem.length);
Winston_Salem[Winston_Salem.length] = createMarker(new GPoint(-80.32262900,36.07712900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Montessori School Of Winston-salem",'Winston_Salem=' + Winston_Salem.length);
Winston_Salem[Winston_Salem.length] = createMarker(new GPoint(-80.26148800,36.07067000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Our Lady Of Mercy School",'Winston_Salem=' + Winston_Salem.length);
Winston_Salem[Winston_Salem.length] = createMarker(new GPoint(-80.21103700,36.15086300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Quality Education Institute",'Winston_Salem=' + Winston_Salem.length);
Winston_Salem[Winston_Salem.length] = createMarker(new GPoint(-80.27356900,36.07975900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Redeemer School",'Winston_Salem=' + Winston_Salem.length);
Winston_Salem[Winston_Salem.length] = createMarker(new GPoint(-80.28574000,36.12559500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Reynolda Presbyterian Preschool and Kindergarten",'Winston_Salem=' + Winston_Salem.length);
Winston_Salem[Winston_Salem.length] = createMarker(new GPoint(-80.28200300,36.07009800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Johns Lutheran Day School",'Winston_Salem=' + Winston_Salem.length);
Winston_Salem[Winston_Salem.length] = createMarker(new GPoint(-80.27360500,36.10115100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Leo Parish School",'Winston_Salem=' + Winston_Salem.length);
Winston_Salem[Winston_Salem.length] = createMarker(new GPoint(-80.25742700,36.09929200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Pauls Episcopal Preschool",'Winston_Salem=' + Winston_Salem.length);
Winston_Salem[Winston_Salem.length] = createMarker(new GPoint(-80.23736300,36.08929100),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Salem Academy",'Winston_Salem=' + Winston_Salem.length);
Winston_Salem[Winston_Salem.length] = createMarker(new GPoint(-80.24973200,36.08888000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Salem Baptist Christian School",'Winston_Salem=' + Winston_Salem.length);
Winston_Salem[Winston_Salem.length] = createMarker(new GPoint(-80.28451400,36.12423800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Summit School",'Winston_Salem=' + Winston_Salem.length);
Kernersville[Kernersville.length] = createMarker(new GPoint(-80.10152200,36.10641500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Triad Baptist Christian Academy",'Kernersville=' + Kernersville.length);
Clemmons[Clemmons.length] = createMarker(new GPoint(-80.37072100,35.99335600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Victory Christian School",'Clemmons=' + Clemmons.length);
Winston_Salem[Winston_Salem.length] = createMarker(new GPoint(-80.31789100,36.07791500),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Vineyard School",'Winston_Salem=' + Winston_Salem.length);
Winston_Salem[Winston_Salem.length] = createMarker(new GPoint(-80.24362400,36.14085900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Woodland Baptist Christian 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,11);
/*
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/////3/' + showArray);
map.removeOverlays(Clemmons);
map.removeOverlays(Kernersville);
map.removeOverlays(Lewisville);
map.removeOverlays(Walkertown);
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(Clemmons);map.removeOverlays(Clemmons);
map.removeOverlays(Kernersville);
map.removeOverlays(Lewisville);
map.removeOverlays(Walkertown);
map.removeOverlays(Winston_Salem);
map.addOverlays(Clemmons);
centerByArray(Clemmons, false, false);
cntMarker += Clemmons.length;
map.addOverlays(Kernersville);
centerByArray(Kernersville, false, false);
cntMarker += Kernersville.length;
map.addOverlays(Lewisville);
centerByArray(Lewisville, false, false);
cntMarker += Lewisville.length;
map.addOverlays(Walkertown);
centerByArray(Walkertown, false, false);
cntMarker += Walkertown.length;
map.addOverlays(Winston_Salem);
centerByArray(Winston_Salem, false, false);
cntMarker += Winston_Salem.length;
centerByArray(Clemmons,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');
//window.open('/map.php?type=1&schools=&school_level=3&radius=&zipcode=&school_type_search=&school_type_code=');
}
}
function createMarker(point, label, icon)
{
var marker = new GMarker(point, icon);
var html = label;
GEvent.addListener(marker, "click", function() {
marker.openInfoWindowHtml(html);
});
return marker;
}