function addMarkers() { mySelect = document.getElementById('selection'); Kokomo = [];Greentown = [];Russiaville = [];mySelect.options[mySelect.options.length] = new Option("Greentown schools",'all=Greentown'); mySelect.options[mySelect.options.length] = new Option("Kokomo schools",'all=Kokomo'); mySelect.options[mySelect.options.length] = new Option("Russiaville schools",'all=Russiaville'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Kokomo[Kokomo.length] = createMarker(new GPoint(-86.12671661,40.51525116),"
",iconRd); mySelect.options[mySelect.options.length] = new Option("Bon Air Elementary School",'Kokomo=' + Kokomo.length); Kokomo[Kokomo.length] = createMarker(new GPoint(-86.12671661,40.51520157),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Bon Air Middle School",'Kokomo=' + Kokomo.length); Kokomo[Kokomo.length] = createMarker(new GPoint(-86.13369751,40.48643112),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Boulevard Elementary School",'Kokomo=' + Kokomo.length); Kokomo[Kokomo.length] = createMarker(new GPoint(-86.12847137,40.48537827),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Central Middle School",'Kokomo=' + Kokomo.length); Kokomo[Kokomo.length] = createMarker(new GPoint(-86.13732147,40.49722290),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Columbian Elementary School",'Kokomo=' + Kokomo.length); Kokomo[Kokomo.length] = createMarker(new GPoint(-86.09832001,40.47763443),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Darrough Chapel Elementary School",'Kokomo=' + Kokomo.length); Greentown[Greentown.length] = createMarker(new GPoint(-85.96676636,40.47564316),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Eastern Elementary School",'Greentown=' + Greentown.length); Greentown[Greentown.length] = createMarker(new GPoint(-85.97058105,40.47356415),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Eastern Junior & Senior High School",'Greentown=' + Greentown.length); Kokomo[Kokomo.length] = createMarker(new GPoint(-86.11195374,40.47752380),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Elwood Haynes Elementary School",'Kokomo=' + Kokomo.length); Kokomo[Kokomo.length] = createMarker(new GPoint(-86.06968689,40.52826309),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Howard Elementary School",'Kokomo=' + Kokomo.length); Kokomo[Kokomo.length] = createMarker(new GPoint(-86.14208221,40.43820190),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Kokomo Area Career Center",'Kokomo=' + Kokomo.length); Kokomo[Kokomo.length] = createMarker(new GPoint(-86.15567780,40.45595551),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Kokomo High School",'Kokomo=' + Kokomo.length); Kokomo[Kokomo.length] = createMarker(new GPoint(-86.14897919,40.49367523),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Lafayette Park Elementary School",'Kokomo=' + Kokomo.length); Kokomo[Kokomo.length] = createMarker(new GPoint(-86.14897919,40.49370575),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Lafayette Park Middle School",'Kokomo=' + Kokomo.length); Kokomo[Kokomo.length] = createMarker(new GPoint(-86.13282013,40.45528030),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Maple Crest Elementary School",'Kokomo=' + Kokomo.length); Kokomo[Kokomo.length] = createMarker(new GPoint(-86.13197327,40.45689011),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Maple Crest Middle School",'Kokomo=' + Kokomo.length); Kokomo[Kokomo.length] = createMarker(new GPoint(-86.13369751,40.48643112),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Northwestern Elementary School",'Kokomo=' + Kokomo.length); Kokomo[Kokomo.length] = createMarker(new GPoint(-86.05083466,40.52069473),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Northwestern Middle School",'Kokomo=' + Kokomo.length); Kokomo[Kokomo.length] = createMarker(new GPoint(-86.20336151,40.52521896),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Northwestern Senior High School",'Kokomo=' + Kokomo.length); Kokomo[Kokomo.length] = createMarker(new GPoint(-86.14118958,40.49426270),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Pettit Park School",'Kokomo=' + Kokomo.length); Kokomo[Kokomo.length] = createMarker(new GPoint(-86.11054230,40.48891449),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Sycamore Elementary School",'Kokomo=' + Kokomo.length); Kokomo[Kokomo.length] = createMarker(new GPoint(-86.13369751,40.48643112),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Taylor High School",'Kokomo=' + Kokomo.length); Kokomo[Kokomo.length] = createMarker(new GPoint(-86.05674744,40.43436813),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Taylor Intermediate School",'Kokomo=' + Kokomo.length); Kokomo[Kokomo.length] = createMarker(new GPoint(-86.13369751,40.48643112),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Taylor Middle School",'Kokomo=' + Kokomo.length); Kokomo[Kokomo.length] = createMarker(new GPoint(-86.11854553,40.42671204),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Taylor Primary School",'Kokomo=' + Kokomo.length); Kokomo[Kokomo.length] = createMarker(new GPoint(-86.16368866,40.49073792),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Wallace Elementary School",'Kokomo=' + Kokomo.length); Kokomo[Kokomo.length] = createMarker(new GPoint(-86.13362122,40.46926117),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Washington Elementary School",'Kokomo=' + Kokomo.length); Russiaville[Russiaville.length] = createMarker(new GPoint(-86.27137756,40.41748047),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Western High School",'Russiaville=' + Russiaville.length); Russiaville[Russiaville.length] = createMarker(new GPoint(-86.27137756,40.41748047),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Western Intermediate School",'Russiaville=' + Russiaville.length); Russiaville[Russiaville.length] = createMarker(new GPoint(-86.27137756,40.41748047),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Western Middle School",'Russiaville=' + Russiaville.length); Russiaville[Russiaville.length] = createMarker(new GPoint(-86.27137756,40.41748047),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Western Primary School",'Russiaville=' + Russiaville.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(Greentown); map.removeOverlays(Kokomo); map.removeOverlays(Russiaville); 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(Kokomo);map.removeOverlays(Greentown); map.removeOverlays(Kokomo); map.removeOverlays(Russiaville); map.addOverlays(Greentown); centerByArray(Greentown, false, false); cntMarker += Greentown.length; map.addOverlays(Kokomo); centerByArray(Kokomo, false, false); cntMarker += Kokomo.length; map.addOverlays(Russiaville); centerByArray(Russiaville, false, false); cntMarker += Russiaville.length; centerByArray(Kokomo,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'); } }