function addMarkers() { mySelect = document.getElementById('selection'); Conway = [];Garysburg = [];Gaston = [];Jackson = [];Rich_Square = [];Seaboard = [];Pendleton = [];mySelect.options[mySelect.options.length] = new Option("Conway schools",'all=Conway'); mySelect.options[mySelect.options.length] = new Option("Garysburg schools",'all=Garysburg'); mySelect.options[mySelect.options.length] = new Option("Gaston schools",'all=Gaston'); mySelect.options[mySelect.options.length] = new Option("Jackson schools",'all=Jackson'); mySelect.options[mySelect.options.length] = new Option("Pendleton schools",'all=Pendleton'); mySelect.options[mySelect.options.length] = new Option("Rich Square schools",'all=Rich_Square'); mySelect.options[mySelect.options.length] = new Option("Seaboard schools",'all=Seaboard'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Conway[Conway.length] = createMarker(new GPoint(-77.22383118,36.43693542),"
Conway Middle School
400 East Main Street
Conway, NC 27820

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Conway Middle School",'Conway=' + Conway.length); Garysburg[Garysburg.length] = createMarker(new GPoint(-77.56099701,36.46509933),"
Garysburg Elementary School
Po Drawer J
Garysburg, NC 27831

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Garysburg Elementary School",'Garysburg=' + Garysburg.length); Gaston[Gaston.length] = createMarker(new GPoint(-77.69190216,36.51290131),"
Gaston College Preparatory
320 Pleasant Hill Road
Gaston, NC 27832

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Gaston College Preparatory",'Gaston=' + Gaston.length); Gaston[Gaston.length] = createMarker(new GPoint(-77.68049622,36.50699997),"
Gaston Middle School
Po Drawer J
Gaston, NC 27832

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Gaston Middle School",'Gaston=' + Gaston.length); Jackson[Jackson.length] = createMarker(new GPoint(-77.42147064,36.38901901),"
Jackson-eastside Elementary School
8380 Hwy 305 S
Jackson, NC 27845

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Jackson-eastside Elementary School",'Jackson=' + Jackson.length); Conway[Conway.length] = createMarker(new GPoint(-77.27279663,36.42599869),"
Northampton High-east High School
750 Nchs-e Road
Conway, NC 27820

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Northampton High-east High School",'Conway=' + Conway.length); Gaston[Gaston.length] = createMarker(new GPoint(-77.65630341,36.50400162),"
Northampton High-west High School
152 Hurricane Drive
Gaston, NC 27832

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Northampton High-west High School",'Gaston=' + Gaston.length); Rich_Square[Rich_Square.length] = createMarker(new GPoint(-77.28928375,36.26666260),"
Rich Square-creecy Elementary School
210 Roberts Road
Rich Square, NC 27869

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Rich Square-creecy Elementary School",'Rich_Square=' + Rich_Square.length); Seaboard[Seaboard.length] = createMarker(new GPoint(-77.44309998,36.49300003),"
Seaboard-coates Elementary School
Po Box 309
Seaboard, NC 27876

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Seaboard-coates Elementary School",'Seaboard=' + Seaboard.length); Gaston[Gaston.length] = createMarker(new GPoint(-77.68049622,36.50699997),"
Squire Elementary School
Po Drawer G
Gaston, NC 27832

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Squire Elementary School",'Gaston=' + Gaston.length); Pendleton[Pendleton.length] = createMarker(new GPoint(-77.17140198,36.49961853),"
Willis Hare Elementary School
479 Willis Hare Road
Pendleton, NC 27862

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Willis Hare Elementary School",'Pendleton=' + Pendleton.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(Conway); map.removeOverlays(Garysburg); map.removeOverlays(Gaston); map.removeOverlays(Jackson); map.removeOverlays(Pendleton); map.removeOverlays(Rich_Square); map.removeOverlays(Seaboard); 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(Conway);map.removeOverlays(Conway); map.removeOverlays(Garysburg); map.removeOverlays(Gaston); map.removeOverlays(Jackson); map.removeOverlays(Pendleton); map.removeOverlays(Rich_Square); map.removeOverlays(Seaboard); map.addOverlays(Conway); centerByArray(Conway, false, false); cntMarker += Conway.length; map.addOverlays(Garysburg); centerByArray(Garysburg, false, false); cntMarker += Garysburg.length; map.addOverlays(Gaston); centerByArray(Gaston, false, false); cntMarker += Gaston.length; map.addOverlays(Jackson); centerByArray(Jackson, false, false); cntMarker += Jackson.length; map.addOverlays(Pendleton); centerByArray(Pendleton, false, false); cntMarker += Pendleton.length; map.addOverlays(Rich_Square); centerByArray(Rich_Square, false, false); cntMarker += Rich_Square.length; map.addOverlays(Seaboard); centerByArray(Seaboard, false, false); cntMarker += Seaboard.length; centerByArray(Conway,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'); } }