function addMarkers() { mySelect = document.getElementById('selection'); Aberdeen = [];Pinehurst = [];Southern_Pines = [];Carthage = [];Robbins = [];Highfalls = [];Cameron = [];Vass = [];West_End = [];mySelect.options[mySelect.options.length] = new Option("Aberdeen schools",'all=Aberdeen'); mySelect.options[mySelect.options.length] = new Option("Cameron schools",'all=Cameron'); mySelect.options[mySelect.options.length] = new Option("Carthage schools",'all=Carthage'); mySelect.options[mySelect.options.length] = new Option("Highfalls schools",'all=Highfalls'); mySelect.options[mySelect.options.length] = new Option("Pinehurst schools",'all=Pinehurst'); mySelect.options[mySelect.options.length] = new Option("Robbins schools",'all=Robbins'); mySelect.options[mySelect.options.length] = new Option("Southern Pines schools",'all=Southern_Pines'); mySelect.options[mySelect.options.length] = new Option("Vass schools",'all=Vass'); mySelect.options[mySelect.options.length] = new Option("West End schools",'all=West_End'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Aberdeen[Aberdeen.length] = createMarker(new GPoint(-79.42596436,35.13840866),"
Aberdeen Elementary School
503 Sandhills Blvd N
Aberdeen, NC 28315

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Aberdeen Elementary School",'Aberdeen=' + Aberdeen.length); Aberdeen[Aberdeen.length] = createMarker(new GPoint(-79.42306519,35.12582016),"
Aberdeen Primary
310 Keyser St
Aberdeen, NC 28315

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Aberdeen Primary",'Aberdeen=' + Aberdeen.length); Pinehurst[Pinehurst.length] = createMarker(new GPoint(-79.47139740,35.18970108),"
Academy Heights Elementary School
Po Box 579
Pinehurst, NC 28370

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Academy Heights Elementary School",'Pinehurst=' + Pinehurst.length); Southern_Pines[Southern_Pines.length] = createMarker(new GPoint(-79.40232849,35.19653320),"
Academy Of Moore County
105 Turner Street
Southern Pines, NC 28387

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Academy Of Moore County",'Southern_Pines=' + Southern_Pines.length); Carthage[Carthage.length] = createMarker(new GPoint(-79.39790344,35.31729889),"
Carthage Elementary School
Po Box 190
Carthage, NC 28327

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Carthage Elementary School",'Carthage=' + Carthage.length); Robbins[Robbins.length] = createMarker(new GPoint(-79.58059692,35.45629883),"
Elise Middle School
Po Box 850
Robbins, NC 27325

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Elise Middle School",'Robbins=' + Robbins.length); Highfalls[Highfalls.length] = createMarker(new GPoint(-79.54149900,35.50199000),"
Highfalls Elementary School
Po Box 206
Highfalls, NC 27259

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Highfalls Elementary School",'Highfalls=' + Highfalls.length); Cameron[Cameron.length] = createMarker(new GPoint(-79.35673523,35.32576752),"
New Century Middle School
1577 Union Church Road
Cameron, NC 28326

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("New Century Middle School",'Cameron=' + Cameron.length); Robbins[Robbins.length] = createMarker(new GPoint(-79.58059692,35.45629883),"
North Moore High School
Po Box 9
Robbins, NC 27325

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("North Moore High School",'Robbins=' + Robbins.length); Carthage[Carthage.length] = createMarker(new GPoint(-79.39790344,35.31729889),"
Pinckney Academy
Po Box 1423
Carthage, NC 28327

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Pinckney Academy",'Carthage=' + Carthage.length); Southern_Pines[Southern_Pines.length] = createMarker(new GPoint(-79.43054962,35.18784714),"
Pinecrest High School
100 Voit Gilmore Lane
Southern Pines, NC 28387

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Pinecrest High School",'Southern_Pines=' + Southern_Pines.length); Pinehurst[Pinehurst.length] = createMarker(new GPoint(-79.47139740,35.18970108),"
Pinehurst Elementary School
Po Box 729
Pinehurst, NC 28370

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Pinehurst Elementary School",'Pinehurst=' + Pinehurst.length); Robbins[Robbins.length] = createMarker(new GPoint(-79.58059692,35.45629883),"
Robbins Elementary School
Po Box 189
Robbins, NC 27325

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Robbins Elementary School",'Robbins=' + Robbins.length); Vass[Vass.length] = createMarker(new GPoint(-79.24220276,35.21860123),"
Sandhills Theatre Arts Renaiss Elementary School
140 Southern Dunes Drive
Vass, NC 28394

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Sandhills Theatre Arts Renaiss Elementary School",'Vass=' + Vass.length); Carthage[Carthage.length] = createMarker(new GPoint(-79.39205170,35.27595139),"
Sandhills-farm Life Elementary School
2201 Farm Life Rd
Carthage, NC 28327

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Sandhills-farm Life Elementary School",'Carthage=' + Carthage.length); Aberdeen[Aberdeen.length] = createMarker(new GPoint(-79.42334747,35.15486145),"
Southern Middle School
717 Johnson Street
Aberdeen, NC 28315

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Southern Middle School",'Aberdeen=' + Aberdeen.length); Southern_Pines[Southern_Pines.length] = createMarker(new GPoint(-79.39182281,35.17029190),"
Southern Pines Elementary School
255 S May St
Southern Pines, NC 28387

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Southern Pines Elementary School",'Southern_Pines=' + Southern_Pines.length); Southern_Pines[Southern_Pines.length] = createMarker(new GPoint(-79.40453339,35.18521881),"
Southern Pines Primary
1250 W New York Ave
Southern Pines, NC 28387

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Southern Pines Primary",'Southern_Pines=' + Southern_Pines.length); Cameron[Cameron.length] = createMarker(new GPoint(-79.34819794,35.31675720),"
Union Pines High School
1981 Union Church Rd
Cameron, NC 28326

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Union Pines High School",'Cameron=' + Cameron.length); Vass[Vass.length] = createMarker(new GPoint(-79.28838348,35.24927521),"
Vass-lakeview Elementary School
141 James Street
Vass, NC 28394

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Vass-lakeview Elementary School",'Vass=' + Vass.length); West_End[West_End.length] = createMarker(new GPoint(-79.55059814,35.25109863),"
West End Elementary School
Po Box 290
West End, NC 27376

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("West End Elementary School",'West_End=' + West_End.length); West_End[West_End.length] = createMarker(new GPoint(-79.53182983,35.22430420),"
West Pine Middle School
144 Archie Road
West End, NC 27376

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("West Pine Middle School",'West_End=' + West_End.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(Aberdeen); map.removeOverlays(Cameron); map.removeOverlays(Carthage); map.removeOverlays(Highfalls); map.removeOverlays(Pinehurst); map.removeOverlays(Robbins); map.removeOverlays(Southern_Pines); map.removeOverlays(Vass); map.removeOverlays(West_End); 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(Aberdeen);map.removeOverlays(Aberdeen); map.removeOverlays(Cameron); map.removeOverlays(Carthage); map.removeOverlays(Highfalls); map.removeOverlays(Pinehurst); map.removeOverlays(Robbins); map.removeOverlays(Southern_Pines); map.removeOverlays(Vass); map.removeOverlays(West_End); map.addOverlays(Aberdeen); centerByArray(Aberdeen, false, false); cntMarker += Aberdeen.length; map.addOverlays(Cameron); centerByArray(Cameron, false, false); cntMarker += Cameron.length; map.addOverlays(Carthage); centerByArray(Carthage, false, false); cntMarker += Carthage.length; map.addOverlays(Highfalls); centerByArray(Highfalls, false, false); cntMarker += Highfalls.length; map.addOverlays(Pinehurst); centerByArray(Pinehurst, false, false); cntMarker += Pinehurst.length; map.addOverlays(Robbins); centerByArray(Robbins, false, false); cntMarker += Robbins.length; map.addOverlays(Southern_Pines); centerByArray(Southern_Pines, false, false); cntMarker += Southern_Pines.length; map.addOverlays(Vass); centerByArray(Vass, false, false); cntMarker += Vass.length; map.addOverlays(West_End); centerByArray(West_End, false, false); cntMarker += West_End.length; centerByArray(Aberdeen,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'); } }