function addMarkers() { mySelect = document.getElementById('selection'); Taylorsville = [];Hiddenite = [];Stony_Point = [];mySelect.options[mySelect.options.length] = new Option("Hiddenite schools",'all=Hiddenite'); mySelect.options[mySelect.options.length] = new Option("Stony Point schools",'all=Stony_Point'); mySelect.options[mySelect.options.length] = new Option("Taylorsville schools",'all=Taylorsville'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Taylorsville[Taylorsville.length] = createMarker(new GPoint(-80.91118622,35.77795029),"
Alexander Central High School
223 School Drive
Taylorsville, NC 28681

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Alexander Central High School",'Taylorsville=' + Taylorsville.length); Taylorsville[Taylorsville.length] = createMarker(new GPoint(-81.21499634,35.90200043),"
Bethlehem Elementary School
7900 Nc Hwy 127
Taylorsville, NC 28681

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Bethlehem Elementary School",'Taylorsville=' + Taylorsville.length); Hiddenite[Hiddenite.length] = createMarker(new GPoint(-81.11968231,35.92639160),"
East Alexander Middle School
1285 White Plains Road
Hiddenite, NC 28636

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("East Alexander Middle School",'Hiddenite=' + Hiddenite.length); Taylorsville[Taylorsville.length] = createMarker(new GPoint(-81.27796173,35.92566681),"
Ellendale Elementary School
175 Ellendale Park Lane
Taylorsville, NC 28681

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Ellendale Elementary School",'Taylorsville=' + Taylorsville.length); Hiddenite[Hiddenite.length] = createMarker(new GPoint(-81.09050751,35.90372849),"
Hiddenite Elementary School
374 Sulphur Springs Road
Hiddenite, NC 28636

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Hiddenite Elementary School",'Hiddenite=' + Hiddenite.length); Stony_Point[Stony_Point.length] = createMarker(new GPoint(-81.05310059,35.84550095),"
Stony Point Elementary School
Po Box 306
Stony Point, NC 28678

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Stony Point Elementary School",'Stony_Point=' + Stony_Point.length); Taylorsville[Taylorsville.length] = createMarker(new GPoint(-81.21499634,35.90200043),"
Sugar Loaf Elementary School
3600 Nc Hwy 16n
Taylorsville, NC 28681

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Sugar Loaf Elementary School",'Taylorsville=' + Taylorsville.length); Taylorsville[Taylorsville.length] = createMarker(new GPoint(-81.18345642,35.91757202),"
Taylorsville Elementary School
100 7th Street Sw
Taylorsville, NC 28681

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Taylorsville Elementary School",'Taylorsville=' + Taylorsville.length); Taylorsville[Taylorsville.length] = createMarker(new GPoint(-81.21499634,35.90200043),"
West Alexander Middle School
85 Bulldog Lane
Taylorsville, NC 28681

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("West Alexander Middle School",'Taylorsville=' + Taylorsville.length); Taylorsville[Taylorsville.length] = createMarker(new GPoint(-81.23241425,35.83180618),"
Wittenburg Elementary School
7300 Church Road
Taylorsville, NC 28681

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Wittenburg Elementary School",'Taylorsville=' + Taylorsville.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(Hiddenite); map.removeOverlays(Stony_Point); map.removeOverlays(Taylorsville); 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(Taylorsville);map.removeOverlays(Hiddenite); map.removeOverlays(Stony_Point); map.removeOverlays(Taylorsville); map.addOverlays(Hiddenite); centerByArray(Hiddenite, false, false); cntMarker += Hiddenite.length; map.addOverlays(Stony_Point); centerByArray(Stony_Point, false, false); cntMarker += Stony_Point.length; map.addOverlays(Taylorsville); centerByArray(Taylorsville, false, false); cntMarker += Taylorsville.length; centerByArray(Taylorsville,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'); } }