function addMarkers() { mySelect = document.getElementById('selection'); Bunnlevel = [];Angier = [];Olivia = [];Mamers = [];Buies_Creek = [];Cameron = [];Coats = [];Dunn = [];Erwin = [];Sanford = [];Kipling = [];Lillington = [];Spring_Lake = [];mySelect.options[mySelect.options.length] = new Option("Angier schools",'all=Angier'); mySelect.options[mySelect.options.length] = new Option("Buies Creek schools",'all=Buies_Creek'); mySelect.options[mySelect.options.length] = new Option("Bunnlevel schools",'all=Bunnlevel'); mySelect.options[mySelect.options.length] = new Option("Cameron schools",'all=Cameron'); mySelect.options[mySelect.options.length] = new Option("Coats schools",'all=Coats'); mySelect.options[mySelect.options.length] = new Option("Dunn schools",'all=Dunn'); mySelect.options[mySelect.options.length] = new Option("Erwin schools",'all=Erwin'); mySelect.options[mySelect.options.length] = new Option("Kipling schools",'all=Kipling'); mySelect.options[mySelect.options.length] = new Option("Lillington schools",'all=Lillington'); mySelect.options[mySelect.options.length] = new Option("Mamers schools",'all=Mamers'); mySelect.options[mySelect.options.length] = new Option("Olivia schools",'all=Olivia'); mySelect.options[mySelect.options.length] = new Option("Sanford schools",'all=Sanford'); mySelect.options[mySelect.options.length] = new Option("Spring Lake schools",'all=Spring_Lake'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Bunnlevel[Bunnlevel.length] = createMarker(new GPoint(-78.91695404,35.27605057),"
",iconRd); mySelect.options[mySelect.options.length] = new Option("Anderson Creek Primary",'Bunnlevel=' + Bunnlevel.length); Angier[Angier.length] = createMarker(new GPoint(-78.74068451,35.50432587),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Angier Elementary School",'Angier=' + Angier.length); Olivia[Olivia.length] = createMarker(new GPoint(-79.11009979,35.35869980),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Benhaven Elementary School",'Olivia=' + Olivia.length); Mamers[Mamers.length] = createMarker(new GPoint(-78.93360138,35.41659927),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Boone Trail Elementary School",'Mamers=' + Mamers.length); Buies_Creek[Buies_Creek.length] = createMarker(new GPoint(-78.73580170,35.41299820),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Buies Creek Elementary School",'Buies_Creek=' + Buies_Creek.length); Cameron[Cameron.length] = createMarker(new GPoint(-79.26519012,35.32606888),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Cameron Elementary School",'Cameron=' + Cameron.length); Coats[Coats.length] = createMarker(new GPoint(-78.71041870,35.39039993),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Coats Elementary School",'Coats=' + Coats.length); Dunn[Dunn.length] = createMarker(new GPoint(-78.60903168,35.30628967),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Coats-erwin Middle School",'Dunn=' + Dunn.length); Dunn[Dunn.length] = createMarker(new GPoint(-78.60932922,35.32947922),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Dunn Middle School",'Dunn=' + Dunn.length); Erwin[Erwin.length] = createMarker(new GPoint(-78.67082977,35.32485580),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Erwin Elementary School",'Erwin=' + Erwin.length); Erwin[Erwin.length] = createMarker(new GPoint(-78.67366028,35.33899689),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Gentry Primary",'Erwin=' + Erwin.length); Angier[Angier.length] = createMarker(new GPoint(-78.78066254,35.46097946),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Harnett Central High School",'Angier=' + Angier.length); Angier[Angier.length] = createMarker(new GPoint(-78.77881622,35.46065903),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Harnett Central Middle School",'Angier=' + Angier.length); Dunn[Dunn.length] = createMarker(new GPoint(-78.60910034,35.30609894),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Harnett Early Childhood Elementary School",'Dunn=' + Dunn.length); Dunn[Dunn.length] = createMarker(new GPoint(-78.61601257,35.31419754),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Harnett Primary",'Dunn=' + Dunn.length); Sanford[Sanford.length] = createMarker(new GPoint(-79.04391479,35.31859589),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Highland Elementary School",'Sanford=' + Sanford.length); Cameron[Cameron.length] = createMarker(new GPoint(-79.09904480,35.30094528),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Johnsonville Elementary School",'Cameron=' + Cameron.length); Kipling[Kipling.length] = createMarker(new GPoint(-78.82129669,35.47969818),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Lafayette Elementary School",'Kipling=' + Kipling.length); Lillington[Lillington.length] = createMarker(new GPoint(-78.83489990,35.39780045),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Lillington-shawtown Elementary School",'Lillington=' + Lillington.length); Dunn[Dunn.length] = createMarker(new GPoint(-78.47905731,35.18379974),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Midway High School",'Dunn=' + Dunn.length); Angier[Angier.length] = createMarker(new GPoint(-78.77868652,35.47759628),"",iconRd); mySelect.options[mySelect.options.length] = new Option("North Harnett Primary",'Angier=' + Angier.length); Spring_Lake[Spring_Lake.length] = createMarker(new GPoint(-78.94894900,35.22637700),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Overhills High School",'Spring_Lake=' + Spring_Lake.length); Spring_Lake[Spring_Lake.length] = createMarker(new GPoint(-78.95068359,35.22608185),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Overhills Middle School",'Spring_Lake=' + Spring_Lake.length); Lillington[Lillington.length] = createMarker(new GPoint(-78.83120728,35.38320160),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Shawtown Primary",'Lillington=' + Lillington.length); Bunnlevel[Bunnlevel.length] = createMarker(new GPoint(-78.78043365,35.30960083),"",iconRd); mySelect.options[mySelect.options.length] = new Option("South Harnett Elementary School",'Bunnlevel=' + Bunnlevel.length); Lillington[Lillington.length] = createMarker(new GPoint(-78.82159424,35.39882660),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Star Academy",'Lillington=' + Lillington.length); Erwin[Erwin.length] = createMarker(new GPoint(-78.67081451,35.33535385),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Triton High School",'Erwin=' + Erwin.length); Dunn[Dunn.length] = createMarker(new GPoint(-78.61627960,35.31433868),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Wayne Avenue Elementary School",'Dunn=' + Dunn.length); Lillington[Lillington.length] = createMarker(new GPoint(-78.81622314,35.39875031),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Western Harnett High School",'Lillington=' + Lillington.length); Lillington[Lillington.length] = createMarker(new GPoint(-78.81622314,35.39875031),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Western Harnett Middle School",'Lillington=' + Lillington.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(Buies_Creek); map.removeOverlays(Bunnlevel); map.removeOverlays(Cameron); map.removeOverlays(Coats); map.removeOverlays(Dunn); map.removeOverlays(Erwin); map.removeOverlays(Kipling); map.removeOverlays(Lillington); map.removeOverlays(Mamers); map.removeOverlays(Olivia); map.removeOverlays(Sanford); map.removeOverlays(Spring_Lake); 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(Bunnlevel);map.removeOverlays(Angier); map.removeOverlays(Buies_Creek); map.removeOverlays(Bunnlevel); map.removeOverlays(Cameron); map.removeOverlays(Coats); map.removeOverlays(Dunn); map.removeOverlays(Erwin); map.removeOverlays(Kipling); map.removeOverlays(Lillington); map.removeOverlays(Mamers); map.removeOverlays(Olivia); map.removeOverlays(Sanford); map.removeOverlays(Spring_Lake); map.addOverlays(Angier); centerByArray(Angier, false, false); cntMarker += Angier.length; map.addOverlays(Buies_Creek); centerByArray(Buies_Creek, false, false); cntMarker += Buies_Creek.length; map.addOverlays(Bunnlevel); centerByArray(Bunnlevel, false, false); cntMarker += Bunnlevel.length; map.addOverlays(Cameron); centerByArray(Cameron, false, false); cntMarker += Cameron.length; map.addOverlays(Coats); centerByArray(Coats, false, false); cntMarker += Coats.length; map.addOverlays(Dunn); centerByArray(Dunn, false, false); cntMarker += Dunn.length; map.addOverlays(Erwin); centerByArray(Erwin, false, false); cntMarker += Erwin.length; map.addOverlays(Kipling); centerByArray(Kipling, false, false); cntMarker += Kipling.length; map.addOverlays(Lillington); centerByArray(Lillington, false, false); cntMarker += Lillington.length; map.addOverlays(Mamers); centerByArray(Mamers, false, false); cntMarker += Mamers.length; map.addOverlays(Olivia); centerByArray(Olivia, false, false); cntMarker += Olivia.length; map.addOverlays(Sanford); centerByArray(Sanford, false, false); cntMarker += Sanford.length; map.addOverlays(Spring_Lake); centerByArray(Spring_Lake, false, false); cntMarker += Spring_Lake.length; centerByArray(Bunnlevel,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'); } }