function addMarkers(){
mySelect = document.getElementById('selection');
Pitman = [];Glassboro = [];Westville_Grov = [];Sewell = [];Deptford = [];Turnersville = [];Woodbury = [];Mullica_Hill = [];Gibbstown = [];Hurffville = [];Westville = [];Newfield = [];Woodbury_Heights = [];Williamstown = [];Clayton = [];Sicklerville = [];Mantua = [];mySelect.options[mySelect.options.length] = new Option("Clayton schools",'all=Clayton');
mySelect.options[mySelect.options.length] = new Option("Deptford schools",'all=Deptford');
mySelect.options[mySelect.options.length] = new Option("Gibbstown schools",'all=Gibbstown');
mySelect.options[mySelect.options.length] = new Option("Glassboro schools",'all=Glassboro');
mySelect.options[mySelect.options.length] = new Option("Hurffville schools",'all=Hurffville');
mySelect.options[mySelect.options.length] = new Option("Mantua schools",'all=Mantua');
mySelect.options[mySelect.options.length] = new Option("Mullica Hill schools",'all=Mullica_Hill');
mySelect.options[mySelect.options.length] = new Option("Newfield schools",'all=Newfield');
mySelect.options[mySelect.options.length] = new Option("Pitman schools",'all=Pitman');
mySelect.options[mySelect.options.length] = new Option("Sewell schools",'all=Sewell');
mySelect.options[mySelect.options.length] = new Option("Sicklerville schools",'all=Sicklerville');
mySelect.options[mySelect.options.length] = new Option("Turnersville schools",'all=Turnersville');
mySelect.options[mySelect.options.length] = new Option("Westville schools",'all=Westville');
mySelect.options[mySelect.options.length] = new Option("Westville Grov schools",'all=Westville_Grov');
mySelect.options[mySelect.options.length] = new Option("Williamstown schools",'all=Williamstown');
mySelect.options[mySelect.options.length] = new Option("Woodbury schools",'all=Woodbury');
mySelect.options[mySelect.options.length] = new Option("Woodbury Heights schools",'all=Woodbury_Heights');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Pitman[Pitman.length] = createMarker(new GPoint(-75.11350000,39.73920000),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Abc Express Preschool Inc.",'Pitman=' + Pitman.length);
Glassboro[Glassboro.length] = createMarker(new GPoint(-94.27280000,37.50690000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Ambassador Christian Academy",'Glassboro=' + Glassboro.length);
Westville_Grov[Westville_Grov.length] = createMarker(new GPoint(-75.12492000,39.84747400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Archbishop Damiano School",'Westville_Grov=' + Westville_Grov.length);
Sewell[Sewell.length] = createMarker(new GPoint(-75.14820100,39.76641100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Archway School -Washington Township School",'Sewell=' + Sewell.length);
Deptford[Deptford.length] = createMarker(new GPoint(-75.08382600,39.80614700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bethany Baptist Christian School",'Deptford=' + Deptford.length);
Turnersville[Turnersville.length] = createMarker(new GPoint(-75.05070700,39.72273400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bright Beginnings West School",'Turnersville=' + Turnersville.length);
Turnersville[Turnersville.length] = createMarker(new GPoint(-75.05649400,39.77277500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Brighten Academy",'Turnersville=' + Turnersville.length);
Woodbury[Woodbury.length] = createMarker(new GPoint(-75.15471500,39.85017400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Childrens Montess School House",'Woodbury=' + Woodbury.length);
Glassboro[Glassboro.length] = createMarker(new GPoint(-75.09655500,39.70091200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Children's Corner",'Glassboro=' + Glassboro.length);
Deptford[Deptford.length] = createMarker(new GPoint(-75.10424100,39.81467800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Delaware Valley Jr. Academy",'Deptford=' + Deptford.length);
Woodbury[Woodbury.length] = createMarker(new GPoint(-75.14385700,39.84093600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Durand Academy, Inc.",'Woodbury=' + Woodbury.length);
Glassboro[Glassboro.length] = createMarker(new GPoint(-75.10953200,39.70237300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Faith Christian Academy",'Glassboro=' + Glassboro.length);
Mullica_Hill[Mullica_Hill.length] = createMarker(new GPoint(-75.22574900,39.73206100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Friends School",'Mullica_Hill=' + Mullica_Hill.length);
Sewell[Sewell.length] = createMarker(new GPoint(-75.15954000,39.73777000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Gloucester County Christian School",'Sewell=' + Sewell.length);
Gibbstown[Gibbstown.length] = createMarker(new GPoint(-75.28575100,39.82160600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Guardian Angels Regional School",'Gibbstown=' + Gibbstown.length);
Hurffville[Hurffville.length] = createMarker(new GPoint(-75.10826900,39.76239500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("HollyDELL School",'Hurffville=' + Hurffville.length);
Sewell[Sewell.length] = createMarker(new GPoint(-75.09995200,39.78171300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Kindercare Learning Center #1263",'Sewell=' + Sewell.length);
Sewell[Sewell.length] = createMarker(new GPoint(-75.12130000,39.75364300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lambs Road Academy",'Sewell=' + Sewell.length);
Turnersville[Turnersville.length] = createMarker(new GPoint(-75.04383900,39.74837800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Little Achievers Learning Center",'Turnersville=' + Turnersville.length);
Westville[Westville.length] = createMarker(new GPoint(-75.12492000,39.84402000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Most Holy Redeemer School",'Westville=' + Westville.length);
Newfield[Newfield.length] = createMarker(new GPoint(-75.02273100,39.54836500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Notre Dame Regional School",'Newfield=' + Newfield.length);
Glassboro[Glassboro.length] = createMarker(new GPoint(-75.11231200,39.70300600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Bridget Regional School",'Glassboro=' + Glassboro.length);
Woodbury_Heights[Woodbury_Heights.length] = createMarker(new GPoint(-75.15732800,39.81503500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Margaret Regional School",'Woodbury_Heights=' + Woodbury_Heights.length);
Williamstown[Williamstown.length] = createMarker(new GPoint(-74.98786800,39.67954800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Mary School",'Williamstown=' + Williamstown.length);
Westville[Westville.length] = createMarker(new GPoint(-75.16447900,39.86101400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Matthew Regional School",'Westville=' + Westville.length);
Woodbury[Woodbury.length] = createMarker(new GPoint(-75.14731800,39.83522500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Patrick Elementary School",'Woodbury=' + Woodbury.length);
Clayton[Clayton.length] = createMarker(new GPoint(-75.09427700,39.66372900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Catherine Of Siena School",'Clayton=' + Clayton.length);
Sicklerville[Sicklerville.length] = createMarker(new GPoint(-75.03389600,39.73944500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Judes Annex",'Sicklerville=' + Sicklerville.length);
Sewell[Sewell.length] = createMarker(new GPoint(-75.08337700,39.74580000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Tlc Daycare Center Inc.",'Sewell=' + Sewell.length);
Woodbury[Woodbury.length] = createMarker(new GPoint(-75.15069600,39.84476900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Tra-cee Kindergarten Academy",'Woodbury=' + Woodbury.length);
Mantua[Mantua.length] = createMarker(new GPoint(-75.17009400,39.80035100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Under The Sun Learning Center",'Mantua=' + Mantua.length);
Williamstown[Williamstown.length] = createMarker(new GPoint(-74.97210000,39.65960000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Victory Christian School",'Williamstown=' + Williamstown.length);
Williamstown[Williamstown.length] = createMarker(new GPoint(-74.99517400,39.69200100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Yale School Williamstown Campu",'Williamstown=' + Williamstown.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(Clayton);
map.removeOverlays(Deptford);
map.removeOverlays(Gibbstown);
map.removeOverlays(Glassboro);
map.removeOverlays(Hurffville);
map.removeOverlays(Mantua);
map.removeOverlays(Mullica_Hill);
map.removeOverlays(Newfield);
map.removeOverlays(Pitman);
map.removeOverlays(Sewell);
map.removeOverlays(Sicklerville);
map.removeOverlays(Turnersville);
map.removeOverlays(Westville);
map.removeOverlays(Westville_Grov);
map.removeOverlays(Williamstown);
map.removeOverlays(Woodbury);
map.removeOverlays(Woodbury_Heights);
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(Pitman);map.removeOverlays(Clayton);
map.removeOverlays(Deptford);
map.removeOverlays(Gibbstown);
map.removeOverlays(Glassboro);
map.removeOverlays(Hurffville);
map.removeOverlays(Mantua);
map.removeOverlays(Mullica_Hill);
map.removeOverlays(Newfield);
map.removeOverlays(Pitman);
map.removeOverlays(Sewell);
map.removeOverlays(Sicklerville);
map.removeOverlays(Turnersville);
map.removeOverlays(Westville);
map.removeOverlays(Westville_Grov);
map.removeOverlays(Williamstown);
map.removeOverlays(Woodbury);
map.removeOverlays(Woodbury_Heights);
map.addOverlays(Clayton);
centerByArray(Clayton, false, false);
cntMarker += Clayton.length;
map.addOverlays(Deptford);
centerByArray(Deptford, false, false);
cntMarker += Deptford.length;
map.addOverlays(Gibbstown);
centerByArray(Gibbstown, false, false);
cntMarker += Gibbstown.length;
map.addOverlays(Glassboro);
centerByArray(Glassboro, false, false);
cntMarker += Glassboro.length;
map.addOverlays(Hurffville);
centerByArray(Hurffville, false, false);
cntMarker += Hurffville.length;
map.addOverlays(Mantua);
centerByArray(Mantua, false, false);
cntMarker += Mantua.length;
map.addOverlays(Mullica_Hill);
centerByArray(Mullica_Hill, false, false);
cntMarker += Mullica_Hill.length;
map.addOverlays(Newfield);
centerByArray(Newfield, false, false);
cntMarker += Newfield.length;
map.addOverlays(Pitman);
centerByArray(Pitman, false, false);
cntMarker += Pitman.length;
map.addOverlays(Sewell);
centerByArray(Sewell, false, false);
cntMarker += Sewell.length;
map.addOverlays(Sicklerville);
centerByArray(Sicklerville, false, false);
cntMarker += Sicklerville.length;
map.addOverlays(Turnersville);
centerByArray(Turnersville, false, false);
cntMarker += Turnersville.length;
map.addOverlays(Westville);
centerByArray(Westville, false, false);
cntMarker += Westville.length;
map.addOverlays(Westville_Grov);
centerByArray(Westville_Grov, false, false);
cntMarker += Westville_Grov.length;
map.addOverlays(Williamstown);
centerByArray(Williamstown, false, false);
cntMarker += Williamstown.length;
map.addOverlays(Woodbury);
centerByArray(Woodbury, false, false);
cntMarker += Woodbury.length;
map.addOverlays(Woodbury_Heights);
centerByArray(Woodbury_Heights, false, false);
cntMarker += Woodbury_Heights.length;
centerByArray(Pitman,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;
}