function addMarkers() { mySelect = document.getElementById('selection'); Berlin = [];Charm = [];Millersburg = [];Holmesville = [];Killbuck = [];Lakeville = [];Mount_Hope = [];Nashville = [];Walnut_Creek = [];Winesburg = [];mySelect.options[mySelect.options.length] = new Option("Berlin schools",'all=Berlin'); mySelect.options[mySelect.options.length] = new Option("Charm schools",'all=Charm'); mySelect.options[mySelect.options.length] = new Option("Holmesville schools",'all=Holmesville'); mySelect.options[mySelect.options.length] = new Option("Killbuck schools",'all=Killbuck'); mySelect.options[mySelect.options.length] = new Option("Lakeville schools",'all=Lakeville'); mySelect.options[mySelect.options.length] = new Option("Millersburg schools",'all=Millersburg'); mySelect.options[mySelect.options.length] = new Option("Mount Hope schools",'all=Mount_Hope'); mySelect.options[mySelect.options.length] = new Option("Nashville schools",'all=Nashville'); mySelect.options[mySelect.options.length] = new Option("Walnut Creek schools",'all=Walnut_Creek'); mySelect.options[mySelect.options.length] = new Option("Winesburg schools",'all=Winesburg'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Berlin[Berlin.length] = createMarker(new GPoint(-81.79699707,40.56159973),"
",iconRd); mySelect.options[mySelect.options.length] = new Option("Berlin Elementary School",'Berlin=' + Berlin.length); Charm[Charm.length] = createMarker(new GPoint(-81.78500366,40.50659943),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Charm Elementary School",'Charm=' + Charm.length); Berlin[Berlin.length] = createMarker(new GPoint(-81.79699707,40.56159973),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Chestnut Ridge Elementary School",'Berlin=' + Berlin.length); Millersburg[Millersburg.length] = createMarker(new GPoint(-81.91660309,40.53736115),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Clark Elementary School",'Millersburg=' + Millersburg.length); Charm[Charm.length] = createMarker(new GPoint(-81.78500366,40.50659943),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Flat Ridge Elementary School",'Charm=' + Charm.length); Berlin[Berlin.length] = createMarker(new GPoint(-81.79699707,40.56159973),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Hiland High School",'Berlin=' + Berlin.length); Holmesville[Holmesville.length] = createMarker(new GPoint(-81.92970276,40.63010025),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Holmesville Elementary School",'Holmesville=' + Holmesville.length); Killbuck[Killbuck.length] = createMarker(new GPoint(-81.97847748,40.49726486),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Killbuck Elementary School",'Killbuck=' + Killbuck.length); Lakeville[Lakeville.length] = createMarker(new GPoint(-82.13430023,40.64939880),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Lakeville Elementary School",'Lakeville=' + Lakeville.length); Millersburg[Millersburg.length] = createMarker(new GPoint(-81.91198730,40.55413818),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Millersburg Elementary School",'Millersburg=' + Millersburg.length); Mount_Hope[Mount_Hope.length] = createMarker(new GPoint(-81.78469849,40.62379837),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Mt Hope Elementary School",'Mount_Hope=' + Mount_Hope.length); Nashville[Nashville.length] = createMarker(new GPoint(-82.11360168,40.59619904),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Nashville Elementary School",'Nashville=' + Nashville.length); Charm[Charm.length] = createMarker(new GPoint(-81.78500366,40.50659943),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Sharp Run Elementary School",'Charm=' + Charm.length); Walnut_Creek[Walnut_Creek.length] = createMarker(new GPoint(-81.72190094,40.54130173),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Walnut Creek Elementary School",'Walnut_Creek=' + Walnut_Creek.length); Millersburg[Millersburg.length] = createMarker(new GPoint(-82.01863861,40.57619095),"",iconGr); mySelect.options[mySelect.options.length] = new Option("West Holmes High School",'Millersburg=' + Millersburg.length); Millersburg[Millersburg.length] = createMarker(new GPoint(-82.01853943,40.57617188),"",iconBl); mySelect.options[mySelect.options.length] = new Option("West Holmes Middle School",'Millersburg=' + Millersburg.length); Winesburg[Winesburg.length] = createMarker(new GPoint(-81.69490051,40.61640167),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Winesburg Elementary School",'Winesburg=' + Winesburg.length); Charm[Charm.length] = createMarker(new GPoint(-81.78500366,40.50659943),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Wise Elementary School",'Charm=' + Charm.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(Berlin); map.removeOverlays(Charm); map.removeOverlays(Holmesville); map.removeOverlays(Killbuck); map.removeOverlays(Lakeville); map.removeOverlays(Millersburg); map.removeOverlays(Mount_Hope); map.removeOverlays(Nashville); map.removeOverlays(Walnut_Creek); map.removeOverlays(Winesburg); 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(Berlin);map.removeOverlays(Berlin); map.removeOverlays(Charm); map.removeOverlays(Holmesville); map.removeOverlays(Killbuck); map.removeOverlays(Lakeville); map.removeOverlays(Millersburg); map.removeOverlays(Mount_Hope); map.removeOverlays(Nashville); map.removeOverlays(Walnut_Creek); map.removeOverlays(Winesburg); map.addOverlays(Berlin); centerByArray(Berlin, false, false); cntMarker += Berlin.length; map.addOverlays(Charm); centerByArray(Charm, false, false); cntMarker += Charm.length; map.addOverlays(Holmesville); centerByArray(Holmesville, false, false); cntMarker += Holmesville.length; map.addOverlays(Killbuck); centerByArray(Killbuck, false, false); cntMarker += Killbuck.length; map.addOverlays(Lakeville); centerByArray(Lakeville, false, false); cntMarker += Lakeville.length; map.addOverlays(Millersburg); centerByArray(Millersburg, false, false); cntMarker += Millersburg.length; map.addOverlays(Mount_Hope); centerByArray(Mount_Hope, false, false); cntMarker += Mount_Hope.length; map.addOverlays(Nashville); centerByArray(Nashville, false, false); cntMarker += Nashville.length; map.addOverlays(Walnut_Creek); centerByArray(Walnut_Creek, false, false); cntMarker += Walnut_Creek.length; map.addOverlays(Winesburg); centerByArray(Winesburg, false, false); cntMarker += Winesburg.length; centerByArray(Berlin,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'); } }