function addMarkers() { mySelect = document.getElementById('selection'); Clinton = [];Middletown = [];Portland = [];Higganum = [];East_Hampton = [];Chester = [];Durham = [];Cromwell = [];Westbrook = [];Deep_River = [];Moodus = [];Centerbrook = [];Middlefield = [];Old_Saybrook = [];Killingworth = [];mySelect.options[mySelect.options.length] = new Option("Centerbrook schools",'all=Centerbrook'); mySelect.options[mySelect.options.length] = new Option("Chester schools",'all=Chester'); mySelect.options[mySelect.options.length] = new Option("Clinton schools",'all=Clinton'); mySelect.options[mySelect.options.length] = new Option("Cromwell schools",'all=Cromwell'); mySelect.options[mySelect.options.length] = new Option("Deep River schools",'all=Deep_River'); mySelect.options[mySelect.options.length] = new Option("Durham schools",'all=Durham'); mySelect.options[mySelect.options.length] = new Option("East Hampton schools",'all=East_Hampton'); mySelect.options[mySelect.options.length] = new Option("Higganum schools",'all=Higganum'); mySelect.options[mySelect.options.length] = new Option("Killingworth schools",'all=Killingworth'); mySelect.options[mySelect.options.length] = new Option("Middlefield schools",'all=Middlefield'); mySelect.options[mySelect.options.length] = new Option("Middletown schools",'all=Middletown'); mySelect.options[mySelect.options.length] = new Option("Moodus schools",'all=Moodus'); mySelect.options[mySelect.options.length] = new Option("Old Saybrook schools",'all=Old_Saybrook'); mySelect.options[mySelect.options.length] = new Option("Portland schools",'all=Portland'); mySelect.options[mySelect.options.length] = new Option("Westbrook schools",'all=Westbrook'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Clinton[Clinton.length] = createMarker(new GPoint(-72.52151489,41.27754211),"
",iconBl); mySelect.options[mySelect.options.length] = new Option("Abraham Pierson School",'Clinton=' + Clinton.length); Middletown[Middletown.length] = createMarker(new GPoint(-72.63354492,41.54301834),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Bielefield School",'Middletown=' + Middletown.length); Portland[Portland.length] = createMarker(new GPoint(-72.63768000,41.57722700),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Brownstone Intermediate School",'Portland=' + Portland.length); Higganum[Higganum.length] = createMarker(new GPoint(-72.55524445,41.45270157),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Burr District Elementary School",'Higganum=' + Higganum.length); East_Hampton[East_Hampton.length] = createMarker(new GPoint(-72.50112152,41.57715988),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Center School",'East_Hampton=' + East_Hampton.length); Chester[Chester.length] = createMarker(new GPoint(-72.45890808,41.40499878),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Chester Elementary School",'Chester=' + Chester.length); Durham[Durham.length] = createMarker(new GPoint(-72.67181396,41.47637177),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Coginchaug Regional High School",'Durham=' + Durham.length); Middletown[Middletown.length] = createMarker(new GPoint(-72.64273071,41.55107498),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Connecticut Juvenile Training School",'Middletown=' + Middletown.length); Cromwell[Cromwell.length] = createMarker(new GPoint(-72.65698242,41.61302567),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Cromwell High School",'Cromwell=' + Cromwell.length); Cromwell[Cromwell.length] = createMarker(new GPoint(-72.65588379,41.62683868),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Cromwell Middle School",'Cromwell=' + Cromwell.length); Westbrook[Westbrook.length] = createMarker(new GPoint(-72.44770813,41.28583145),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Daisy Ingraham School",'Westbrook=' + Westbrook.length); Deep_River[Deep_River.length] = createMarker(new GPoint(-72.43554687,41.38635635),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Deep River Elementary School",'Deep_River=' + Deep_River.length); Moodus[Moodus.length] = createMarker(new GPoint(-72.43810272,41.50640106),"",iconRd); mySelect.options[mySelect.options.length] = new Option("East Haddam Elementary School",'Moodus=' + Moodus.length); East_Hampton[East_Hampton.length] = createMarker(new GPoint(-72.51329041,41.58688736),"",iconGr); mySelect.options[mySelect.options.length] = new Option("East Hampton High School",'East_Hampton=' + East_Hampton.length); East_Hampton[East_Hampton.length] = createMarker(new GPoint(-72.52434540,41.57055664),"",iconBl); mySelect.options[mySelect.options.length] = new Option("East Hampton Middle School",'East_Hampton=' + East_Hampton.length); Cromwell[Cromwell.length] = createMarker(new GPoint(-72.65869904,41.62017822),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Edna C. Stevens School",'Cromwell=' + Cromwell.length); Centerbrook[Centerbrook.length] = createMarker(new GPoint(-72.42202759,41.34949875),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Essex Elementary School",'Centerbrook=' + Centerbrook.length); Middletown[Middletown.length] = createMarker(new GPoint(-72.63323975,41.52988052),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Farm Hill School",'Middletown=' + Middletown.length); Durham[Durham.length] = createMarker(new GPoint(-72.67141724,41.47676468),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Francis E. Korn School",'Durham=' + Durham.length); Durham[Durham.length] = createMarker(new GPoint(-72.68027496,41.47625351),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Frank Ward Strong School",'Durham=' + Durham.length); Durham[Durham.length] = createMarker(new GPoint(-72.70319366,41.46149445),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Frederick Brewster School",'Durham=' + Durham.length); Portland[Portland.length] = createMarker(new GPoint(-72.62290192,41.59238815),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Gildersleeve School",'Portland=' + Portland.length); Higganum[Higganum.length] = createMarker(new GPoint(-72.56111900,41.49738400),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Haddam Elementary School",'Higganum=' + Higganum.length); Higganum[Higganum.length] = createMarker(new GPoint(-72.58312988,41.45139313),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Haddam-killingworth High School",'Higganum=' + Higganum.length); Higganum[Higganum.length] = createMarker(new GPoint(-72.58242798,41.45177078),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Haddam-killingworth Middle School",'Higganum=' + Higganum.length); Middletown[Middletown.length] = createMarker(new GPoint(-72.64707184,41.54158401),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Homebound",'Middletown=' + Middletown.length); Clinton[Clinton.length] = createMarker(new GPoint(-72.51923370,41.29789734),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Jared Eliot School",'Clinton=' + Clinton.length); Middlefield[Middlefield.length] = createMarker(new GPoint(-72.72305298,41.51739502),"",iconRd); mySelect.options[mySelect.options.length] = new Option("John Lyman School",'Middlefield=' + Middlefield.length); Deep_River[Deep_River.length] = createMarker(new GPoint(-72.44840240,41.37680054),"",iconBl); mySelect.options[mySelect.options.length] = new Option("John Winthrop Junior High School",'Deep_River=' + Deep_River.length); Old_Saybrook[Old_Saybrook.length] = createMarker(new GPoint(-72.38118744,41.28768921),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Kathleen E. Goodwin School",'Old_Saybrook=' + Old_Saybrook.length); Middletown[Middletown.length] = createMarker(new GPoint(-72.67722321,41.57780457),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Keigwin Annex Middle School",'Middletown=' + Middletown.length); Killingworth[Killingworth.length] = createMarker(new GPoint(-72.56493378,41.37134933),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Killingworth Elementary School",'Killingworth=' + Killingworth.length); Middletown[Middletown.length] = createMarker(new GPoint(-72.68324280,41.58663940),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Lawrence School",'Middletown=' + Middletown.length); Clinton[Clinton.length] = createMarker(new GPoint(-72.52439880,41.30401993),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Lewin G. Joel Junior School",'Clinton=' + Clinton.length); Middletown[Middletown.length] = createMarker(new GPoint(-72.66479492,41.54895782),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Long Lane High School",'Middletown=' + Middletown.length); Middletown[Middletown.length] = createMarker(new GPoint(-72.65582275,41.56608582),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Macdonough School",'Middletown=' + Middletown.length); East_Hampton[East_Hampton.length] = createMarker(new GPoint(-72.48839569,41.57019424),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Memorial School",'East_Hampton=' + East_Hampton.length); Middlefield[Middlefield.length] = createMarker(new GPoint(-72.69754028,41.52145767),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Middlefield Memorial School",'Middlefield=' + Middlefield.length); Middletown[Middletown.length] = createMarker(new GPoint(-72.64683533,41.54053116),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Middletown High School",'Middletown=' + Middletown.length); Middletown[Middletown.length] = createMarker(new GPoint(-72.71215820,41.56247711),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Moody School",'Middletown=' + Middletown.length); Clinton[Clinton.length] = createMarker(new GPoint(-72.53153229,41.29349899),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Morgan School",'Clinton=' + Clinton.length); Moodus[Moodus.length] = createMarker(new GPoint(-72.43810272,41.50640106),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Nathan Hale-ray High School",'Moodus=' + Moodus.length); Moodus[Moodus.length] = createMarker(new GPoint(-72.43810272,41.50640106),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Nathan Hale-ray Middle School",'Moodus=' + Moodus.length); Old_Saybrook[Old_Saybrook.length] = createMarker(new GPoint(-72.37042999,41.29022980),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Old Saybrook Middle School",'Old_Saybrook=' + Old_Saybrook.length); Old_Saybrook[Old_Saybrook.length] = createMarker(new GPoint(-72.39620209,41.28748322),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Old Saybrook Senior High School",'Old_Saybrook=' + Old_Saybrook.length); Portland[Portland.length] = createMarker(new GPoint(-72.62512207,41.58059311),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Portland High School",'Portland=' + Portland.length); Portland[Portland.length] = createMarker(new GPoint(-72.63681793,41.57775879),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Portland Middle School",'Portland=' + Portland.length); Middletown[Middletown.length] = createMarker(new GPoint(-72.61181641,41.55870438),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Riverview Hospital",'Middletown=' + Middletown.length); Middletown[Middletown.length] = createMarker(new GPoint(-72.67012024,41.54247665),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Snow School",'Middletown=' + Middletown.length); Middletown[Middletown.length] = createMarker(new GPoint(-72.67577362,41.56390381),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Spencer School",'Middletown=' + Middletown.length); Deep_River[Deep_River.length] = createMarker(new GPoint(-72.44773102,41.36840057),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Valley Regional High School",'Deep_River=' + Deep_River.length); Portland[Portland.length] = createMarker(new GPoint(-72.62570953,41.57931137),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Valley View School",'Portland=' + Portland.length); Middletown[Middletown.length] = createMarker(new GPoint(-72.67355347,41.52750015),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Vinal Vocational School",'Middletown=' + Middletown.length); Middletown[Middletown.length] = createMarker(new GPoint(-72.66621399,41.52269363),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Wesley School",'Middletown=' + Middletown.length); Westbrook[Westbrook.length] = createMarker(new GPoint(-72.45442963,41.29750061),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Westbrook High School",'Westbrook=' + Westbrook.length); Westbrook[Westbrook.length] = createMarker(new GPoint(-72.45442963,41.29750061),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Westbrook Middle School",'Westbrook=' + Westbrook.length); Middletown[Middletown.length] = createMarker(new GPoint(-80.15400800,25.99088200),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Woodrow Wilson Middle School",'Middletown=' + Middletown.length); Cromwell[Cromwell.length] = createMarker(new GPoint(-72.66017200,41.62282600),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Woodside Intermediate School",'Cromwell=' + Cromwell.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,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) { 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////' + showArray); map.removeOverlays(Centerbrook); map.removeOverlays(Chester); map.removeOverlays(Clinton); map.removeOverlays(Cromwell); map.removeOverlays(Deep_River); map.removeOverlays(Durham); map.removeOverlays(East_Hampton); map.removeOverlays(Higganum); map.removeOverlays(Killingworth); map.removeOverlays(Middlefield); map.removeOverlays(Middletown); map.removeOverlays(Moodus); map.removeOverlays(Old_Saybrook); map.removeOverlays(Portland); map.removeOverlays(Westbrook); 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(Clinton);map.removeOverlays(Centerbrook); map.removeOverlays(Chester); map.removeOverlays(Clinton); map.removeOverlays(Cromwell); map.removeOverlays(Deep_River); map.removeOverlays(Durham); map.removeOverlays(East_Hampton); map.removeOverlays(Higganum); map.removeOverlays(Killingworth); map.removeOverlays(Middlefield); map.removeOverlays(Middletown); map.removeOverlays(Moodus); map.removeOverlays(Old_Saybrook); map.removeOverlays(Portland); map.removeOverlays(Westbrook); map.addOverlays(Centerbrook); centerByArray(Centerbrook, false, false); cntMarker += Centerbrook.length; map.addOverlays(Chester); centerByArray(Chester, false, false); cntMarker += Chester.length; map.addOverlays(Clinton); centerByArray(Clinton, false, false); cntMarker += Clinton.length; map.addOverlays(Cromwell); centerByArray(Cromwell, false, false); cntMarker += Cromwell.length; map.addOverlays(Deep_River); centerByArray(Deep_River, false, false); cntMarker += Deep_River.length; map.addOverlays(Durham); centerByArray(Durham, false, false); cntMarker += Durham.length; map.addOverlays(East_Hampton); centerByArray(East_Hampton, false, false); cntMarker += East_Hampton.length; map.addOverlays(Higganum); centerByArray(Higganum, false, false); cntMarker += Higganum.length; map.addOverlays(Killingworth); centerByArray(Killingworth, false, false); cntMarker += Killingworth.length; map.addOverlays(Middlefield); centerByArray(Middlefield, false, false); cntMarker += Middlefield.length; map.addOverlays(Middletown); centerByArray(Middletown, false, false); cntMarker += Middletown.length; map.addOverlays(Moodus); centerByArray(Moodus, false, false); cntMarker += Moodus.length; map.addOverlays(Old_Saybrook); centerByArray(Old_Saybrook, false, false); cntMarker += Old_Saybrook.length; map.addOverlays(Portland); centerByArray(Portland, false, false); cntMarker += Portland.length; map.addOverlays(Westbrook); centerByArray(Westbrook, false, false); cntMarker += Westbrook.length; centerByArray(Clinton,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'); } }