function addMarkers() { mySelect = document.getElementById('selection'); Crooksville = [];Glenford = [];Junction_City = [];Corning = [];New_Lexington = [];Roseville = [];Thornville = [];Somerset = [];mySelect.options[mySelect.options.length] = new Option("Corning schools",'all=Corning'); mySelect.options[mySelect.options.length] = new Option("Crooksville schools",'all=Crooksville'); mySelect.options[mySelect.options.length] = new Option("Glenford schools",'all=Glenford'); mySelect.options[mySelect.options.length] = new Option("Junction City schools",'all=Junction_City'); mySelect.options[mySelect.options.length] = new Option("New Lexington schools",'all=New_Lexington'); mySelect.options[mySelect.options.length] = new Option("Roseville schools",'all=Roseville'); mySelect.options[mySelect.options.length] = new Option("Somerset schools",'all=Somerset'); mySelect.options[mySelect.options.length] = new Option("Thornville schools",'all=Thornville'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Crooksville[Crooksville.length] = createMarker(new GPoint(-82.09321594,39.74375534),"
",iconGr); mySelect.options[mySelect.options.length] = new Option("Crooksville High School",'Crooksville=' + Crooksville.length); Crooksville[Crooksville.length] = createMarker(new GPoint(-82.10144806,39.74043655),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Crooksville K-8 Elementary School",'Crooksville=' + Crooksville.length); Crooksville[Crooksville.length] = createMarker(new GPoint(-82.10144806,39.74043655),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Crooksville Middle School",'Crooksville=' + Crooksville.length); Glenford[Glenford.length] = createMarker(new GPoint(-82.31649780,39.88750076),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Glenford Elementary School",'Glenford=' + Glenford.length); Junction_City[Junction_City.length] = createMarker(new GPoint(-82.30629730,39.70439911),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Junction City Elementary School",'Junction_City=' + Junction_City.length); Corning[Corning.length] = createMarker(new GPoint(-82.14310455,39.59176254),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Millcreek Elementary School",'Corning=' + Corning.length); Corning[Corning.length] = createMarker(new GPoint(-82.14310455,39.59176254),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Miller High School",'Corning=' + Corning.length); Corning[Corning.length] = createMarker(new GPoint(-82.14310455,39.59176254),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Miller Middle School",'Corning=' + Corning.length); New_Lexington[New_Lexington.length] = createMarker(new GPoint(-82.20533752,39.72634506),"",iconRd); mySelect.options[mySelect.options.length] = new Option("New Lexington Elementary School",'New_Lexington=' + New_Lexington.length); New_Lexington[New_Lexington.length] = createMarker(new GPoint(-82.20526886,39.72632599),"",iconGr); mySelect.options[mySelect.options.length] = new Option("New Lexington High School",'New_Lexington=' + New_Lexington.length); New_Lexington[New_Lexington.length] = createMarker(new GPoint(-82.20530701,39.72633743),"",iconBl); mySelect.options[mySelect.options.length] = new Option("New Lexington Middle School",'New_Lexington=' + New_Lexington.length); New_Lexington[New_Lexington.length] = createMarker(new GPoint(-82.18699646,39.76466370),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Perry County Learning Center",'New_Lexington=' + New_Lexington.length); Roseville[Roseville.length] = createMarker(new GPoint(-82.07060242,39.82030106),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Roseville Elementary School",'Roseville=' + Roseville.length); Roseville[Roseville.length] = createMarker(new GPoint(-82.07060242,39.82030106),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Roseville Middle School",'Roseville=' + Roseville.length); Thornville[Thornville.length] = createMarker(new GPoint(-82.37746429,39.82446289),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Sheridan High School",'Thornville=' + Thornville.length); Thornville[Thornville.length] = createMarker(new GPoint(-82.37744904,39.82463837),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Sheridan Middle School",'Thornville=' + Thornville.length); Somerset[Somerset.length] = createMarker(new GPoint(-82.29866028,39.81314468),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Somerset Elementary School",'Somerset=' + Somerset.length); Thornville[Thornville.length] = createMarker(new GPoint(-82.41802216,39.89633560),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Thornville Elementary School",'Thornville=' + Thornville.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(Corning); map.removeOverlays(Crooksville); map.removeOverlays(Glenford); map.removeOverlays(Junction_City); map.removeOverlays(New_Lexington); map.removeOverlays(Roseville); map.removeOverlays(Somerset); map.removeOverlays(Thornville); 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(Crooksville);map.removeOverlays(Corning); map.removeOverlays(Crooksville); map.removeOverlays(Glenford); map.removeOverlays(Junction_City); map.removeOverlays(New_Lexington); map.removeOverlays(Roseville); map.removeOverlays(Somerset); map.removeOverlays(Thornville); map.addOverlays(Corning); centerByArray(Corning, false, false); cntMarker += Corning.length; map.addOverlays(Crooksville); centerByArray(Crooksville, false, false); cntMarker += Crooksville.length; map.addOverlays(Glenford); centerByArray(Glenford, false, false); cntMarker += Glenford.length; map.addOverlays(Junction_City); centerByArray(Junction_City, false, false); cntMarker += Junction_City.length; map.addOverlays(New_Lexington); centerByArray(New_Lexington, false, false); cntMarker += New_Lexington.length; map.addOverlays(Roseville); centerByArray(Roseville, false, false); cntMarker += Roseville.length; map.addOverlays(Somerset); centerByArray(Somerset, false, false); cntMarker += Somerset.length; map.addOverlays(Thornville); centerByArray(Thornville, false, false); cntMarker += Thornville.length; centerByArray(Crooksville,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'); } }