function addMarkers() { mySelect = document.getElementById('selection'); Mc_Connelsville = [];Glouster = [];Malta = [];Chesterhill = [];Mcconnelsville = [];Stockport = [];Crooksville = [];mySelect.options[mySelect.options.length] = new Option("Chesterhill schools",'all=Chesterhill'); mySelect.options[mySelect.options.length] = new Option("Crooksville schools",'all=Crooksville'); mySelect.options[mySelect.options.length] = new Option("Glouster schools",'all=Glouster'); mySelect.options[mySelect.options.length] = new Option("Malta schools",'all=Malta'); mySelect.options[mySelect.options.length] = new Option("Mc Connelsville schools",'all=Mc_Connelsville'); mySelect.options[mySelect.options.length] = new Option("Mcconnelsville schools",'all=Mcconnelsville'); mySelect.options[mySelect.options.length] = new Option("Stockport schools",'all=Stockport'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Mc_Connelsville[Mc_Connelsville.length] = createMarker(new GPoint(-81.86007690,39.66420746),"
East Elementary School
4265 N State Route 376 Nw
Mc Connelsville, OH 43756

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("East Elementary School",'Mc_Connelsville=' + Mc_Connelsville.length); Glouster[Glouster.length] = createMarker(new GPoint(-82.08493042,39.50315094),"
Homer Union Elementary School
4515 Mountville Rd, Rt 2
Glouster, OH 45732

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Homer Union Elementary School",'Glouster=' + Glouster.length); Malta[Malta.length] = createMarker(new GPoint(-81.86539459,39.65322495),"
Malta Elementary School
851 N Main, Po Box 265
Malta, OH 43758

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Malta Elementary School",'Malta=' + Malta.length); Chesterhill[Chesterhill.length] = createMarker(new GPoint(-81.86907959,39.49068069),"
Marion Elementary School
7474 College St, Po Box 115
Chesterhill, OH 43728

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Marion Elementary School",'Chesterhill=' + Chesterhill.length); Mcconnelsville[Mcconnelsville.length] = createMarker(new GPoint(-81.85274506,39.65083694),"
Mcconnelsville Elementary School
21 E Jefferson St
Mcconnelsville, OH 43756

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Mcconnelsville Elementary School",'Mcconnelsville=' + Mcconnelsville.length); Mc_Connelsville[Mc_Connelsville.length] = createMarker(new GPoint(-81.81638336,39.61045074),"
Morgan High School
800 Raider Dr
Mc Connelsville, OH 43756

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Morgan High School",'Mc_Connelsville=' + Mc_Connelsville.length); Mc_Connelsville[Mc_Connelsville.length] = createMarker(new GPoint(-81.81638336,39.61045074),"
Morgan Junior High School
820 Raider Dr
Mc Connelsville, OH 43756

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Morgan Junior High School",'Mc_Connelsville=' + Mc_Connelsville.length); Stockport[Stockport.length] = createMarker(new GPoint(-81.79360962,39.54771042),"
Pennsville Elementary School
1821 S St Rt 377, Rt 1
Stockport, OH 43787

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Pennsville Elementary School",'Stockport=' + Stockport.length); Stockport[Stockport.length] = createMarker(new GPoint(-81.81642151,39.54706192),"
South Elementary School
3555 State Route 792
Stockport, OH 43787

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("South Elementary School",'Stockport=' + Stockport.length); Malta[Malta.length] = createMarker(new GPoint(-82.00517273,39.66839600),"
West Elementary School
9675 State Route 37
Malta, OH 43758

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("West Elementary School",'Malta=' + Malta.length); Stockport[Stockport.length] = createMarker(new GPoint(-81.81159973,39.54980087),"
Windsor Elementary School
Po Box 288
Stockport, OH 43787

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Windsor Elementary School",'Stockport=' + Stockport.length); Crooksville[Crooksville.length] = createMarker(new GPoint(-82.03784943,39.73283768),"
York Elementary School
8500 St Rt 555
Crooksville, OH 43731

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("York Elementary School",'Crooksville=' + Crooksville.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(Chesterhill); map.removeOverlays(Crooksville); map.removeOverlays(Glouster); map.removeOverlays(Malta); map.removeOverlays(Mc_Connelsville); map.removeOverlays(Mcconnelsville); map.removeOverlays(Stockport); 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(Mc_Connelsville);map.removeOverlays(Chesterhill); map.removeOverlays(Crooksville); map.removeOverlays(Glouster); map.removeOverlays(Malta); map.removeOverlays(Mc_Connelsville); map.removeOverlays(Mcconnelsville); map.removeOverlays(Stockport); map.addOverlays(Chesterhill); centerByArray(Chesterhill, false, false); cntMarker += Chesterhill.length; map.addOverlays(Crooksville); centerByArray(Crooksville, false, false); cntMarker += Crooksville.length; map.addOverlays(Glouster); centerByArray(Glouster, false, false); cntMarker += Glouster.length; map.addOverlays(Malta); centerByArray(Malta, false, false); cntMarker += Malta.length; map.addOverlays(Mc_Connelsville); centerByArray(Mc_Connelsville, false, false); cntMarker += Mc_Connelsville.length; map.addOverlays(Mcconnelsville); centerByArray(Mcconnelsville, false, false); cntMarker += Mcconnelsville.length; map.addOverlays(Stockport); centerByArray(Stockport, false, false); cntMarker += Stockport.length; centerByArray(Mc_Connelsville,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'); } }