function addMarkers() { mySelect = document.getElementById('selection'); Axton = [];Bassett = [];Collinsville = [];Martinsville = [];Ridgeway = [];Fieldale = [];Spencer = [];Stanleytown = [];mySelect.options[mySelect.options.length] = new Option("Axton schools",'all=Axton'); mySelect.options[mySelect.options.length] = new Option("Bassett schools",'all=Bassett'); mySelect.options[mySelect.options.length] = new Option("Collinsville schools",'all=Collinsville'); mySelect.options[mySelect.options.length] = new Option("Fieldale schools",'all=Fieldale'); mySelect.options[mySelect.options.length] = new Option("Martinsville schools",'all=Martinsville'); mySelect.options[mySelect.options.length] = new Option("Ridgeway schools",'all=Ridgeway'); mySelect.options[mySelect.options.length] = new Option("Spencer schools",'all=Spencer'); mySelect.options[mySelect.options.length] = new Option("Stanleytown schools",'all=Stanleytown'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Axton[Axton.length] = createMarker(new GPoint(-79.71369171,36.66131973),"
Axton Middle School
1500 Axton School Road
Axton, VA 24054

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Axton Middle School",'Axton=' + Axton.length); Bassett[Bassett.length] = createMarker(new GPoint(-79.96107483,36.73575592),"
Bassett High School
85 Riverside Dr
Bassett, VA 24055

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Bassett High School",'Bassett=' + Bassett.length); Bassett[Bassett.length] = createMarker(new GPoint(-79.99588013,36.76188660),"
Bassett Middle School
3289 Riverside Dr
Bassett, VA 24055

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Bassett Middle School",'Bassett=' + Bassett.length); Collinsville[Collinsville.length] = createMarker(new GPoint(-10.00000000,10.00000000),"
Breaking Barriers Alternative Ed/henry Co
Co Henry Co Public Schls
Collinsville, VA 24078

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Breaking Barriers Alternative Ed/henry Co",'Collinsville=' + Collinsville.length); Bassett[Bassett.length] = createMarker(new GPoint(-79.98213196,36.75643921),"
Campbell Court Elementary School
220 Campbell Ct
Bassett, VA 24055

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Campbell Court Elementary School",'Bassett=' + Bassett.length); Martinsville[Martinsville.length] = createMarker(new GPoint(-79.93990326,36.67226410),"
Carver Middle School
220 Trott Circle
Martinsville, VA 24112

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Carver Middle School",'Martinsville=' + Martinsville.length); Martinsville[Martinsville.length] = createMarker(new GPoint(-79.86786652,36.68605042),"
Center For Community Learning
202 Cleveland Ave
Martinsville, VA 24112

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Center For Community Learning",'Martinsville=' + Martinsville.length); Collinsville[Collinsville.length] = createMarker(new GPoint(-79.90938568,36.71886444),"
Collinsville Primary
15 Primary School Rd
Collinsville, VA 24078

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Collinsville Primary",'Collinsville=' + Collinsville.length); Ridgeway[Ridgeway.length] = createMarker(new GPoint(-79.86105347,36.60680008),"
Drewry Mason Middle School
45 Drewry Mason Dr
Ridgeway, VA 24148

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Drewry Mason Middle School",'Ridgeway=' + Ridgeway.length); Collinsville[Collinsville.length] = createMarker(new GPoint(-79.92308044,36.71173859),"
Fieldale Collinsville High School
645 Miles Road
Collinsville, VA 24078

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Fieldale Collinsville High School",'Collinsville=' + Collinsville.length); Fieldale[Fieldale.length] = createMarker(new GPoint(-79.95770264,36.70959854),"
Fieldale Elementary School
Po Box 68
Fieldale, VA 24089

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Fieldale Elementary School",'Fieldale=' + Fieldale.length); Martinsville[Martinsville.length] = createMarker(new GPoint(-79.87342072,36.76510239),"
Figsboro Elementary School
340 Ridgedale Dr
Martinsville, VA 24112

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Figsboro Elementary School",'Martinsville=' + Martinsville.length); Collinsville[Collinsville.length] = createMarker(new GPoint(-79.91882324,36.70355988),"
Henry Co/martinsville Reg Pgm
Po Box 8958
Collinsville, VA 24078

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Henry Co/martinsville Reg Pgm",'Collinsville=' + Collinsville.length); Axton[Axton.length] = createMarker(new GPoint(-79.73352814,36.61692810),"
Irisburg Elementary School
6871 Irisburg Rd
Axton, VA 24054

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Irisburg Elementary School",'Axton=' + Axton.length); Collinsville[Collinsville.length] = createMarker(new GPoint(-79.91136932,36.71822739),"
John Redd Smith Elementary School
40 School Dr
Collinsville, VA 24078

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("John Redd Smith Elementary School",'Collinsville=' + Collinsville.length); Martinsville[Martinsville.length] = createMarker(new GPoint(-79.78330231,36.68562698),"
Laurel Park High School
280 Laurel Park Avenue
Martinsville, VA 24112

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Laurel Park High School",'Martinsville=' + Martinsville.length); Ridgeway[Ridgeway.length] = createMarker(new GPoint(-79.89009857,36.60161591),"
Magna Vista High School
701 Magna Vista School Rd
Ridgeway, VA 24148

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Magna Vista High School",'Ridgeway=' + Ridgeway.length); Martinsville[Martinsville.length] = createMarker(new GPoint(-79.81132507,36.68602753),"
Mt. Olivet Elementary School
255 Lancer Lane
Martinsville, VA 24112

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Mt. Olivet Elementary School",'Martinsville=' + Martinsville.length); Collinsville[Collinsville.length] = createMarker(new GPoint(-79.91410065,36.72700119),"
Piedmont Gov Sch For Math/sci/tech
P.o. Box 728
Collinsville, VA 24078

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Piedmont Gov Sch For Math/sci/tech",'Collinsville=' + Collinsville.length); Martinsville[Martinsville.length] = createMarker(new GPoint(-79.87567902,36.63703918),"
Rich Acres Elementary School
400 Rich Acres School Rd
Martinsville, VA 24112

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Rich Acres Elementary School",'Martinsville=' + Martinsville.length); Ridgeway[Ridgeway.length] = createMarker(new GPoint(-79.86528015,36.57522202),"
Ridgeway Elementary School
380 Church St
Ridgeway, VA 24148

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Ridgeway Elementary School",'Ridgeway=' + Ridgeway.length); Bassett[Bassett.length] = createMarker(new GPoint(-80.05255890,36.71405029),"
Sanville Elementary School
19 Sanville School Rd
Bassett, VA 24055

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Sanville Elementary School",'Bassett=' + Bassett.length); Spencer[Spencer.length] = createMarker(new GPoint(-80.01325989,36.61506653),"
Spencer Penn Elementary School
30 George Taylor Rd
Spencer, VA 24165

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Spencer Penn Elementary School",'Spencer=' + Spencer.length); Stanleytown[Stanleytown.length] = createMarker(new GPoint(-79.94203186,36.73616409),"
Stanleytown Elementary School
74 Edgewood Dr
Stanleytown, VA 24168

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Stanleytown Elementary School",'Stanleytown=' + Stanleytown.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(Axton); map.removeOverlays(Bassett); map.removeOverlays(Collinsville); map.removeOverlays(Fieldale); map.removeOverlays(Martinsville); map.removeOverlays(Ridgeway); map.removeOverlays(Spencer); map.removeOverlays(Stanleytown); 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(Axton);map.removeOverlays(Axton); map.removeOverlays(Bassett); map.removeOverlays(Collinsville); map.removeOverlays(Fieldale); map.removeOverlays(Martinsville); map.removeOverlays(Ridgeway); map.removeOverlays(Spencer); map.removeOverlays(Stanleytown); map.addOverlays(Axton); centerByArray(Axton, false, false); cntMarker += Axton.length; map.addOverlays(Bassett); centerByArray(Bassett, false, false); cntMarker += Bassett.length; map.addOverlays(Collinsville); centerByArray(Collinsville, false, false); cntMarker += Collinsville.length; map.addOverlays(Fieldale); centerByArray(Fieldale, false, false); cntMarker += Fieldale.length; map.addOverlays(Martinsville); centerByArray(Martinsville, false, false); cntMarker += Martinsville.length; map.addOverlays(Ridgeway); centerByArray(Ridgeway, false, false); cntMarker += Ridgeway.length; map.addOverlays(Spencer); centerByArray(Spencer, false, false); cntMarker += Spencer.length; map.addOverlays(Stanleytown); centerByArray(Stanleytown, false, false); cntMarker += Stanleytown.length; centerByArray(Axton,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'); } }