function addMarkers(){
mySelect = document.getElementById('selection');
Neptune = [];Lincroft = [];Howell = [];Morganville = [];Wickatunk = [];West_Long_Branch = [];Ocean = [];Tinton_Falls = [];Eatontown = [];Elberon = [];Hazlet = [];Middletown = [];Cream_Ridge = [];Red_Bank = [];Wall = [];Holmdel = [];Belmar = [];W_Long_Branch = [];Wanamassa = [];Long_Branch = [];Farmingdale = [];Wall_Township = [];mySelect.options[mySelect.options.length] = new Option("Belmar schools",'all=Belmar');
mySelect.options[mySelect.options.length] = new Option("Cream Ridge schools",'all=Cream_Ridge');
mySelect.options[mySelect.options.length] = new Option("Eatontown schools",'all=Eatontown');
mySelect.options[mySelect.options.length] = new Option("Elberon schools",'all=Elberon');
mySelect.options[mySelect.options.length] = new Option("Farmingdale schools",'all=Farmingdale');
mySelect.options[mySelect.options.length] = new Option("Hazlet schools",'all=Hazlet');
mySelect.options[mySelect.options.length] = new Option("Holmdel schools",'all=Holmdel');
mySelect.options[mySelect.options.length] = new Option("Howell schools",'all=Howell');
mySelect.options[mySelect.options.length] = new Option("Lincroft schools",'all=Lincroft');
mySelect.options[mySelect.options.length] = new Option("Long Branch schools",'all=Long_Branch');
mySelect.options[mySelect.options.length] = new Option("Middletown schools",'all=Middletown');
mySelect.options[mySelect.options.length] = new Option("Morganville schools",'all=Morganville');
mySelect.options[mySelect.options.length] = new Option("Neptune schools",'all=Neptune');
mySelect.options[mySelect.options.length] = new Option("Ocean schools",'all=Ocean');
mySelect.options[mySelect.options.length] = new Option("Red Bank schools",'all=Red_Bank');
mySelect.options[mySelect.options.length] = new Option("Tinton Falls schools",'all=Tinton_Falls');
mySelect.options[mySelect.options.length] = new Option("W Long Branch schools",'all=W_Long_Branch');
mySelect.options[mySelect.options.length] = new Option("Wall schools",'all=Wall');
mySelect.options[mySelect.options.length] = new Option("Wall Township schools",'all=Wall_Township');
mySelect.options[mySelect.options.length] = new Option("Wanamassa schools",'all=Wanamassa');
mySelect.options[mySelect.options.length] = new Option("West Long Branch schools",'all=West_Long_Branch');
mySelect.options[mySelect.options.length] = new Option("Wickatunk schools",'all=Wickatunk');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Neptune[Neptune.length] = createMarker(new GPoint(-74.07633600,40.23020600),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Childrens Center Of Monmouth C",'Neptune=' + Neptune.length);
Lincroft[Lincroft.length] = createMarker(new GPoint(-74.14572900,40.33870400),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Christian Brothers Academy",'Lincroft=' + Lincroft.length);
Howell[Howell.length] = createMarker(new GPoint(-74.17586700,40.11257500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Coastal Learning Center",'Howell=' + Howell.length);
Morganville[Morganville.length] = createMarker(new GPoint(-74.24434500,40.37627800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Coastal Learning Center",'Morganville=' + Morganville.length);
Wickatunk[Wickatunk.length] = createMarker(new GPoint(-74.24830000,40.35000000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Collier High School",'Wickatunk=' + Wickatunk.length);
West_Long_Branch[West_Long_Branch.length] = createMarker(new GPoint(-74.01720000,40.29050000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Deal Yeshiva",'West_Long_Branch=' + West_Long_Branch.length);
Ocean[Ocean.length] = createMarker(new GPoint(-74.03323600,40.23633300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Deal Yeshiva - Boys Division",'Ocean=' + Ocean.length);
Tinton_Falls[Tinton_Falls.length] = createMarker(new GPoint(-74.07714700,40.26973500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Dorothy B Hersh High School",'Tinton_Falls=' + Tinton_Falls.length);
Eatontown[Eatontown.length] = createMarker(new GPoint(-74.04982500,40.30594800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Harbor School",'Eatontown=' + Eatontown.length);
Ocean[Ocean.length] = createMarker(new GPoint(-74.05725800,40.25014900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Hillel Yeshiva High School",'Ocean=' + Ocean.length);
Elberon[Elberon.length] = createMarker(new GPoint(-73.99883900,40.27028500),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Ilan High School",'Elberon=' + Elberon.length);
Howell[Howell.length] = createMarker(new GPoint(-74.21410100,40.12864000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lakewood Prep",'Howell=' + Howell.length);
Howell[Howell.length] = createMarker(new GPoint(-74.16023300,40.15489700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Liberty Christian School",'Howell=' + Howell.length);
Hazlet[Hazlet.length] = createMarker(new GPoint(-74.19067800,40.41352800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Maranatha Christian Academy",'Hazlet=' + Hazlet.length);
Middletown[Middletown.length] = createMarker(new GPoint(-74.09997400,40.41413600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mater Dei High School",'Middletown=' + Middletown.length);
Cream_Ridge[Cream_Ridge.length] = createMarker(new GPoint(-74.53603800,40.11073900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("New Jersey United Christian Academy",'Cream_Ridge=' + Cream_Ridge.length);
Tinton_Falls[Tinton_Falls.length] = createMarker(new GPoint(-74.08533200,40.33476100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Oakwood School",'Tinton_Falls=' + Tinton_Falls.length);
Tinton_Falls[Tinton_Falls.length] = createMarker(new GPoint(-74.08041600,40.30704000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Ranney School",'Tinton_Falls=' + Tinton_Falls.length);
Red_Bank[Red_Bank.length] = createMarker(new GPoint(-74.06532400,40.34821600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Red Bank Catholic High School",'Red_Bank=' + Red_Bank.length);
Wall[Wall.length] = createMarker(new GPoint(-74.05660000,40.17300000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Rugby School",'Wall=' + Wall.length);
Holmdel[Holmdel.length] = createMarker(new GPoint(-74.20884800,40.40423200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. John Vianney High School",'Holmdel=' + Holmdel.length);
Belmar[Belmar.length] = createMarker(new GPoint(-74.02292900,40.18192900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Rose High School",'Belmar=' + Belmar.length);
W_Long_Branch[W_Long_Branch.length] = createMarker(new GPoint(-74.01720000,40.29050000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("School For Children",'W_Long_Branch=' + W_Long_Branch.length);
Wanamassa[Wanamassa.length] = createMarker(new GPoint(-74.04074300,40.24249800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Schroth School-cp Of Monmouth",'Wanamassa=' + Wanamassa.length);
Ocean[Ocean.length] = createMarker(new GPoint(-74.02220600,40.24247700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Search Day Program Inc",'Ocean=' + Ocean.length);
Long_Branch[Long_Branch.length] = createMarker(new GPoint(-73.98352800,40.29486900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Seashore School",'Long_Branch=' + Long_Branch.length);
Farmingdale[Farmingdale.length] = createMarker(new GPoint(-74.18886800,40.20703300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Voyagers' Community School",'Farmingdale=' + Farmingdale.length);
Red_Bank[Red_Bank.length] = createMarker(new GPoint(-74.07736800,40.34099100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("West Side Christian Academy",'Red_Bank=' + Red_Bank.length);
Wall_Township[Wall_Township.length] = createMarker(new GPoint(-74.11852900,40.21505400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Woodcliff Academy",'Wall_Township=' + Wall_Township.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(Belmar);
map.removeOverlays(Cream_Ridge);
map.removeOverlays(Eatontown);
map.removeOverlays(Elberon);
map.removeOverlays(Farmingdale);
map.removeOverlays(Hazlet);
map.removeOverlays(Holmdel);
map.removeOverlays(Howell);
map.removeOverlays(Lincroft);
map.removeOverlays(Long_Branch);
map.removeOverlays(Middletown);
map.removeOverlays(Morganville);
map.removeOverlays(Neptune);
map.removeOverlays(Ocean);
map.removeOverlays(Red_Bank);
map.removeOverlays(Tinton_Falls);
map.removeOverlays(W_Long_Branch);
map.removeOverlays(Wall);
map.removeOverlays(Wall_Township);
map.removeOverlays(Wanamassa);
map.removeOverlays(West_Long_Branch);
map.removeOverlays(Wickatunk);
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(Neptune);map.removeOverlays(Belmar);
map.removeOverlays(Cream_Ridge);
map.removeOverlays(Eatontown);
map.removeOverlays(Elberon);
map.removeOverlays(Farmingdale);
map.removeOverlays(Hazlet);
map.removeOverlays(Holmdel);
map.removeOverlays(Howell);
map.removeOverlays(Lincroft);
map.removeOverlays(Long_Branch);
map.removeOverlays(Middletown);
map.removeOverlays(Morganville);
map.removeOverlays(Neptune);
map.removeOverlays(Ocean);
map.removeOverlays(Red_Bank);
map.removeOverlays(Tinton_Falls);
map.removeOverlays(W_Long_Branch);
map.removeOverlays(Wall);
map.removeOverlays(Wall_Township);
map.removeOverlays(Wanamassa);
map.removeOverlays(West_Long_Branch);
map.removeOverlays(Wickatunk);
map.addOverlays(Belmar);
centerByArray(Belmar, false, false);
cntMarker += Belmar.length;
map.addOverlays(Cream_Ridge);
centerByArray(Cream_Ridge, false, false);
cntMarker += Cream_Ridge.length;
map.addOverlays(Eatontown);
centerByArray(Eatontown, false, false);
cntMarker += Eatontown.length;
map.addOverlays(Elberon);
centerByArray(Elberon, false, false);
cntMarker += Elberon.length;
map.addOverlays(Farmingdale);
centerByArray(Farmingdale, false, false);
cntMarker += Farmingdale.length;
map.addOverlays(Hazlet);
centerByArray(Hazlet, false, false);
cntMarker += Hazlet.length;
map.addOverlays(Holmdel);
centerByArray(Holmdel, false, false);
cntMarker += Holmdel.length;
map.addOverlays(Howell);
centerByArray(Howell, false, false);
cntMarker += Howell.length;
map.addOverlays(Lincroft);
centerByArray(Lincroft, false, false);
cntMarker += Lincroft.length;
map.addOverlays(Long_Branch);
centerByArray(Long_Branch, false, false);
cntMarker += Long_Branch.length;
map.addOverlays(Middletown);
centerByArray(Middletown, false, false);
cntMarker += Middletown.length;
map.addOverlays(Morganville);
centerByArray(Morganville, false, false);
cntMarker += Morganville.length;
map.addOverlays(Neptune);
centerByArray(Neptune, false, false);
cntMarker += Neptune.length;
map.addOverlays(Ocean);
centerByArray(Ocean, false, false);
cntMarker += Ocean.length;
map.addOverlays(Red_Bank);
centerByArray(Red_Bank, false, false);
cntMarker += Red_Bank.length;
map.addOverlays(Tinton_Falls);
centerByArray(Tinton_Falls, false, false);
cntMarker += Tinton_Falls.length;
map.addOverlays(W_Long_Branch);
centerByArray(W_Long_Branch, false, false);
cntMarker += W_Long_Branch.length;
map.addOverlays(Wall);
centerByArray(Wall, false, false);
cntMarker += Wall.length;
map.addOverlays(Wall_Township);
centerByArray(Wall_Township, false, false);
cntMarker += Wall_Township.length;
map.addOverlays(Wanamassa);
centerByArray(Wanamassa, false, false);
cntMarker += Wanamassa.length;
map.addOverlays(West_Long_Branch);
centerByArray(West_Long_Branch, false, false);
cntMarker += West_Long_Branch.length;
map.addOverlays(Wickatunk);
centerByArray(Wickatunk, false, false);
cntMarker += Wickatunk.length;
centerByArray(Neptune,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;
}