function addMarkers() { mySelect = document.getElementById('selection'); Morganton = [];Drexel = [];Connelly_Springs = [];Icard = [];Valdese = [];Hildebran = [];Hickory = [];Rutherford_College = [];mySelect.options[mySelect.options.length] = new Option("Connelly Springs schools",'all=Connelly_Springs'); mySelect.options[mySelect.options.length] = new Option("Drexel schools",'all=Drexel'); mySelect.options[mySelect.options.length] = new Option("Hickory schools",'all=Hickory'); mySelect.options[mySelect.options.length] = new Option("Hildebran schools",'all=Hildebran'); mySelect.options[mySelect.options.length] = new Option("Icard schools",'all=Icard'); mySelect.options[mySelect.options.length] = new Option("Morganton schools",'all=Morganton'); mySelect.options[mySelect.options.length] = new Option("Rutherford College schools",'all=Rutherford_College'); mySelect.options[mySelect.options.length] = new Option("Valdese schools",'all=Valdese'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Morganton[Morganton.length] = createMarker(new GPoint(-81.68476105,35.73997498),"
Burke Alternate
510 College Street
Morganton, NC 28655

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Burke Alternate",'Morganton=' + Morganton.length); Morganton[Morganton.length] = createMarker(new GPoint(-81.67170715,35.81684875),"
Chesterfield Elementary School
2142 Pax Hill Road
Morganton, NC 28655

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Chesterfield Elementary School",'Morganton=' + Morganton.length); Drexel[Drexel.length] = createMarker(new GPoint(-81.60440063,35.75770187),"
Drexel Primary
101 Alta Vista Street
Drexel, NC 28619

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Drexel Primary",'Drexel=' + Drexel.length); Drexel[Drexel.length] = createMarker(new GPoint(-81.60440063,35.75770187),"
Drexel/hallyburton Elementary School
Po Box 3238
Drexel, NC 28619

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Drexel/hallyburton Elementary School",'Drexel=' + Drexel.length); Connelly_Springs[Connelly_Springs.length] = createMarker(new GPoint(-81.48082733,35.71903992),"
East Burke High School
3695 East Burke Boulevard
Connelly Springs, NC 28612

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("East Burke High School",'Connelly_Springs=' + Connelly_Springs.length); Icard[Icard.length] = createMarker(new GPoint(-81.47080231,35.72719955),"
East Burke Middle School
Po Box 1150
Icard, NC 28666

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("East Burke Middle School",'Icard=' + Icard.length); Morganton[Morganton.length] = createMarker(new GPoint(-81.70081329,35.73174286),"
Forest Hill Elementary School
304 Ann Street
Morganton, NC 28655

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Forest Hill Elementary School",'Morganton=' + Morganton.length); Morganton[Morganton.length] = createMarker(new GPoint(-81.72278595,35.74296188),"
Freedom High School
511 Independence Boulevard
Morganton, NC 28655

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Freedom High School",'Morganton=' + Morganton.length); Connelly_Springs[Connelly_Springs.length] = createMarker(new GPoint(-81.50550079,35.70399857),"
George Hildebrand Elementary School
8078 G Hildebrand Sch Road
Connelly Springs, NC 28612

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("George Hildebrand Elementary School",'Connelly_Springs=' + Connelly_Springs.length); Morganton[Morganton.length] = createMarker(new GPoint(-81.77867126,35.72639847),"
Glen Alpine Elementary School
302 London Street
Morganton, NC 28655

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Glen Alpine Elementary School",'Morganton=' + Morganton.length); Valdese[Valdese.length] = createMarker(new GPoint(-81.58266449,35.75891113),"
Heritage Middle School
1951 Enon Road
Valdese, NC 28690

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Heritage Middle School",'Valdese=' + Valdese.length); Hildebran[Hildebran.length] = createMarker(new GPoint(-81.42209625,35.71620178),"
Hildebran Elementary School
Po Box 451
Hildebran, NC 28637

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Hildebran Elementary School",'Hildebran=' + Hildebran.length); Morganton[Morganton.length] = createMarker(new GPoint(-81.67508698,35.75432205),"
Hillcrest Elementary School
201 Tennessee Street
Morganton, NC 28655

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Hillcrest Elementary School",'Morganton=' + Morganton.length); Icard[Icard.length] = createMarker(new GPoint(-81.47080231,35.72719955),"
Icard Elementary School
Po Box 70
Icard, NC 28666

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Icard Elementary School",'Icard=' + Icard.length); Morganton[Morganton.length] = createMarker(new GPoint(-81.67188263,35.70939255),"
Liberty Middle School
529 Enola Road
Morganton, NC 28655

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Liberty Middle School",'Morganton=' + Morganton.length); Morganton[Morganton.length] = createMarker(new GPoint(-81.70059204,35.75336838),"
Mountain View Elementary School
106 Alphabet Lane
Morganton, NC 28655

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Mountain View Elementary School",'Morganton=' + Morganton.length); Morganton[Morganton.length] = createMarker(new GPoint(-81.71489716,35.73460007),"
Mull Elementary School
1140 Old Nc 18 South
Morganton, NC 28655

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Mull Elementary School",'Morganton=' + Morganton.length); Morganton[Morganton.length] = createMarker(new GPoint(-81.68499756,35.74520111),"
New Dimensions School
Po Box 2248
Morganton, NC 28680

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("New Dimensions School",'Morganton=' + Morganton.length); Morganton[Morganton.length] = createMarker(new GPoint(-81.67192078,35.70962906),"
North Liberty
523 Enola Road
Morganton, NC 28655

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("North Liberty",'Morganton=' + Morganton.length); Morganton[Morganton.length] = createMarker(new GPoint(-81.68499756,35.74520111),"
Oak Hill Elementary School
Po Box 1389
Morganton, NC 28680

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Oak Hill Elementary School",'Morganton=' + Morganton.length); Hickory[Hickory.length] = createMarker(new GPoint(-81.42726135,35.75159836),"
Ray Childers Elementary School
1183 Cape Hickory Road
Hickory, NC 28601

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Ray Childers Elementary School",'Hickory=' + Hickory.length); Rutherford_College[Rutherford_College.length] = createMarker(new GPoint(-81.52749634,35.75469971),"
Rutherford College Elementary School
Po Box 247
Rutherford College, NC 28671

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Rutherford College Elementary School",'Rutherford_College=' + Rutherford_College.length); Morganton[Morganton.length] = createMarker(new GPoint(-81.70083618,35.69615173),"
Salem Elementary School
1329 Salem Road
Morganton, NC 28655

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Salem Elementary School",'Morganton=' + Morganton.length); Morganton[Morganton.length] = createMarker(new GPoint(-81.71489716,35.73460007),"
Table Rock Middle School
1581 Nc 126
Morganton, NC 28655

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Table Rock Middle School",'Morganton=' + Morganton.length); Valdese[Valdese.length] = createMarker(new GPoint(-81.56507111,35.74544144),"
Valdese Elementary School
298 Praley Street
Valdese, NC 28690

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Valdese Elementary School",'Valdese=' + Valdese.length); Morganton[Morganton.length] = createMarker(new GPoint(-81.76857758,35.71834946),"
W A Young Elementary School
325 Conley Road
Morganton, NC 28655

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("W A Young Elementary School",'Morganton=' + Morganton.length); Morganton[Morganton.length] = createMarker(new GPoint(-81.71499634,35.73440170),"
Walter R Johnson Middle School
701 Lenoir Road
Morganton, NC 28655

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Walter R Johnson Middle School",'Morganton=' + Morganton.length); Morganton[Morganton.length] = createMarker(new GPoint(-81.68771362,35.73321915),"
Wtn Nc School For Deaf
517 West Fleming Drive
Morganton, NC 28655

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Wtn Nc School For Deaf",'Morganton=' + Morganton.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(Connelly_Springs); map.removeOverlays(Drexel); map.removeOverlays(Hickory); map.removeOverlays(Hildebran); map.removeOverlays(Icard); map.removeOverlays(Morganton); map.removeOverlays(Rutherford_College); map.removeOverlays(Valdese); 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(Morganton);map.removeOverlays(Connelly_Springs); map.removeOverlays(Drexel); map.removeOverlays(Hickory); map.removeOverlays(Hildebran); map.removeOverlays(Icard); map.removeOverlays(Morganton); map.removeOverlays(Rutherford_College); map.removeOverlays(Valdese); map.addOverlays(Connelly_Springs); centerByArray(Connelly_Springs, false, false); cntMarker += Connelly_Springs.length; map.addOverlays(Drexel); centerByArray(Drexel, false, false); cntMarker += Drexel.length; map.addOverlays(Hickory); centerByArray(Hickory, false, false); cntMarker += Hickory.length; map.addOverlays(Hildebran); centerByArray(Hildebran, false, false); cntMarker += Hildebran.length; map.addOverlays(Icard); centerByArray(Icard, false, false); cntMarker += Icard.length; map.addOverlays(Morganton); centerByArray(Morganton, false, false); cntMarker += Morganton.length; map.addOverlays(Rutherford_College); centerByArray(Rutherford_College, false, false); cntMarker += Rutherford_College.length; map.addOverlays(Valdese); centerByArray(Valdese, false, false); cntMarker += Valdese.length; centerByArray(Morganton,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'); } }