function addMarkers() { mySelect = document.getElementById('selection'); Benson = [];Clayton = [];Garner = [];Zebulon = [];Four_Oaks = [];Kenly = [];Smithfield = [];Angier = [];Pine_Level = [];Micro = [];Princeton = [];Selma = [];Wilsons_Mills = [];mySelect.options[mySelect.options.length] = new Option("Angier schools",'all=Angier'); mySelect.options[mySelect.options.length] = new Option("Benson schools",'all=Benson'); mySelect.options[mySelect.options.length] = new Option("Clayton schools",'all=Clayton'); mySelect.options[mySelect.options.length] = new Option("Four Oaks schools",'all=Four_Oaks'); mySelect.options[mySelect.options.length] = new Option("Garner schools",'all=Garner'); mySelect.options[mySelect.options.length] = new Option("Kenly schools",'all=Kenly'); mySelect.options[mySelect.options.length] = new Option("Micro schools",'all=Micro'); mySelect.options[mySelect.options.length] = new Option("Pine Level schools",'all=Pine_Level'); mySelect.options[mySelect.options.length] = new Option("Princeton schools",'all=Princeton'); mySelect.options[mySelect.options.length] = new Option("Selma schools",'all=Selma'); mySelect.options[mySelect.options.length] = new Option("Smithfield schools",'all=Smithfield'); mySelect.options[mySelect.options.length] = new Option("Wilsons Mills schools",'all=Wilsons_Mills'); mySelect.options[mySelect.options.length] = new Option("Zebulon schools",'all=Zebulon'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Benson[Benson.length] = createMarker(new GPoint(-78.55718994,35.40326691),"
",iconRd); mySelect.options[mySelect.options.length] = new Option("Benson Elementary School",'Benson=' + Benson.length); Benson[Benson.length] = createMarker(new GPoint(-78.54786682,35.37750244),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Benson Middle School",'Benson=' + Benson.length); Clayton[Clayton.length] = createMarker(new GPoint(-78.46468353,35.64956665),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Clayton High School",'Clayton=' + Clayton.length); Clayton[Clayton.length] = createMarker(new GPoint(-78.48583221,35.64376068),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Clayton Middle School",'Clayton=' + Clayton.length); Clayton[Clayton.length] = createMarker(new GPoint(-78.53711700,35.57504272),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Cleveland Elementary School",'Clayton=' + Clayton.length); Garner[Garner.length] = createMarker(new GPoint(-78.54724884,35.57546616),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Cleveland Middle School",'Garner=' + Garner.length); Clayton[Clayton.length] = createMarker(new GPoint(-78.45153809,35.65639877),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Cooper Elementary School",'Clayton=' + Clayton.length); Zebulon[Zebulon.length] = createMarker(new GPoint(-78.31462860,35.82429886),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Corinth Holders Elementary School",'Zebulon=' + Zebulon.length); Clayton[Clayton.length] = createMarker(new GPoint(-78.40378571,35.64755249),"",iconRd); mySelect.options[mySelect.options.length] = new Option("East Clayton Elementary School",'Clayton=' + Clayton.length); Four_Oaks[Four_Oaks.length] = createMarker(new GPoint(-78.43324280,35.44944000),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Four Oaks Elementary School",'Four_Oaks=' + Four_Oaks.length); Four_Oaks[Four_Oaks.length] = createMarker(new GPoint(-78.40360260,35.44887543),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Four Oaks Middle School",'Four_Oaks=' + Four_Oaks.length); Kenly[Kenly.length] = createMarker(new GPoint(-78.13619995,35.61090088),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Glendale-kenly Elementary School",'Kenly=' + Kenly.length); Smithfield[Smithfield.length] = createMarker(new GPoint(-78.33697500,35.50105600),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Johnston Co Middle College",'Smithfield=' + Smithfield.length); Angier[Angier.length] = createMarker(new GPoint(-83.52335400,40.53353700),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Mcgee's Crossroads Elementary School",'Angier=' + Angier.length); Benson[Benson.length] = createMarker(new GPoint(-83.51528100,40.80074600),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Mcgee's Crossroads Middle School",'Benson=' + Benson.length); Benson[Benson.length] = createMarker(new GPoint(-78.54894257,35.38199997),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Meadow Elementary School",'Benson=' + Benson.length); Pine_Level[Pine_Level.length] = createMarker(new GPoint(-78.24469757,35.51300049),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Micro-pine Level Elementary School",'Pine_Level=' + Pine_Level.length); Kenly[Kenly.length] = createMarker(new GPoint(-78.13619995,35.61090088),"",iconGr); mySelect.options[mySelect.options.length] = new Option("North Johnston High School",'Kenly=' + Kenly.length); Micro[Micro.length] = createMarker(new GPoint(-78.20469666,35.56359863),"",iconBl); mySelect.options[mySelect.options.length] = new Option("North Johnston Middle School",'Micro=' + Micro.length); Garner[Garner.length] = createMarker(new GPoint(-78.51256561,35.57516098),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Polenta Elementary School",'Garner=' + Garner.length); Princeton[Princeton.length] = createMarker(new GPoint(-78.17009735,35.46250153),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Princeton High School",'Princeton=' + Princeton.length); Clayton[Clayton.length] = createMarker(new GPoint(-78.47160339,35.62459946),"",iconRd); mySelect.options[mySelect.options.length] = new Option("River Dell Elementary School",'Clayton=' + Clayton.length); Clayton[Clayton.length] = createMarker(new GPoint(-78.45639801,35.65069962),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Riverwood Elementary School",'Clayton=' + Clayton.length); Clayton[Clayton.length] = createMarker(new GPoint(-78.42337036,35.69352722),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Riverwood Middle School",'Clayton=' + Clayton.length); Selma[Selma.length] = createMarker(new GPoint(-78.28325653,35.54059219),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Selma Elementary School",'Selma=' + Selma.length); Selma[Selma.length] = createMarker(new GPoint(-78.28443909,35.53631973),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Selma Middle School",'Selma=' + Selma.length); Smithfield[Smithfield.length] = createMarker(new GPoint(-78.34950256,35.50939941),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Smithfield Middle School",'Smithfield=' + Smithfield.length); Smithfield[Smithfield.length] = createMarker(new GPoint(-78.34950256,35.50939941),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Smithfield-selma High School",'Smithfield=' + Smithfield.length); Smithfield[Smithfield.length] = createMarker(new GPoint(-78.34950256,35.50939941),"",iconGr); mySelect.options[mySelect.options.length] = new Option("South Campus Community",'Smithfield=' + Smithfield.length); Smithfield[Smithfield.length] = createMarker(new GPoint(-78.34671400,35.51151500),"",iconBl); mySelect.options[mySelect.options.length] = new Option("South Campus Community Middle School",'Smithfield=' + Smithfield.length); Four_Oaks[Four_Oaks.length] = createMarker(new GPoint(-78.42790985,35.44449997),"",iconGr); mySelect.options[mySelect.options.length] = new Option("South Johnston High School",'Four_Oaks=' + Four_Oaks.length); Smithfield[Smithfield.length] = createMarker(new GPoint(-78.35731506,35.49990082),"",iconRd); mySelect.options[mySelect.options.length] = new Option("South Smithfield Elementary School",'Smithfield=' + Smithfield.length); Clayton[Clayton.length] = createMarker(new GPoint(-78.46295929,35.64525986),"",iconRd); mySelect.options[mySelect.options.length] = new Option("West Clayton Elementary School",'Clayton=' + Clayton.length); Benson[Benson.length] = createMarker(new GPoint(-78.54220581,35.52420807),"",iconGr); mySelect.options[mySelect.options.length] = new Option("West Johnston High School",'Benson=' + Benson.length); Smithfield[Smithfield.length] = createMarker(new GPoint(-78.34941864,35.50502014),"",iconRd); mySelect.options[mySelect.options.length] = new Option("West Smithfield Elementary School",'Smithfield=' + Smithfield.length); Wilsons_Mills[Wilsons_Mills.length] = createMarker(new GPoint(-83.79156200,41.10525400),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Wilson's Mills Elementary School",'Wilsons_Mills=' + Wilsons_Mills.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(Angier); map.removeOverlays(Benson); map.removeOverlays(Clayton); map.removeOverlays(Four_Oaks); map.removeOverlays(Garner); map.removeOverlays(Kenly); map.removeOverlays(Micro); map.removeOverlays(Pine_Level); map.removeOverlays(Princeton); map.removeOverlays(Selma); map.removeOverlays(Smithfield); map.removeOverlays(Wilsons_Mills); map.removeOverlays(Zebulon); 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(Benson);map.removeOverlays(Angier); map.removeOverlays(Benson); map.removeOverlays(Clayton); map.removeOverlays(Four_Oaks); map.removeOverlays(Garner); map.removeOverlays(Kenly); map.removeOverlays(Micro); map.removeOverlays(Pine_Level); map.removeOverlays(Princeton); map.removeOverlays(Selma); map.removeOverlays(Smithfield); map.removeOverlays(Wilsons_Mills); map.removeOverlays(Zebulon); map.addOverlays(Angier); centerByArray(Angier, false, false); cntMarker += Angier.length; map.addOverlays(Benson); centerByArray(Benson, false, false); cntMarker += Benson.length; map.addOverlays(Clayton); centerByArray(Clayton, false, false); cntMarker += Clayton.length; map.addOverlays(Four_Oaks); centerByArray(Four_Oaks, false, false); cntMarker += Four_Oaks.length; map.addOverlays(Garner); centerByArray(Garner, false, false); cntMarker += Garner.length; map.addOverlays(Kenly); centerByArray(Kenly, false, false); cntMarker += Kenly.length; map.addOverlays(Micro); centerByArray(Micro, false, false); cntMarker += Micro.length; map.addOverlays(Pine_Level); centerByArray(Pine_Level, false, false); cntMarker += Pine_Level.length; map.addOverlays(Princeton); centerByArray(Princeton, false, false); cntMarker += Princeton.length; map.addOverlays(Selma); centerByArray(Selma, false, false); cntMarker += Selma.length; map.addOverlays(Smithfield); centerByArray(Smithfield, false, false); cntMarker += Smithfield.length; map.addOverlays(Wilsons_Mills); centerByArray(Wilsons_Mills, false, false); cntMarker += Wilsons_Mills.length; map.addOverlays(Zebulon); centerByArray(Zebulon, false, false); cntMarker += Zebulon.length; centerByArray(Benson,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'); } }