function addMarkers(){
mySelect = document.getElementById('selection');
Raleigh = [];Cary = [];Zebulon = [];Fuquay_Varina = [];Fuquay_varina = [];Holly_Springs = [];mySelect.options[mySelect.options.length] = new Option("Cary schools",'all=Cary');
mySelect.options[mySelect.options.length] = new Option("Fuquay Varina schools",'all=Fuquay_Varina');
mySelect.options[mySelect.options.length] = new Option("Fuquay varina schools",'all=Fuquay_varina');
mySelect.options[mySelect.options.length] = new Option("Holly Springs schools",'all=Holly_Springs');
mySelect.options[mySelect.options.length] = new Option("Raleigh schools",'all=Raleigh');
mySelect.options[mySelect.options.length] = new Option("Zebulon schools",'all=Zebulon');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Raleigh[Raleigh.length] = createMarker(new GPoint(-78.72636800,35.80458300),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cardinal Gibbons High School",'Raleigh=' + Raleigh.length);
Cary[Cary.length] = createMarker(new GPoint(-78.77128600,35.81938800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cary Academy",'Cary=' + Cary.length);
Cary[Cary.length] = createMarker(new GPoint(-78.80643700,35.77476300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cary Christian School",'Cary=' + Cary.length);
Raleigh[Raleigh.length] = createMarker(new GPoint(-78.61833500,35.80533000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Faith Lutheran School",'Raleigh=' + Raleigh.length);
Raleigh[Raleigh.length] = createMarker(new GPoint(-78.63134200,35.85647100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Fletcher Academy",'Raleigh=' + Raleigh.length);
Raleigh[Raleigh.length] = createMarker(new GPoint(-78.61576900,35.85699500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Friendship Christian School",'Raleigh=' + Raleigh.length);
Raleigh[Raleigh.length] = createMarker(new GPoint(-78.73773400,35.77213200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Grace Christian School",'Raleigh=' + Raleigh.length);
Zebulon[Zebulon.length] = createMarker(new GPoint(-78.32714700,35.81733300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Heritage Christian Academy",'Zebulon=' + Zebulon.length);
Fuquay_Varina[Fuquay_Varina.length] = createMarker(new GPoint(-78.72071700,35.62704500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Hilltop Christian School",'Fuquay_Varina=' + Fuquay_Varina.length);
Cary[Cary.length] = createMarker(new GPoint(-78.80977400,35.81294200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Hopewell Academy",'Cary=' + Cary.length);
Raleigh[Raleigh.length] = createMarker(new GPoint(-78.60949500,35.78353700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Love Christian Ctr. Academy",'Raleigh=' + Raleigh.length);
Raleigh[Raleigh.length] = createMarker(new GPoint(-78.63217500,35.79090700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Montessori Comm Children's Hou",'Raleigh=' + Raleigh.length);
Raleigh[Raleigh.length] = createMarker(new GPoint(-78.66180400,35.87633800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Montessori School Of Raleigh",'Raleigh=' + Raleigh.length);
Fuquay_varina[Fuquay_varina.length] = createMarker(new GPoint(-78.80808700,35.52689500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Montessori World",'Fuquay_varina=' + Fuquay_varina.length);
Raleigh[Raleigh.length] = createMarker(new GPoint(-78.55823300,35.89757500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Neuse Baptist Christian School",'Raleigh=' + Raleigh.length);
Holly_Springs[Holly_Springs.length] = createMarker(new GPoint(-78.78932700,35.65499300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The New School, A Montessori Center For Children",'Holly_Springs=' + Holly_Springs.length);
Raleigh[Raleigh.length] = createMarker(new GPoint(-78.54539000,35.87903600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("North Raleigh Christian Academy",'Raleigh=' + Raleigh.length);
Raleigh[Raleigh.length] = createMarker(new GPoint(-78.57713000,35.80919100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Raleigh Christian Academy",'Raleigh=' + Raleigh.length);
Raleigh[Raleigh.length] = createMarker(new GPoint(-78.62713900,35.88467500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Ravenscroft School",'Raleigh=' + Raleigh.length);
Cary[Cary.length] = createMarker(new GPoint(-78.77746800,35.72943600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Resurrection Lutheran School",'Cary=' + Cary.length);
Raleigh[Raleigh.length] = createMarker(new GPoint(-78.64922700,35.82250200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Davids School",'Raleigh=' + Raleigh.length);
Raleigh[Raleigh.length] = createMarker(new GPoint(-78.65225000,35.78128500),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Saint Marys School",'Raleigh=' + Raleigh.length);
Raleigh[Raleigh.length] = createMarker(new GPoint(-78.63281600,35.84609200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Timothys School",'Raleigh=' + Raleigh.length);
Raleigh[Raleigh.length] = createMarker(new GPoint(-78.58903100,35.85527000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Thomas More Academy",'Raleigh=' + Raleigh.length);
Raleigh[Raleigh.length] = createMarker(new GPoint(-78.62201800,35.90176700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Stevens Prep Academy",'Raleigh=' + Raleigh.length);
Raleigh[Raleigh.length] = createMarker(new GPoint(-78.63323000,35.82943100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Trilogy School",'Raleigh=' + Raleigh.length);
Raleigh[Raleigh.length] = createMarker(new GPoint(-78.69597200,35.91105100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Trinity Academy Of Raleigh",'Raleigh=' + Raleigh.length);
Raleigh[Raleigh.length] = createMarker(new GPoint(-78.68863900,35.79125700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Vital Link Is Cross Link",'Raleigh=' + Raleigh.length);
Raleigh[Raleigh.length] = createMarker(new GPoint(-78.66888900,35.70443900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Wake Christian Academy",'Raleigh=' + Raleigh.length);
Raleigh[Raleigh.length] = createMarker(new GPoint(-78.63880000,35.77190000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Word Of God Christian Academy",'Raleigh=' + Raleigh.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/////2/' + showArray);
map.removeOverlays(Cary);
map.removeOverlays(Fuquay_Varina);
map.removeOverlays(Fuquay_varina);
map.removeOverlays(Holly_Springs);
map.removeOverlays(Raleigh);
map.removeOverlays(Zebulon);
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(Raleigh);map.removeOverlays(Cary);
map.removeOverlays(Fuquay_Varina);
map.removeOverlays(Fuquay_varina);
map.removeOverlays(Holly_Springs);
map.removeOverlays(Raleigh);
map.removeOverlays(Zebulon);
map.addOverlays(Cary);
centerByArray(Cary, false, false);
cntMarker += Cary.length;
map.addOverlays(Fuquay_Varina);
centerByArray(Fuquay_Varina, false, false);
cntMarker += Fuquay_Varina.length;
map.addOverlays(Fuquay_varina);
centerByArray(Fuquay_varina, false, false);
cntMarker += Fuquay_varina.length;
map.addOverlays(Holly_Springs);
centerByArray(Holly_Springs, false, false);
cntMarker += Holly_Springs.length;
map.addOverlays(Raleigh);
centerByArray(Raleigh, false, false);
cntMarker += Raleigh.length;
map.addOverlays(Zebulon);
centerByArray(Zebulon, false, false);
cntMarker += Zebulon.length;
centerByArray(Raleigh,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=2&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;
}