function addMarkers(){ mySelect = document.getElementById('selection'); Rooseveltown = [];Heuvelton = [];Rensselaer_Falls = [];De_Peyster = [];Canton = [];Massena = [];Richville = [];Gouverneur = [];Potsdam = [];Ogdensburg = [];Nicholville = [];Depeyster = [];mySelect.options[mySelect.options.length] = new Option("Canton schools",'all=Canton'); mySelect.options[mySelect.options.length] = new Option("De Peyster schools",'all=De_Peyster'); mySelect.options[mySelect.options.length] = new Option("Depeyster schools",'all=Depeyster'); mySelect.options[mySelect.options.length] = new Option("Gouverneur schools",'all=Gouverneur'); mySelect.options[mySelect.options.length] = new Option("Heuvelton schools",'all=Heuvelton'); mySelect.options[mySelect.options.length] = new Option("Massena schools",'all=Massena'); mySelect.options[mySelect.options.length] = new Option("Nicholville schools",'all=Nicholville'); mySelect.options[mySelect.options.length] = new Option("Ogdensburg schools",'all=Ogdensburg'); mySelect.options[mySelect.options.length] = new Option("Potsdam schools",'all=Potsdam'); mySelect.options[mySelect.options.length] = new Option("Rensselaer Falls schools",'all=Rensselaer_Falls'); mySelect.options[mySelect.options.length] = new Option("Richville schools",'all=Richville'); mySelect.options[mySelect.options.length] = new Option("Rooseveltown schools",'all=Rooseveltown'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Rooseveltown[Rooseveltown.length] = createMarker(new GPoint(-74.73130000,44.97270000),"
Akwesasne Freedom School
Mohawk Nation Box 290
Rooseveltown, NY 13683
Co-ed school, PK-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Akwesasne Freedom School",'Rooseveltown=' + Rooseveltown.length); Heuvelton[Heuvelton.length] = createMarker(new GPoint(-75.38552000,44.63466000),"
Amish School/pleasant View School
State Highway 184
Heuvelton, NY 13654
Co-ed school, 1-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Amish School/pleasant View School",'Heuvelton=' + Heuvelton.length); Rensselaer_Falls[Rensselaer_Falls.length] = createMarker(new GPoint(-75.34414200,44.57991800),"
Anderson Valley School
244 Winter Road
Rensselaer Falls, NY 13680
Co-ed school, 1-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Anderson Valley School",'Rensselaer_Falls=' + Rensselaer_Falls.length); De_Peyster[De_Peyster.length] = createMarker(new GPoint(-75.49250000,44.48260000),"
Elm Grove School
St Highway 184
De Peyster, NY 13633
Co-ed school, 1-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Elm Grove School",'De_Peyster=' + De_Peyster.length); Canton[Canton.length] = createMarker(new GPoint(-75.13431100,44.53170500),"
Little River Community School
1227 County Route 25
Canton, NY 13617
Co-ed school, K-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Little River Community School",'Canton=' + Canton.length); Rensselaer_Falls[Rensselaer_Falls.length] = createMarker(new GPoint(-75.32286000,44.59918000),"
Locust Grove
Johnson Road
Rensselaer Falls, NY 13680
Co-ed school, 1-7
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Locust Grove",'Rensselaer_Falls=' + Rensselaer_Falls.length); Massena[Massena.length] = createMarker(new GPoint(-74.91445200,44.92385900),"
Massena Christian Academy
265 Andrews St
Massena, NY 13662
Co-ed school, K-5
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Massena Christian Academy",'Massena=' + Massena.length); De_Peyster[De_Peyster.length] = createMarker(new GPoint(-75.49250000,44.48260000),"
Plimpton School
Plimpton School Cr 10
De Peyster, NY 13633
Co-ed school, 1-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Plimpton School",'De_Peyster=' + De_Peyster.length); Richville[Richville.length] = createMarker(new GPoint(-75.39048300,44.41919700),"
Richville Christian Academy
209 Main Street
Richville, NY 13681
Co-ed school, PK-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Richville Christian Academy",'Richville=' + Richville.length); Heuvelton[Heuvelton.length] = createMarker(new GPoint(-75.42730000,44.59460000),"
Rocky Ledge School
St Hwy 184
Heuvelton, NY 13654
Co-ed school, 2-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Rocky Ledge School",'Heuvelton=' + Heuvelton.length); Gouverneur[Gouverneur.length] = createMarker(new GPoint(-75.46478600,44.33596600),"
St. James Elementary School
20 South Gordan
Gouverneur, NY 13642
Co-ed school, PK-6
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("St. James Elementary School",'Gouverneur=' + Gouverneur.length); Potsdam[Potsdam.length] = createMarker(new GPoint(-74.97472100,44.67476200),"
St. Mary's Elementary School
45 Lawrence Avenue
Potsdam, NY 13676
Co-ed school, PK-6
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("St. Mary's Elementary School",'Potsdam=' + Potsdam.length); Ogdensburg[Ogdensburg.length] = createMarker(new GPoint(-75.49889600,44.68794600),"
St Marguerite D'youville Academy
315 Gates Street
Ogdensburg, NY 13669
Co-ed school, PK-6
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("St Marguerite D'youville Academy",'Ogdensburg=' + Ogdensburg.length); Canton[Canton.length] = createMarker(new GPoint(-75.16799700,44.60135200),"
St Marys School
2 Powers Street
Canton, NY 13617
Co-ed school, PK-6
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("St Marys School",'Canton=' + Canton.length); Nicholville[Nicholville.length] = createMarker(new GPoint(-74.68950000,44.70450000),"
St Therese's Academy
Po Box 128
Nicholville, NY 12965
Co-ed school, K-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("St Therese's Academy",'Nicholville=' + Nicholville.length); Heuvelton[Heuvelton.length] = createMarker(new GPoint(-75.56194000,44.52634000),"
Townline School
Bishop Road
Heuvelton, NY 13654
Co-ed school, 1-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Townline School",'Heuvelton=' + Heuvelton.length); Massena[Massena.length] = createMarker(new GPoint(-74.89159100,44.92659300),"
Trinity Catholic School
188 Main Street
Massena, NY 13662
Co-ed school, PK-6
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Trinity Catholic School",'Massena=' + Massena.length); Depeyster[Depeyster.length] = createMarker(new GPoint(-75.49250000,44.48260000),"
Twin Maples
West Lake Road
Depeyster, NY 13633
Co-ed school, 1-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Twin Maples",'Depeyster=' + Depeyster.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(Canton); map.removeOverlays(De_Peyster); map.removeOverlays(Depeyster); map.removeOverlays(Gouverneur); map.removeOverlays(Heuvelton); map.removeOverlays(Massena); map.removeOverlays(Nicholville); map.removeOverlays(Ogdensburg); map.removeOverlays(Potsdam); map.removeOverlays(Rensselaer_Falls); map.removeOverlays(Richville); map.removeOverlays(Rooseveltown); 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(Rooseveltown);map.removeOverlays(Canton); map.removeOverlays(De_Peyster); map.removeOverlays(Depeyster); map.removeOverlays(Gouverneur); map.removeOverlays(Heuvelton); map.removeOverlays(Massena); map.removeOverlays(Nicholville); map.removeOverlays(Ogdensburg); map.removeOverlays(Potsdam); map.removeOverlays(Rensselaer_Falls); map.removeOverlays(Richville); map.removeOverlays(Rooseveltown); map.addOverlays(Canton); centerByArray(Canton, false, false); cntMarker += Canton.length; map.addOverlays(De_Peyster); centerByArray(De_Peyster, false, false); cntMarker += De_Peyster.length; map.addOverlays(Depeyster); centerByArray(Depeyster, false, false); cntMarker += Depeyster.length; map.addOverlays(Gouverneur); centerByArray(Gouverneur, false, false); cntMarker += Gouverneur.length; map.addOverlays(Heuvelton); centerByArray(Heuvelton, false, false); cntMarker += Heuvelton.length; map.addOverlays(Massena); centerByArray(Massena, false, false); cntMarker += Massena.length; map.addOverlays(Nicholville); centerByArray(Nicholville, false, false); cntMarker += Nicholville.length; map.addOverlays(Ogdensburg); centerByArray(Ogdensburg, false, false); cntMarker += Ogdensburg.length; map.addOverlays(Potsdam); centerByArray(Potsdam, false, false); cntMarker += Potsdam.length; map.addOverlays(Rensselaer_Falls); centerByArray(Rensselaer_Falls, false, false); cntMarker += Rensselaer_Falls.length; map.addOverlays(Richville); centerByArray(Richville, false, false); cntMarker += Richville.length; map.addOverlays(Rooseveltown); centerByArray(Rooseveltown, false, false); cntMarker += Rooseveltown.length; centerByArray(Rooseveltown,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; }