function addMarkers() { mySelect = document.getElementById('selection'); Ruffin = [];Walterboro = [];Cottageville = [];Edisto_Beach = [];Smoaks = [];mySelect.options[mySelect.options.length] = new Option("Cottageville schools",'all=Cottageville'); mySelect.options[mySelect.options.length] = new Option("Edisto Beach schools",'all=Edisto_Beach'); mySelect.options[mySelect.options.length] = new Option("Ruffin schools",'all=Ruffin'); mySelect.options[mySelect.options.length] = new Option("Smoaks schools",'all=Smoaks'); mySelect.options[mySelect.options.length] = new Option("Walterboro schools",'all=Walterboro'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Ruffin[Ruffin.length] = createMarker(new GPoint(-80.85186005,32.97985840),"
Bells Elementary School
12088 Bells Hwy.
Ruffin, SC 29475

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Bells Elementary School",'Ruffin=' + Ruffin.length); Walterboro[Walterboro.length] = createMarker(new GPoint(-80.65031433,32.89381790),"
Black Street Elementary School
120 Smith Street
Walterboro, SC 29488

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Black Street Elementary School",'Walterboro=' + Walterboro.length); Walterboro[Walterboro.length] = createMarker(new GPoint(-80.65819550,32.93429565),"
Colleton County High School
1379 Bulldog Avenue
Walterboro, SC 29488

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Colleton County High School",'Walterboro=' + Walterboro.length); Walterboro[Walterboro.length] = createMarker(new GPoint(-80.64900208,32.91306305),"
Colleton Middle School
603 Colleton Loop
Walterboro, SC 29488

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Colleton Middle School",'Walterboro=' + Walterboro.length); Cottageville[Cottageville.length] = createMarker(new GPoint(-80.48208618,32.93416214),"
Cottageville Elementary School
72 Sally Ackerman Drive
Cottageville, SC 29435

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Cottageville Elementary School",'Cottageville=' + Cottageville.length); Edisto_Beach[Edisto_Beach.length] = createMarker(new GPoint(-80.33541870,32.48162079),"
Edisto Beach Elementary School
3002 Lee Street
Edisto Beach, SC 29438

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Edisto Beach Elementary School",'Edisto_Beach=' + Edisto_Beach.length); Walterboro[Walterboro.length] = createMarker(new GPoint(-80.67935181,32.91623306),"
Forest Circle Middle School
500 Forest Circle
Walterboro, SC 29488

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Forest Circle Middle School",'Walterboro=' + Walterboro.length); Walterboro[Walterboro.length] = createMarker(new GPoint(-80.67964172,32.91397858),"
Forest Hills Elementary School
633 Hiers Corner Road
Walterboro, SC 29488

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Forest Hills Elementary School",'Walterboro=' + Walterboro.length); Walterboro[Walterboro.length] = createMarker(new GPoint(-80.71430969,32.80519485),"
Hendersonville Elementary School
6089 Hendersonville Hwy
Walterboro, SC 29488

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Hendersonville Elementary School",'Walterboro=' + Walterboro.length); Walterboro[Walterboro.length] = createMarker(new GPoint(-80.61638641,32.94713974),"
Northside Elementary School
1929 Industrial Road
Walterboro, SC 29488

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Northside Elementary School",'Walterboro=' + Walterboro.length); Ruffin[Ruffin.length] = createMarker(new GPoint(-80.80693817,33.01125336),"
Ruffin High School
155 Patriots Lane
Ruffin, SC 29475

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Ruffin High School",'Ruffin=' + Ruffin.length); Smoaks[Smoaks.length] = createMarker(new GPoint(-80.79851532,33.09146118),"
Ruffin Middle School
906 Sunrise Road
Smoaks, SC 29481

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Ruffin Middle School",'Smoaks=' + Smoaks.length); Walterboro[Walterboro.length] = createMarker(new GPoint(-80.63030900,32.93629300),"
Thunderbolt Career And Technolgy
1069 Thunderbolt Rd.
Walterboro, SC 29488

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Thunderbolt Career And Technolgy",'Walterboro=' + Walterboro.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(Cottageville); map.removeOverlays(Edisto_Beach); map.removeOverlays(Ruffin); map.removeOverlays(Smoaks); map.removeOverlays(Walterboro); 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(Ruffin);map.removeOverlays(Cottageville); map.removeOverlays(Edisto_Beach); map.removeOverlays(Ruffin); map.removeOverlays(Smoaks); map.removeOverlays(Walterboro); map.addOverlays(Cottageville); centerByArray(Cottageville, false, false); cntMarker += Cottageville.length; map.addOverlays(Edisto_Beach); centerByArray(Edisto_Beach, false, false); cntMarker += Edisto_Beach.length; map.addOverlays(Ruffin); centerByArray(Ruffin, false, false); cntMarker += Ruffin.length; map.addOverlays(Smoaks); centerByArray(Smoaks, false, false); cntMarker += Smoaks.length; map.addOverlays(Walterboro); centerByArray(Walterboro, false, false); cntMarker += Walterboro.length; centerByArray(Ruffin,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'); } }