function addMarkers(){
mySelect = document.getElementById('selection');
Fayetteville = [];Raleigh = [];Charlotte = [];Albemarle = [];Candler = [];High_Point = [];Winterville = [];Fletcher = [];Statesville = [];Winston_Salem = [];Durham = [];Franklin = [];Haw_River = [];Banner_Elk = [];Hickory = [];La_Grange = [];Wilson = [];Murphy = [];Greensboro = [];Wilmington = [];Whiteville = [];Salisbury = [];Morganton = [];Lynn = [];Flat_Rock = [];Waynesville = [];mySelect.options[mySelect.options.length] = new Option("Albemarle schools",'all=Albemarle');
mySelect.options[mySelect.options.length] = new Option("Banner Elk schools",'all=Banner_Elk');
mySelect.options[mySelect.options.length] = new Option("Candler schools",'all=Candler');
mySelect.options[mySelect.options.length] = new Option("Charlotte schools",'all=Charlotte');
mySelect.options[mySelect.options.length] = new Option("Durham schools",'all=Durham');
mySelect.options[mySelect.options.length] = new Option("Fayetteville schools",'all=Fayetteville');
mySelect.options[mySelect.options.length] = new Option("Flat Rock schools",'all=Flat_Rock');
mySelect.options[mySelect.options.length] = new Option("Fletcher schools",'all=Fletcher');
mySelect.options[mySelect.options.length] = new Option("Franklin schools",'all=Franklin');
mySelect.options[mySelect.options.length] = new Option("Greensboro schools",'all=Greensboro');
mySelect.options[mySelect.options.length] = new Option("Haw River schools",'all=Haw_River');
mySelect.options[mySelect.options.length] = new Option("Hickory schools",'all=Hickory');
mySelect.options[mySelect.options.length] = new Option("High Point schools",'all=High_Point');
mySelect.options[mySelect.options.length] = new Option("La Grange schools",'all=La_Grange');
mySelect.options[mySelect.options.length] = new Option("Lynn schools",'all=Lynn');
mySelect.options[mySelect.options.length] = new Option("Morganton schools",'all=Morganton');
mySelect.options[mySelect.options.length] = new Option("Murphy schools",'all=Murphy');
mySelect.options[mySelect.options.length] = new Option("Raleigh schools",'all=Raleigh');
mySelect.options[mySelect.options.length] = new Option("Salisbury schools",'all=Salisbury');
mySelect.options[mySelect.options.length] = new Option("Statesville schools",'all=Statesville');
mySelect.options[mySelect.options.length] = new Option("Waynesville schools",'all=Waynesville');
mySelect.options[mySelect.options.length] = new Option("Whiteville schools",'all=Whiteville');
mySelect.options[mySelect.options.length] = new Option("Wilmington schools",'all=Wilmington');
mySelect.options[mySelect.options.length] = new Option("Wilson schools",'all=Wilson');
mySelect.options[mySelect.options.length] = new Option("Winston Salem schools",'all=Winston_Salem');
mySelect.options[mySelect.options.length] = new Option("Winterville schools",'all=Winterville');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Fayetteville[Fayetteville.length] = createMarker(new GPoint(-78.89292700,35.09810900),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Abney Chapel Sda Christian School",'Fayetteville=' + Fayetteville.length);
Raleigh[Raleigh.length] = createMarker(new GPoint(-78.72126700,35.74860400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Adventist Christian Academy",'Raleigh=' + Raleigh.length);
Charlotte[Charlotte.length] = createMarker(new GPoint(-80.78731500,35.17880500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Adventist Christian Academy",'Charlotte=' + Charlotte.length);
Fayetteville[Fayetteville.length] = createMarker(new GPoint(-78.93350000,34.98880000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Adventist Christian School",'Fayetteville=' + Fayetteville.length);
Albemarle[Albemarle.length] = createMarker(new GPoint(-80.22480600,35.36856300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Albemarle Sda School",'Albemarle=' + Albemarle.length);
Candler[Candler.length] = createMarker(new GPoint(-82.67056200,35.56866200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Asheville Pisgah Church School",'Candler=' + Candler.length);
High_Point[High_Point.length] = createMarker(new GPoint(-79.99122800,35.95904500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Baldwins Chapel Sda Elementary School",'High_Point=' + High_Point.length);
Charlotte[Charlotte.length] = createMarker(new GPoint(-80.85815800,35.28580800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Berean Jr Academy",'Charlotte=' + Charlotte.length);
Winterville[Winterville.length] = createMarker(new GPoint(-77.41651200,35.53216000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Brookhaven Sda School",'Winterville=' + Winterville.length);
Fletcher[Fletcher.length] = createMarker(new GPoint(-82.49500000,35.43930000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Captain Gilmer School",'Fletcher=' + Fletcher.length);
Statesville[Statesville.length] = createMarker(new GPoint(-80.84118200,35.79591200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Crossroads Adventist Christian School",'Statesville=' + Statesville.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);
Durham[Durham.length] = createMarker(new GPoint(-78.98384300,35.94275800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Five Oaks Seventh-day Adventist Christian School",'Durham=' + Durham.length);
Fletcher[Fletcher.length] = createMarker(new GPoint(-82.48348400,35.44775900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Fletcher Academy",'Fletcher=' + Fletcher.length);
Franklin[Franklin.length] = createMarker(new GPoint(-83.38010000,35.18070000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Franklin Adventist School",'Franklin=' + Franklin.length);
Raleigh[Raleigh.length] = createMarker(new GPoint(-78.61382600,35.74480300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Gethsemane Sda School",'Raleigh=' + Raleigh.length);
Haw_River[Haw_River.length] = createMarker(new GPoint(-79.34873400,36.09573400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Haw River Christian School",'Haw_River=' + Haw_River.length);
Banner_Elk[Banner_Elk.length] = createMarker(new GPoint(-81.86037000,36.14541800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("High Country Christian School",'Banner_Elk=' + Banner_Elk.length);
Hickory[Hickory.length] = createMarker(new GPoint(-81.37776500,35.73403900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Johnston, Wm. Elementary School",'Hickory=' + Hickory.length);
La_Grange[La_Grange.length] = createMarker(new GPoint(-77.81851200,35.38287000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Jw Jackson Adventist Academy",'La_Grange=' + La_Grange.length);
Candler[Candler.length] = createMarker(new GPoint(-82.67085800,35.56880700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mount Pisgah Academy",'Candler=' + Candler.length);
Wilson[Wilson.length] = createMarker(new GPoint(-77.91571000,35.71411100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mt Hebron Adventist Christian School",'Wilson=' + Wilson.length);
Murphy[Murphy.length] = createMarker(new GPoint(-84.10050000,35.07640000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Murphy Adventist School",'Murphy=' + Murphy.length);
Greensboro[Greensboro.length] = createMarker(new GPoint(-79.76894700,36.07291900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Napoleon B Smith Academy",'Greensboro=' + Greensboro.length);
Wilmington[Wilmington.length] = createMarker(new GPoint(-77.88905700,34.25566900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("New Covenant Christian School",'Wilmington=' + Wilmington.length);
Whiteville[Whiteville.length] = createMarker(new GPoint(-78.70564800,34.32792500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Philadelphia Sda Academy Chris",'Whiteville=' + Whiteville.length);
Salisbury[Salisbury.length] = createMarker(new GPoint(-80.45261600,35.63840900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Salisbury Adventist School",'Salisbury=' + Salisbury.length);
Morganton[Morganton.length] = createMarker(new GPoint(-81.78996800,35.70218700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Silver Creek Sda School",'Morganton=' + Morganton.length);
High_Point[High_Point.length] = createMarker(new GPoint(-79.98711200,36.06158400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Tri-city Junior Academy",'High_Point=' + High_Point.length);
Lynn[Lynn.length] = createMarker(new GPoint(-82.23470000,35.22830000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Tryon Sda School",'Lynn=' + Lynn.length);
Flat_Rock[Flat_Rock.length] = createMarker(new GPoint(-82.39155600,35.29641200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Upward Seventh-day Adventist Church School",'Flat_Rock=' + Flat_Rock.length);
Waynesville[Waynesville.length] = createMarker(new GPoint(-82.99158000,35.52308900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Waynesville Sda School",'Waynesville=' + Waynesville.length);
Wilmington[Wilmington.length] = createMarker(new GPoint(-77.91027500,34.23946600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Wilmington Sda School",'Wilmington=' + Wilmington.length);
map.removeOverlays(Albemarle);
map.removeOverlays(Banner_Elk);
map.removeOverlays(Candler);
map.removeOverlays(Charlotte);
map.removeOverlays(Durham);
map.removeOverlays(Fayetteville);
map.removeOverlays(Flat_Rock);
map.removeOverlays(Fletcher);
map.removeOverlays(Franklin);
map.removeOverlays(Greensboro);
map.removeOverlays(Haw_River);
map.removeOverlays(Hickory);
map.removeOverlays(High_Point);
map.removeOverlays(La_Grange);
map.removeOverlays(Lynn);
map.removeOverlays(Morganton);
map.removeOverlays(Murphy);
map.removeOverlays(Raleigh);
map.removeOverlays(Salisbury);
map.removeOverlays(Statesville);
map.removeOverlays(Waynesville);
map.removeOverlays(Whiteville);
map.removeOverlays(Wilmington);
map.removeOverlays(Wilson);
map.removeOverlays(Winston_Salem);
map.removeOverlays(Winterville);
setTimeout(function(){map.addOverlays(Albemarle)},1000);
setTimeout(function(){map.addOverlays(Banner_Elk)},1000);
setTimeout(function(){map.addOverlays(Candler)},1000);
setTimeout(function(){map.addOverlays(Charlotte)},1000);
setTimeout(function(){map.addOverlays(Durham)},1000);
setTimeout(function(){map.addOverlays(Fayetteville)},1000);
setTimeout(function(){map.addOverlays(Flat_Rock)},1000);
setTimeout(function(){map.addOverlays(Fletcher)},1000);
setTimeout(function(){map.addOverlays(Franklin)},1000);
setTimeout(function(){map.addOverlays(Greensboro)},1000);
setTimeout(function(){map.addOverlays(Haw_River)},1000);
setTimeout(function(){map.addOverlays(Hickory)},1000);
setTimeout(function(){map.addOverlays(High_Point)},1000);
setTimeout(function(){map.addOverlays(La_Grange)},1000);
setTimeout(function(){map.addOverlays(Lynn)},1000);
setTimeout(function(){map.addOverlays(Morganton)},1000);
setTimeout(function(){map.addOverlays(Murphy)},1000);
setTimeout(function(){map.addOverlays(Raleigh)},1000);
setTimeout(function(){map.addOverlays(Salisbury)},1000);
setTimeout(function(){map.addOverlays(Statesville)},1000);
setTimeout(function(){map.addOverlays(Waynesville)},1000);
setTimeout(function(){map.addOverlays(Whiteville)},1000);
setTimeout(function(){map.addOverlays(Wilmington)},1000);
setTimeout(function(){map.addOverlays(Wilson)},1000);
setTimeout(function(){map.addOverlays(Winston_Salem)},1000);
setTimeout(function(){map.addOverlays(Winterville)},1000);
maxLng = -77.41651200;
maxLat = 36.14541800;
minLng = -84.10050000;
minLat = 34.23946600;
reCenterMap();
} // 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//////' + showArray);
map.removeOverlays(Albemarle);
map.removeOverlays(Banner_Elk);
map.removeOverlays(Candler);
map.removeOverlays(Charlotte);
map.removeOverlays(Durham);
map.removeOverlays(Fayetteville);
map.removeOverlays(Flat_Rock);
map.removeOverlays(Fletcher);
map.removeOverlays(Franklin);
map.removeOverlays(Greensboro);
map.removeOverlays(Haw_River);
map.removeOverlays(Hickory);
map.removeOverlays(High_Point);
map.removeOverlays(La_Grange);
map.removeOverlays(Lynn);
map.removeOverlays(Morganton);
map.removeOverlays(Murphy);
map.removeOverlays(Raleigh);
map.removeOverlays(Salisbury);
map.removeOverlays(Statesville);
map.removeOverlays(Waynesville);
map.removeOverlays(Whiteville);
map.removeOverlays(Wilmington);
map.removeOverlays(Wilson);
map.removeOverlays(Winston_Salem);
map.removeOverlays(Winterville);
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(Fayetteville);map.removeOverlays(Albemarle);
map.removeOverlays(Banner_Elk);
map.removeOverlays(Candler);
map.removeOverlays(Charlotte);
map.removeOverlays(Durham);
map.removeOverlays(Fayetteville);
map.removeOverlays(Flat_Rock);
map.removeOverlays(Fletcher);
map.removeOverlays(Franklin);
map.removeOverlays(Greensboro);
map.removeOverlays(Haw_River);
map.removeOverlays(Hickory);
map.removeOverlays(High_Point);
map.removeOverlays(La_Grange);
map.removeOverlays(Lynn);
map.removeOverlays(Morganton);
map.removeOverlays(Murphy);
map.removeOverlays(Raleigh);
map.removeOverlays(Salisbury);
map.removeOverlays(Statesville);
map.removeOverlays(Waynesville);
map.removeOverlays(Whiteville);
map.removeOverlays(Wilmington);
map.removeOverlays(Wilson);
map.removeOverlays(Winston_Salem);
map.removeOverlays(Winterville);
map.addOverlays(Albemarle);
centerByArray(Albemarle, false, false);
cntMarker += Albemarle.length;
map.addOverlays(Banner_Elk);
centerByArray(Banner_Elk, false, false);
cntMarker += Banner_Elk.length;
map.addOverlays(Candler);
centerByArray(Candler, false, false);
cntMarker += Candler.length;
map.addOverlays(Charlotte);
centerByArray(Charlotte, false, false);
cntMarker += Charlotte.length;
map.addOverlays(Durham);
centerByArray(Durham, false, false);
cntMarker += Durham.length;
map.addOverlays(Fayetteville);
centerByArray(Fayetteville, false, false);
cntMarker += Fayetteville.length;
map.addOverlays(Flat_Rock);
centerByArray(Flat_Rock, false, false);
cntMarker += Flat_Rock.length;
map.addOverlays(Fletcher);
centerByArray(Fletcher, false, false);
cntMarker += Fletcher.length;
map.addOverlays(Franklin);
centerByArray(Franklin, false, false);
cntMarker += Franklin.length;
map.addOverlays(Greensboro);
centerByArray(Greensboro, false, false);
cntMarker += Greensboro.length;
map.addOverlays(Haw_River);
centerByArray(Haw_River, false, false);
cntMarker += Haw_River.length;
map.addOverlays(Hickory);
centerByArray(Hickory, false, false);
cntMarker += Hickory.length;
map.addOverlays(High_Point);
centerByArray(High_Point, false, false);
cntMarker += High_Point.length;
map.addOverlays(La_Grange);
centerByArray(La_Grange, false, false);
cntMarker += La_Grange.length;
map.addOverlays(Lynn);
centerByArray(Lynn, false, false);
cntMarker += Lynn.length;
map.addOverlays(Morganton);
centerByArray(Morganton, false, false);
cntMarker += Morganton.length;
map.addOverlays(Murphy);
centerByArray(Murphy, false, false);
cntMarker += Murphy.length;
map.addOverlays(Raleigh);
centerByArray(Raleigh, false, false);
cntMarker += Raleigh.length;
map.addOverlays(Salisbury);
centerByArray(Salisbury, false, false);
cntMarker += Salisbury.length;
map.addOverlays(Statesville);
centerByArray(Statesville, false, false);
cntMarker += Statesville.length;
map.addOverlays(Waynesville);
centerByArray(Waynesville, false, false);
cntMarker += Waynesville.length;
map.addOverlays(Whiteville);
centerByArray(Whiteville, false, false);
cntMarker += Whiteville.length;
map.addOverlays(Wilmington);
centerByArray(Wilmington, false, false);
cntMarker += Wilmington.length;
map.addOverlays(Wilson);
centerByArray(Wilson, false, false);
cntMarker += Wilson.length;
map.addOverlays(Winston_Salem);
centerByArray(Winston_Salem, false, false);
cntMarker += Winston_Salem.length;
map.addOverlays(Winterville);
centerByArray(Winterville, false, false);
cntMarker += Winterville.length;
centerByArray(Fayetteville,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///21029,20726,20727,20911,21224,21038,21050,20734,20961,20750,20726,20762,36038,20721,20727,21245,20807,20916,21042,21137,31632,20753,21224,20976,21237,21145,21038,21105,20926,21132,32735,21265,21090,21050,21278,34427,20880,20782,/all');
//window.open('/map.php?type=2&schools=21029,20726,20727,20911,21224,21038,21050,20734,20961,20750,20726,20762,36038,20721,20727,21245,20807,20916,21042,21137,31632,20753,21224,20976,21237,21145,21038,21105,20926,21132,32735,21265,21090,21050,21278,34427,20880,20782,&school_level=&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;
}