function addMarkers(){
mySelect = document.getElementById('selection');
Raleigh = [];Cary = [];Zebulon = [];Fuquay_Varina = [];Garner = [];Wake_Forest = [];Fuquay_varina = [];Holly_Springs = [];Apex = [];mySelect.options[mySelect.options.length] = new Option("Apex schools",'all=Apex');
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("Garner schools",'all=Garner');
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("Wake Forest schools",'all=Wake_Forest');
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.72126700,35.74860400),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Adventist Christian Academy",'Raleigh=' + Raleigh.length);
Raleigh[Raleigh.length] = createMarker(new GPoint(-78.69127500,35.78928100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Al-iman School",'Raleigh=' + Raleigh.length);
Raleigh[Raleigh.length] = createMarker(new GPoint(-78.56655200,35.85621800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Body Of Christ Christian Academy",'Raleigh=' + Raleigh.length);
Raleigh[Raleigh.length] = createMarker(new GPoint(-78.68153000,35.87109800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bonner Academy",'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.64192500,35.78063700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cathedral School",'Raleigh=' + Raleigh.length);
Raleigh[Raleigh.length] = createMarker(new GPoint(-78.66596900,35.90231600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Chesterbrook Academy",'Raleigh=' + Raleigh.length);
Cary[Cary.length] = createMarker(new GPoint(-78.83825400,35.78292800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Chesterbrook Academy",'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.68760300,35.80356300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Follow The Child Montessori School",'Raleigh=' + Raleigh.length);
Raleigh[Raleigh.length] = createMarker(new GPoint(-78.69430000,35.87280000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Franciscan School",'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.61382600,35.74480300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Gethsemane Sda 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);
Raleigh[Raleigh.length] = createMarker(new GPoint(-78.53180000,35.97190000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Growing Child",'Raleigh=' + Raleigh.length);
Cary[Cary.length] = createMarker(new GPoint(-78.78002800,35.78101700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Heartwood Montessori School",'Cary=' + Cary.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);
Raleigh[Raleigh.length] = createMarker(new GPoint(-78.62687000,35.88491900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Hillel Day School",'Raleigh=' + Raleigh.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);
Cary[Cary.length] = createMarker(new GPoint(-78.75109500,35.75303500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Little Treasures School",'Cary=' + Cary.length);
Garner[Garner.length] = createMarker(new GPoint(-78.62506700,35.67670800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lord Of Life Preschool & Kindergarten",'Garner=' + Garner.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);
Cary[Cary.length] = createMarker(new GPoint(-78.79875800,35.82776000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lucy Daniels Center For Early Childhood",'Cary=' + Cary.length);
Wake_Forest[Wake_Forest.length] = createMarker(new GPoint(-78.50196000,35.98937700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Montessori Children's House Of Wake Forest",'Wake_Forest=' + Wake_Forest.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.63449700,35.81871800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Our Lady Of Lourdes Elementary School",'Raleigh=' + Raleigh.length);
Cary[Cary.length] = createMarker(new GPoint(-78.78750200,35.71820200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Paideia Academy",'Cary=' + Cary.length);
Raleigh[Raleigh.length] = createMarker(new GPoint(-78.53233000,35.82686300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Raleigh Chr Community School",'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.72520600,35.79648100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Raleigh School",'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);
Wake_Forest[Wake_Forest.length] = createMarker(new GPoint(-78.52307600,35.97343800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Catherine Of Siena Catholic",'Wake_Forest=' + Wake_Forest.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);
Cary[Cary.length] = createMarker(new GPoint(-78.82222300,35.78604000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Michael The Archangel School",'Cary=' + Cary.length);
Raleigh[Raleigh.length] = createMarker(new GPoint(-78.61922900,35.86106400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Raphael Catholic 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);
Apex[Apex.length] = createMarker(new GPoint(-78.87549300,35.72411900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Mary Magdalene Catholic School",'Apex=' + Apex.length);
Raleigh[Raleigh.length] = createMarker(new GPoint(-78.62658700,35.88393000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Philip Lutheran Preschool",'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(-105.01343500,39.85920900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Upper Room Christian Academy",'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/////1/' + showArray);
map.removeOverlays(Apex);
map.removeOverlays(Cary);
map.removeOverlays(Fuquay_Varina);
map.removeOverlays(Fuquay_varina);
map.removeOverlays(Garner);
map.removeOverlays(Holly_Springs);
map.removeOverlays(Raleigh);
map.removeOverlays(Wake_Forest);
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(Apex);
map.removeOverlays(Cary);
map.removeOverlays(Fuquay_Varina);
map.removeOverlays(Fuquay_varina);
map.removeOverlays(Garner);
map.removeOverlays(Holly_Springs);
map.removeOverlays(Raleigh);
map.removeOverlays(Wake_Forest);
map.removeOverlays(Zebulon);
map.addOverlays(Apex);
centerByArray(Apex, false, false);
cntMarker += Apex.length;
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(Garner);
centerByArray(Garner, false, false);
cntMarker += Garner.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(Wake_Forest);
centerByArray(Wake_Forest, false, false);
cntMarker += Wake_Forest.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=1&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;
}