function addMarkers() { mySelect = document.getElementById('selection'); Mount_Summit = [];New_Castle = [];Kennard = [];Knightstown = [];Middletown = [];Spiceland = [];Straughn = [];mySelect.options[mySelect.options.length] = new Option("Kennard schools",'all=Kennard'); mySelect.options[mySelect.options.length] = new Option("Knightstown schools",'all=Knightstown'); mySelect.options[mySelect.options.length] = new Option("Middletown schools",'all=Middletown'); mySelect.options[mySelect.options.length] = new Option("Mount Summit schools",'all=Mount_Summit'); mySelect.options[mySelect.options.length] = new Option("New Castle schools",'all=New_Castle'); mySelect.options[mySelect.options.length] = new Option("Spiceland schools",'all=Spiceland'); mySelect.options[mySelect.options.length] = new Option("Straughn schools",'all=Straughn'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Mount_Summit[Mount_Summit.length] = createMarker(new GPoint(-85.38610077,40.00400162),"
",iconRd); mySelect.options[mySelect.options.length] = new Option("Blue River Valley Elementary School",'Mount_Summit=' + Mount_Summit.length); Mount_Summit[Mount_Summit.length] = createMarker(new GPoint(-85.38610077,40.00400162),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Blue River Valley Junior Senior High School",'Mount_Summit=' + Mount_Summit.length); New_Castle[New_Castle.length] = createMarker(new GPoint(-85.35801697,39.92392349),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Eastwood Elementary School",'New_Castle=' + New_Castle.length); New_Castle[New_Castle.length] = createMarker(new GPoint(-85.37918091,39.92848969),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Greenstreet Elementary School",'New_Castle=' + New_Castle.length); New_Castle[New_Castle.length] = createMarker(new GPoint(-85.36637000,39.91690300),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Henry Co Youth Center",'New_Castle=' + New_Castle.length); New_Castle[New_Castle.length] = createMarker(new GPoint(-85.37200928,39.90226364),"",iconRd); mySelect.options[mySelect.options.length] = new Option("James Whitcomb Riley Elementary School",'New_Castle=' + New_Castle.length); Kennard[Kennard.length] = createMarker(new GPoint(-85.51969910,39.90349960),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Kennard Elementary School",'Kennard=' + Kennard.length); Knightstown[Knightstown.length] = createMarker(new GPoint(-85.52617645,39.79541016),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Knightstown Elementary School",'Knightstown=' + Knightstown.length); Knightstown[Knightstown.length] = createMarker(new GPoint(-85.52130127,39.80250168),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Knightstown High School",'Knightstown=' + Knightstown.length); Knightstown[Knightstown.length] = createMarker(new GPoint(-85.51509857,39.80759811),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Knightstown Intermediate School",'Knightstown=' + Knightstown.length); New_Castle[New_Castle.length] = createMarker(new GPoint(-85.37001801,39.92890167),"",iconGr); mySelect.options[mySelect.options.length] = new Option("New Castle Area Vocational School",'New_Castle=' + New_Castle.length); New_Castle[New_Castle.length] = createMarker(new GPoint(-85.37787628,39.91390991),"",iconGr); mySelect.options[mySelect.options.length] = new Option("New Castle Chrysler High School",'New_Castle=' + New_Castle.length); New_Castle[New_Castle.length] = createMarker(new GPoint(-85.38091278,39.91386414),"",iconBl); mySelect.options[mySelect.options.length] = new Option("New Castle Middle School",'New_Castle=' + New_Castle.length); New_Castle[New_Castle.length] = createMarker(new GPoint(-85.36864471,39.92776489),"",iconGr); mySelect.options[mySelect.options.length] = new Option("North Campus Alternative School",'New_Castle=' + New_Castle.length); New_Castle[New_Castle.length] = createMarker(new GPoint(-85.36867523,39.91386032),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Parker Elementary School",'New_Castle=' + New_Castle.length); Middletown[Middletown.length] = createMarker(new GPoint(-85.52789307,40.00833511),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Shenandoah Elementary School",'Middletown=' + Middletown.length); Middletown[Middletown.length] = createMarker(new GPoint(-85.53620911,40.05731964),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Shenandoah High School",'Middletown=' + Middletown.length); Middletown[Middletown.length] = createMarker(new GPoint(-85.52794647,40.00692749),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Shenandoah Middle School",'Middletown=' + Middletown.length); Spiceland[Spiceland.length] = createMarker(new GPoint(-85.44300079,39.83853531),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Spiceland Elementary School",'Spiceland=' + Spiceland.length); New_Castle[New_Castle.length] = createMarker(new GPoint(-85.36250305,39.90801620),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Sunnyside Elementary School",'New_Castle=' + New_Castle.length); Straughn[Straughn.length] = createMarker(new GPoint(-85.29099274,39.80913162),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Tri Junior-senior High School",'Straughn=' + Straughn.length); Straughn[Straughn.length] = createMarker(new GPoint(-85.29099274,39.80913162),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Tri-elementary School",'Straughn=' + Straughn.length); New_Castle[New_Castle.length] = createMarker(new GPoint(-85.42262268,39.90314484),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Westwood Elementary School",'New_Castle=' + New_Castle.length); New_Castle[New_Castle.length] = createMarker(new GPoint(-85.36148071,39.93873596),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Wilbur Wright Elementary School",'New_Castle=' + New_Castle.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(Kennard); map.removeOverlays(Knightstown); map.removeOverlays(Middletown); map.removeOverlays(Mount_Summit); map.removeOverlays(New_Castle); map.removeOverlays(Spiceland); map.removeOverlays(Straughn); 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(Mount_Summit);map.removeOverlays(Kennard); map.removeOverlays(Knightstown); map.removeOverlays(Middletown); map.removeOverlays(Mount_Summit); map.removeOverlays(New_Castle); map.removeOverlays(Spiceland); map.removeOverlays(Straughn); map.addOverlays(Kennard); centerByArray(Kennard, false, false); cntMarker += Kennard.length; map.addOverlays(Knightstown); centerByArray(Knightstown, false, false); cntMarker += Knightstown.length; map.addOverlays(Middletown); centerByArray(Middletown, false, false); cntMarker += Middletown.length; map.addOverlays(Mount_Summit); centerByArray(Mount_Summit, false, false); cntMarker += Mount_Summit.length; map.addOverlays(New_Castle); centerByArray(New_Castle, false, false); cntMarker += New_Castle.length; map.addOverlays(Spiceland); centerByArray(Spiceland, false, false); cntMarker += Spiceland.length; map.addOverlays(Straughn); centerByArray(Straughn, false, false); cntMarker += Straughn.length; centerByArray(Mount_Summit,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'); } }