function addMarkers() { mySelect = document.getElementById('selection'); Batesville = [];Bentonville = [];Sherwood = [];Texarkana = [];Helena = [];Mount_Pleasant = [];Hot_Springs = [];Fayetteville = [];mySelect.options[mySelect.options.length] = new Option("Batesville schools",'all=Batesville'); mySelect.options[mySelect.options.length] = new Option("Bentonville schools",'all=Bentonville'); mySelect.options[mySelect.options.length] = new Option("Fayetteville schools",'all=Fayetteville'); mySelect.options[mySelect.options.length] = new Option("Helena schools",'all=Helena'); mySelect.options[mySelect.options.length] = new Option("Hot Springs schools",'all=Hot_Springs'); mySelect.options[mySelect.options.length] = new Option("Mount Pleasant schools",'all=Mount_Pleasant'); mySelect.options[mySelect.options.length] = new Option("Sherwood schools",'all=Sherwood'); mySelect.options[mySelect.options.length] = new Option("Texarkana schools",'all=Texarkana'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Batesville[Batesville.length] = createMarker(new GPoint(-91.50015259,35.93426132),"
Batesville High School
1 Pioneer Drive
Batesville, AR 72501

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Batesville High School",'Batesville=' + Batesville.length); Bentonville[Bentonville.length] = createMarker(new GPoint(-94.19702911,36.35125351),"
Bentonville High School
1901 Se J Street
Bentonville, AR 72712

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Bentonville High School",'Bentonville=' + Bentonville.length); Sherwood[Sherwood.length] = createMarker(new GPoint(-92.20130157,34.82529831),"
Clinton Elementary School
142 Hollywood Ave.
Sherwood, AR 72120

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Clinton Elementary School",'Sherwood=' + Sherwood.length); Texarkana[Texarkana.length] = createMarker(new GPoint(-94.03233337,33.45671463),"
College Hill Elementary School
200 Artesian St.
Texarkana, AR 71854

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("College Hill Elementary School",'Texarkana=' + Texarkana.length); Helena[Helena.length] = createMarker(new GPoint(-90.58602905,34.52392197),"
Kipp:delta College Prep School
215 Cherry
Helena, AR 72342

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Kipp:delta College Prep School",'Helena=' + Helena.length); Mount_Pleasant[Mount_Pleasant.length] = createMarker(new GPoint(-91.80069733,35.96730042),"
Mount Pleasant Elementary School
P.o. Box 144
Mount Pleasant, AR 72561

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Mount Pleasant Elementary School",'Mount_Pleasant=' + Mount_Pleasant.length); Hot_Springs[Hot_Springs.length] = createMarker(new GPoint(-93.04811859,34.52755356),"
Park Magnet School
220 Tom Ellsworth
Hot Springs, AR 71901

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Park Magnet School",'Hot_Springs=' + Hot_Springs.length); Fayetteville[Fayetteville.length] = createMarker(new GPoint(-94.12171936,36.09436417),"
Vandergriff Elementary School
2975 East Township
Fayetteville, AR 72703

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Vandergriff Elementary School",'Fayetteville=' + Fayetteville.length); map.removeOverlays(Batesville); map.removeOverlays(Bentonville); map.removeOverlays(Fayetteville); map.removeOverlays(Helena); map.removeOverlays(Hot_Springs); map.removeOverlays(Mount_Pleasant); map.removeOverlays(Sherwood); map.removeOverlays(Texarkana); setTimeout(function(){map.addOverlays(Batesville)},1000); setTimeout(function(){map.addOverlays(Bentonville)},1000); setTimeout(function(){map.addOverlays(Fayetteville)},1000); setTimeout(function(){map.addOverlays(Helena)},1000); setTimeout(function(){map.addOverlays(Hot_Springs)},1000); setTimeout(function(){map.addOverlays(Mount_Pleasant)},1000); setTimeout(function(){map.addOverlays(Sherwood)},1000); setTimeout(function(){map.addOverlays(Texarkana)},1000); maxLng = -90.58602905; maxLat = 36.35125351; minLng = -94.19702911; minLat = 33.45671463; reCenterMap(); } // 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(Batesville); map.removeOverlays(Bentonville); map.removeOverlays(Fayetteville); map.removeOverlays(Helena); map.removeOverlays(Hot_Springs); map.removeOverlays(Mount_Pleasant); map.removeOverlays(Sherwood); map.removeOverlays(Texarkana); 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(Batesville);map.removeOverlays(Batesville); map.removeOverlays(Bentonville); map.removeOverlays(Fayetteville); map.removeOverlays(Helena); map.removeOverlays(Hot_Springs); map.removeOverlays(Mount_Pleasant); map.removeOverlays(Sherwood); map.removeOverlays(Texarkana); map.addOverlays(Batesville); centerByArray(Batesville, false, false); cntMarker += Batesville.length; map.addOverlays(Bentonville); centerByArray(Bentonville, false, false); cntMarker += Bentonville.length; map.addOverlays(Fayetteville); centerByArray(Fayetteville, false, false); cntMarker += Fayetteville.length; map.addOverlays(Helena); centerByArray(Helena, false, false); cntMarker += Helena.length; map.addOverlays(Hot_Springs); centerByArray(Hot_Springs, false, false); cntMarker += Hot_Springs.length; map.addOverlays(Mount_Pleasant); centerByArray(Mount_Pleasant, false, false); cntMarker += Mount_Pleasant.length; map.addOverlays(Sherwood); centerByArray(Sherwood, false, false); cntMarker += Sherwood.length; map.addOverlays(Texarkana); centerByArray(Texarkana, false, false); cntMarker += Texarkana.length; centerByArray(Batesville,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///3664,3809,95646,4034,4201,4399,4513,4671,/all'); } }