function addMarkers() { mySelect = document.getElementById('selection'); Berea = [];Richmond = [];Waco = [];mySelect.options[mySelect.options.length] = new Option("Berea schools",'all=Berea'); mySelect.options[mySelect.options.length] = new Option("Richmond schools",'all=Richmond'); mySelect.options[mySelect.options.length] = new Option("Waco schools",'all=Waco'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Berea[Berea.length] = createMarker(new GPoint(-84.29261017,37.57035065),"
Berea Community Elementary School
2 Pirate Pkwy
Berea, KY 40403

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Berea Community Elementary School",'Berea=' + Berea.length); Berea[Berea.length] = createMarker(new GPoint(-84.29261017,37.57035065),"
Berea Community High School
1 Pirate Pkwy
Berea, KY 40403

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Berea Community High School",'Berea=' + Berea.length); Berea[Berea.length] = createMarker(new GPoint(-84.29261017,37.57035065),"
Berea Community Middle School
2 Pirate Pkwy
Berea, KY 40403

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Berea Community Middle School",'Berea=' + Berea.length); Richmond[Richmond.length] = createMarker(new GPoint(-84.27257538,37.72993088),"
Clark Moores Middle School
1143 Berea Rd
Richmond, KY 40475

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Clark Moores Middle School",'Richmond=' + Richmond.length); Richmond[Richmond.length] = createMarker(new GPoint(-84.29151154,37.75399017),"
Daniel Boone Elementary School
710 N 2nd St
Richmond, KY 40475

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Daniel Boone Elementary School",'Richmond=' + Richmond.length); Berea[Berea.length] = createMarker(new GPoint(-84.29428101,37.58672714),"
Foley Middle School
275 Glades Rd
Berea, KY 40403

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Foley Middle School",'Berea=' + Berea.length); Berea[Berea.length] = createMarker(new GPoint(-84.23538208,37.64524078),"
Kingston Elementary School
329 Kingston Big Hill Rd
Berea, KY 40403

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Kingston Elementary School",'Berea=' + Berea.length); Richmond[Richmond.length] = createMarker(new GPoint(-84.33659363,37.68659592),"
Kirksville Elementary School
2399 Lancaster Rd
Richmond, KY 40475

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Kirksville Elementary School",'Richmond=' + Richmond.length); Richmond[Richmond.length] = createMarker(new GPoint(-84.32057953,37.76300812),"
Kit Carson Elementary School
450 Tates Creek Rd
Richmond, KY 40475

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Kit Carson Elementary School",'Richmond=' + Richmond.length); Richmond[Richmond.length] = createMarker(new GPoint(-84.29151154,37.75392532),"
Madison Central High School
705 N 2nd St
Richmond, KY 40475

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Madison Central High School",'Richmond=' + Richmond.length); Richmond[Richmond.length] = createMarker(new GPoint(-84.30036926,37.75540924),"
Madison Day Treatment Center Alt School
300 Bellevue Dr
Richmond, KY 40475

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Madison Day Treatment Center Alt School",'Richmond=' + Richmond.length); Richmond[Richmond.length] = createMarker(new GPoint(-84.29755900,37.74877000),"
Madison Middle School
101 Summit St
Richmond, KY 40475

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Madison Middle School",'Richmond=' + Richmond.length); Berea[Berea.length] = createMarker(new GPoint(-84.29418182,37.58672333),"
Madison Southern High School
213 Glades Rd
Berea, KY 40403

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Madison Southern High School",'Berea=' + Berea.length); Richmond[Richmond.length] = createMarker(new GPoint(-84.28511047,37.73747635),"
Mayfield Elementary School
300 Bond St
Richmond, KY 40475

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Mayfield Elementary School",'Richmond=' + Richmond.length); Richmond[Richmond.length] = createMarker(new GPoint(-84.30254364,37.74193573),"
Model Laboratory Elementary School
521 Lancaster Ave
Richmond, KY 40475

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Model Laboratory Elementary School",'Richmond=' + Richmond.length); Richmond[Richmond.length] = createMarker(new GPoint(-84.30254364,37.74193573),"
Model Laboratory High School
521 Lancaster Ave
Richmond, KY 40475

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Model Laboratory High School",'Richmond=' + Richmond.length); Richmond[Richmond.length] = createMarker(new GPoint(-84.29755900,37.74877000),"
Model Laboratory Middle School
521 Lancaster Ave
Richmond, KY 40475

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Model Laboratory Middle School",'Richmond=' + Richmond.length); Berea[Berea.length] = createMarker(new GPoint(-84.28707886,37.59132004),"
Shannon Johnson Elementary School
109 Oakwood Dr
Berea, KY 40403

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Shannon Johnson Elementary School",'Berea=' + Berea.length); Berea[Berea.length] = createMarker(new GPoint(-84.26693726,37.58966827),"
Silver Creek Elementary School
75 Old Us 25 N
Berea, KY 40403

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Silver Creek Elementary School",'Berea=' + Berea.length); Waco[Waco.length] = createMarker(new GPoint(-84.12419891,37.73150253),"
Waco Elementary School
359 Waco Loop
Waco, KY 40385

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Waco Elementary School",'Waco=' + Waco.length); Richmond[Richmond.length] = createMarker(new GPoint(-84.31925964,37.77613449),"
White Hall Elementary School
2166 Lexington Rd
Richmond, KY 40475

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