function addMarkers(){ mySelect = document.getElementById('selection'); Mendham = [];Mays_Landing = [];Paramus = [];West_Paterson = [];Lincroft = [];Pemberton = [];Blackwood = [];Randolph = [];Vineland = [];North_Brunswick = [];Newark = [];Livingston = [];Sewell = [];Jersey_City = [];West_Windsor = [];Edison = [];Toms_River = [];Paterson = [];North_Branch = [];Carneys_Point = [];Newton = [];Cranford = [];Washington = [];mySelect.options[mySelect.options.length] = new Option("Blackwood Schools",'all=Blackwood'); mySelect.options[mySelect.options.length] = new Option("Carneys Point Schools",'all=Carneys_Point'); mySelect.options[mySelect.options.length] = new Option("Cranford Schools",'all=Cranford'); mySelect.options[mySelect.options.length] = new Option("Edison Schools",'all=Edison'); mySelect.options[mySelect.options.length] = new Option("Jersey City Schools",'all=Jersey_City'); mySelect.options[mySelect.options.length] = new Option("Lincroft Schools",'all=Lincroft'); mySelect.options[mySelect.options.length] = new Option("Livingston Schools",'all=Livingston'); mySelect.options[mySelect.options.length] = new Option("Mays Landing Schools",'all=Mays_Landing'); mySelect.options[mySelect.options.length] = new Option("Mendham Schools",'all=Mendham'); mySelect.options[mySelect.options.length] = new Option("Newark Schools",'all=Newark'); mySelect.options[mySelect.options.length] = new Option("Newton Schools",'all=Newton'); mySelect.options[mySelect.options.length] = new Option("North Branch Schools",'all=North_Branch'); mySelect.options[mySelect.options.length] = new Option("North Brunswick Schools",'all=North_Brunswick'); mySelect.options[mySelect.options.length] = new Option("Paramus Schools",'all=Paramus'); mySelect.options[mySelect.options.length] = new Option("Paterson Schools",'all=Paterson'); mySelect.options[mySelect.options.length] = new Option("Pemberton Schools",'all=Pemberton'); mySelect.options[mySelect.options.length] = new Option("Randolph Schools",'all=Randolph'); mySelect.options[mySelect.options.length] = new Option("Sewell Schools",'all=Sewell'); mySelect.options[mySelect.options.length] = new Option("Toms River Schools",'all=Toms_River'); mySelect.options[mySelect.options.length] = new Option("Vineland Schools",'all=Vineland'); mySelect.options[mySelect.options.length] = new Option("Washington Schools",'all=Washington'); mySelect.options[mySelect.options.length] = new Option("West Paterson Schools",'all=West_Paterson'); mySelect.options[mySelect.options.length] = new Option("West Windsor Schools",'all=West_Windsor'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); var tmpLatLng=0; var tmpLen=0; tmpLatLng=new GLatLng(40.75453499999999706,-74.6033170000000041); tmpLen=Mendham.length; Mendham[tmpLen] = createMarker(tmpLatLng,"
",iconRd); Mendham[tmpLen].point = tmpLatLng; mySelect.options[mySelect.options.length] = new Option("Assumption College For Sisters",'Mendham=' + Mendham.length); tmpLatLng=new GLatLng(39.46545900000000273,-74.6826269999999965); tmpLen=Mays_Landing.length; Mays_Landing[tmpLen] = createMarker(tmpLatLng,"",iconGr); Mays_Landing[tmpLen].point = tmpLatLng; mySelect.options[mySelect.options.length] = new Option("Atlantic Cape Community College",'Mays_Landing=' + Mays_Landing.length); tmpLatLng=new GLatLng(40.95149800000000084,-74.0935860000000019); tmpLen=Paramus.length; Paramus[tmpLen] = createMarker(tmpLatLng,"",iconGr); Paramus[tmpLen].point = tmpLatLng; mySelect.options[mySelect.options.length] = new Option("Bergen Community College",'Paramus=' + Paramus.length); tmpLatLng=new GLatLng(40.90026100000000042,-74.1871770000000054); tmpLen=West_Paterson.length; West_Paterson[tmpLen] = createMarker(tmpLatLng,"",iconRd); West_Paterson[tmpLen].point = tmpLatLng; mySelect.options[mySelect.options.length] = new Option("Berkeley College",'West_Paterson=' + West_Paterson.length); tmpLatLng=new GLatLng(40.33311599999999685,-74.1338789999999931); tmpLen=Lincroft.length; Lincroft[tmpLen] = createMarker(tmpLatLng,"",iconGr); Lincroft[tmpLen].point = tmpLatLng; mySelect.options[mySelect.options.length] = new Option("Brookdale Community College",'Lincroft=' + Lincroft.length); tmpLatLng=new GLatLng(39.97185900000000202,-74.6833189999999973); tmpLen=Pemberton.length; Pemberton[tmpLen] = createMarker(tmpLatLng,"",iconGr); Pemberton[tmpLen].point = tmpLatLng; mySelect.options[mySelect.options.length] = new Option("Burlington County College",'Pemberton=' + Pemberton.length); tmpLatLng=new GLatLng(39.78123999999999682,-75.0533999999999963); tmpLen=Blackwood.length; Blackwood[tmpLen] = createMarker(tmpLatLng,"",iconGr); Blackwood[tmpLen].point = tmpLatLng; mySelect.options[mySelect.options.length] = new Option("Camden County College",'Blackwood=' + Blackwood.length); tmpLatLng=new GLatLng(40.85684700000000191,-74.5742300000000000); tmpLen=Randolph.length; Randolph[tmpLen] = createMarker(tmpLatLng,"",iconGr); Randolph[tmpLen].point = tmpLatLng; mySelect.options[mySelect.options.length] = new Option("County College Of Morris",'Randolph=' + Randolph.length); tmpLatLng=new GLatLng(39.43981500000000295,-75.0554219999999929); tmpLen=Vineland.length; Vineland[tmpLen] = createMarker(tmpLatLng,"",iconGr); Vineland[tmpLen].point = tmpLatLng; mySelect.options[mySelect.options.length] = new Option("Cumberland County College",'Vineland=' + Vineland.length); tmpLatLng=new GLatLng(40.46409100000000336,-74.4498310000000032); tmpLen=North_Brunswick.length; North_Brunswick[tmpLen] = createMarker(tmpLatLng,"",iconRd); North_Brunswick[tmpLen].point = tmpLatLng; mySelect.options[mySelect.options.length] = new Option("Devry University-new Jersey",'North_Brunswick=' + North_Brunswick.length); tmpLatLng=new GLatLng(40.73732100000000144,-74.1765989999999959); tmpLen=Newark.length; Newark[tmpLen] = createMarker(tmpLatLng,"",iconGr); Newark[tmpLen].point = tmpLatLng; mySelect.options[mySelect.options.length] = new Option("Essex County College",'Newark=' + Newark.length); tmpLatLng=new GLatLng(40.81239999999999668,-74.2215900000000061); tmpLen=Livingston.length; Livingston[tmpLen] = createMarker(tmpLatLng,"",iconRd); Livingston[tmpLen].point = tmpLatLng; mySelect.options[mySelect.options.length] = new Option("Gibbs College",'Livingston=' + Livingston.length); tmpLatLng=new GLatLng(39.78326899999999710,-75.1278099999999966); tmpLen=Sewell.length; Sewell[tmpLen] = createMarker(tmpLatLng,"",iconGr); Sewell[tmpLen].point = tmpLatLng; mySelect.options[mySelect.options.length] = new Option("Gloucester County College",'Sewell=' + Sewell.length); tmpLatLng=new GLatLng(40.73061599999999771,-74.0620849999999961); tmpLen=Jersey_City.length; Jersey_City[tmpLen] = createMarker(tmpLatLng,"",iconGr); Jersey_City[tmpLen].point = tmpLatLng; mySelect.options[mySelect.options.length] = new Option("Hudson County Community College",'Jersey_City=' + Jersey_City.length); tmpLatLng=new GLatLng(40.25131100000000117,-74.6515870000000063); tmpLen=West_Windsor.length; West_Windsor[tmpLen] = createMarker(tmpLatLng,"",iconGr); West_Windsor[tmpLen].point = tmpLatLng; mySelect.options[mySelect.options.length] = new Option("Mercer County Community College",'West_Windsor=' + West_Windsor.length); tmpLatLng=new GLatLng(40.50790400000000346,-74.3714930000000009); tmpLen=Edison.length; Edison[tmpLen] = createMarker(tmpLatLng,"",iconGr); Edison[tmpLen].point = tmpLatLng; mySelect.options[mySelect.options.length] = new Option("Middlesex County College",'Edison=' + Edison.length); tmpLatLng=new GLatLng(40.00898000000000109,-74.1637800000000027); tmpLen=Toms_River.length; Toms_River[tmpLen] = createMarker(tmpLatLng,"",iconGr); Toms_River[tmpLen].point = tmpLatLng; mySelect.options[mySelect.options.length] = new Option("Ocean County College",'Toms_River=' + Toms_River.length); tmpLatLng=new GLatLng(40.91799999999999926,-74.1693000000000068); tmpLen=Paterson.length; Paterson[tmpLen] = createMarker(tmpLatLng,"",iconGr); Paterson[tmpLen].point = tmpLatLng; mySelect.options[mySelect.options.length] = new Option("Passaic County Community College",'Paterson=' + Paterson.length); tmpLatLng=new GLatLng(40.60660000000000025,-74.6944000000000016); tmpLen=North_Branch.length; North_Branch[tmpLen] = createMarker(tmpLatLng,"",iconGr); North_Branch[tmpLen].point = tmpLatLng; mySelect.options[mySelect.options.length] = new Option("Raritan Valley Community College",'North_Branch=' + North_Branch.length); tmpLatLng=new GLatLng(39.69736100000000078,-75.4690480000000007); tmpLen=Carneys_Point.length; Carneys_Point[tmpLen] = createMarker(tmpLatLng,"",iconGr); Carneys_Point[tmpLen].point = tmpLatLng; mySelect.options[mySelect.options.length] = new Option("Salem Community College",'Carneys_Point=' + Carneys_Point.length); tmpLatLng=new GLatLng(41.06506399999999956,-74.7559530000000052); tmpLen=Newton.length; Newton[tmpLen] = createMarker(tmpLatLng,"",iconGr); Newton[tmpLen].point = tmpLatLng; mySelect.options[mySelect.options.length] = new Option("Sussex County Community College",'Newton=' + Newton.length); tmpLatLng=new GLatLng(40.66805899999999951,-74.3183640000000025); tmpLen=Cranford.length; Cranford[tmpLen] = createMarker(tmpLatLng,"",iconGr); Cranford[tmpLen].point = tmpLatLng; mySelect.options[mySelect.options.length] = new Option("Union County College",'Cranford=' + Cranford.length); tmpLatLng=new GLatLng(40.74649900000000002,-75.0182269999999959); tmpLen=Washington.length; Washington[tmpLen] = createMarker(tmpLatLng,"",iconGr); Washington[tmpLen].point = tmpLatLng; mySelect.options[mySelect.options.length] = new Option("Warren County Community College",'Washington=' + Washington.length); map.removeOverlays(Blackwood); map.removeOverlays(Carneys_Point); map.removeOverlays(Cranford); map.removeOverlays(Edison); map.removeOverlays(Jersey_City); map.removeOverlays(Lincroft); map.removeOverlays(Livingston); map.removeOverlays(Mays_Landing); map.removeOverlays(Mendham); map.removeOverlays(Newark); map.removeOverlays(Newton); map.removeOverlays(North_Branch); map.removeOverlays(North_Brunswick); map.removeOverlays(Paramus); map.removeOverlays(Paterson); map.removeOverlays(Pemberton); map.removeOverlays(Randolph); map.removeOverlays(Sewell); map.removeOverlays(Toms_River); map.removeOverlays(Vineland); map.removeOverlays(Washington); map.removeOverlays(West_Paterson); map.removeOverlays(West_Windsor); setTimeout(function(){map.addOverlays(Blackwood)},1000); setTimeout(function(){map.addOverlays(Carneys_Point)},1000); setTimeout(function(){map.addOverlays(Cranford)},1000); setTimeout(function(){map.addOverlays(Edison)},1000); setTimeout(function(){map.addOverlays(Jersey_City)},1000); setTimeout(function(){map.addOverlays(Lincroft)},1000); setTimeout(function(){map.addOverlays(Livingston)},1000); setTimeout(function(){map.addOverlays(Mays_Landing)},1000); setTimeout(function(){map.addOverlays(Mendham)},1000); setTimeout(function(){map.addOverlays(Newark)},1000); setTimeout(function(){map.addOverlays(Newton)},1000); setTimeout(function(){map.addOverlays(North_Branch)},1000); setTimeout(function(){map.addOverlays(North_Brunswick)},1000); setTimeout(function(){map.addOverlays(Paramus)},1000); setTimeout(function(){map.addOverlays(Paterson)},1000); setTimeout(function(){map.addOverlays(Pemberton)},1000); setTimeout(function(){map.addOverlays(Randolph)},1000); setTimeout(function(){map.addOverlays(Sewell)},1000); setTimeout(function(){map.addOverlays(Toms_River)},1000); setTimeout(function(){map.addOverlays(Vineland)},1000); setTimeout(function(){map.addOverlays(Washington)},1000); setTimeout(function(){map.addOverlays(West_Paterson)},1000); setTimeout(function(){map.addOverlays(West_Windsor)},1000); getPoly("","state","","NJ");} // End addStateMarkers JavaScript Function //open all when map is defined function openAll() { if (map) { selectChange("all"); } else { setTimeout("openAll()",200); } } // 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].point.x; var markLat = myArray[i].point.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].point.x; maxLat = myArray[0].point.y; minLng = myArray[0].point.x; minLat = myArray[0].point.y; } // Recenter map based on global max/mins function reCenterMap(){ //alert('#' + minLat + '#' + minLng + '#' + maxLat + '#' + maxLng); 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,10); /* 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) { if (selection.options) { var _openNewWindow=true; var myVal = selection.options[selection.selectedIndex].value; } else { var _openNewWindow=false; var myVal=selection; } 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('schools-by-distance') == -1) window.open(location.href + '/map/all'); else window.open('/search////all'); map.removeOverlays(Blackwood); map.removeOverlays(Carneys_Point); map.removeOverlays(Cranford); map.removeOverlays(Edison); map.removeOverlays(Jersey_City); map.removeOverlays(Lincroft); map.removeOverlays(Livingston); map.removeOverlays(Mays_Landing); map.removeOverlays(Mendham); map.removeOverlays(Newark); map.removeOverlays(Newton); map.removeOverlays(North_Branch); map.removeOverlays(North_Brunswick); map.removeOverlays(Paramus); map.removeOverlays(Paterson); map.removeOverlays(Pemberton); map.removeOverlays(Randolph); map.removeOverlays(Sewell); map.removeOverlays(Toms_River); map.removeOverlays(Vineland); map.removeOverlays(Washington); map.removeOverlays(West_Paterson); map.removeOverlays(West_Windsor); 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(Mendham);map.removeOverlays(Blackwood); map.removeOverlays(Carneys_Point); map.removeOverlays(Cranford); map.removeOverlays(Edison); map.removeOverlays(Jersey_City); map.removeOverlays(Lincroft); map.removeOverlays(Livingston); map.removeOverlays(Mays_Landing); map.removeOverlays(Mendham); map.removeOverlays(Newark); map.removeOverlays(Newton); map.removeOverlays(North_Branch); map.removeOverlays(North_Brunswick); map.removeOverlays(Paramus); map.removeOverlays(Paterson); map.removeOverlays(Pemberton); map.removeOverlays(Randolph); map.removeOverlays(Sewell); map.removeOverlays(Toms_River); map.removeOverlays(Vineland); map.removeOverlays(Washington); map.removeOverlays(West_Paterson); map.removeOverlays(West_Windsor); map.addOverlays(Blackwood); centerByArray(Blackwood, false, false); cntMarker += Blackwood.length; map.addOverlays(Carneys_Point); centerByArray(Carneys_Point, false, false); cntMarker += Carneys_Point.length; map.addOverlays(Cranford); centerByArray(Cranford, false, false); cntMarker += Cranford.length; map.addOverlays(Edison); centerByArray(Edison, false, false); cntMarker += Edison.length; map.addOverlays(Jersey_City); centerByArray(Jersey_City, false, false); cntMarker += Jersey_City.length; map.addOverlays(Lincroft); centerByArray(Lincroft, false, false); cntMarker += Lincroft.length; map.addOverlays(Livingston); centerByArray(Livingston, false, false); cntMarker += Livingston.length; map.addOverlays(Mays_Landing); centerByArray(Mays_Landing, false, false); cntMarker += Mays_Landing.length; map.addOverlays(Mendham); centerByArray(Mendham, false, false); cntMarker += Mendham.length; map.addOverlays(Newark); centerByArray(Newark, false, false); cntMarker += Newark.length; map.addOverlays(Newton); centerByArray(Newton, false, false); cntMarker += Newton.length; map.addOverlays(North_Branch); centerByArray(North_Branch, false, false); cntMarker += North_Branch.length; map.addOverlays(North_Brunswick); centerByArray(North_Brunswick, false, false); cntMarker += North_Brunswick.length; map.addOverlays(Paramus); centerByArray(Paramus, false, false); cntMarker += Paramus.length; map.addOverlays(Paterson); centerByArray(Paterson, false, false); cntMarker += Paterson.length; map.addOverlays(Pemberton); centerByArray(Pemberton, false, false); cntMarker += Pemberton.length; map.addOverlays(Randolph); centerByArray(Randolph, false, false); cntMarker += Randolph.length; map.addOverlays(Sewell); centerByArray(Sewell, false, false); cntMarker += Sewell.length; map.addOverlays(Toms_River); centerByArray(Toms_River, false, false); cntMarker += Toms_River.length; map.addOverlays(Vineland); centerByArray(Vineland, false, false); cntMarker += Vineland.length; map.addOverlays(Washington); centerByArray(Washington, false, false); cntMarker += Washington.length; map.addOverlays(West_Paterson); centerByArray(West_Paterson, false, false); cntMarker += West_Paterson.length; map.addOverlays(West_Windsor); centerByArray(West_Windsor, false, false); cntMarker += West_Windsor.length; reCenterMap(); //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'); } } function createMarker(point, label, icon){ var marker = new GMarker(point, icon); var html = label; GEvent.addListener(marker, "click", function() { marker.openInfoWindowHtml(html); }); return marker; }