function addMarkers() { mySelect = document.getElementById('selection'); Arkansas_City = [];Burden = [];Winfield = [];Dexter = [];Udall = [];mySelect.options[mySelect.options.length] = new Option("Arkansas City schools",'all=Arkansas_City'); mySelect.options[mySelect.options.length] = new Option("Burden schools",'all=Burden'); mySelect.options[mySelect.options.length] = new Option("Dexter schools",'all=Dexter'); mySelect.options[mySelect.options.length] = new Option("Udall schools",'all=Udall'); mySelect.options[mySelect.options.length] = new Option("Winfield schools",'all=Winfield'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Arkansas_City[Arkansas_City.length] = createMarker(new GPoint(-97.05162048,37.07546234),"
",iconRd); mySelect.options[mySelect.options.length] = new Option("Adams Elementary School",'Arkansas_City=' + Arkansas_City.length); Arkansas_City[Arkansas_City.length] = createMarker(new GPoint(-97.02780151,37.06290054),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Arkansas City High School",'Arkansas_City=' + Arkansas_City.length); Arkansas_City[Arkansas_City.length] = createMarker(new GPoint(-97.03522491,37.07823563),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Arkansas City Middle School",'Arkansas_City=' + Arkansas_City.length); Arkansas_City[Arkansas_City.length] = createMarker(new GPoint(-96.97569275,37.05616379),"",iconRd); mySelect.options[mySelect.options.length] = new Option("C 4 Elementary School",'Arkansas_City=' + Arkansas_City.length); Burden[Burden.length] = createMarker(new GPoint(-96.75202942,37.32066727),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Central Elementary School",'Burden=' + Burden.length); Burden[Burden.length] = createMarker(new GPoint(-96.76940155,37.32870102),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Central Junior Senior High School",'Burden=' + Burden.length); Winfield[Winfield.length] = createMarker(new GPoint(-96.99464100,37.24605900),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Community Learning Center",'Winfield=' + Winfield.length); Winfield[Winfield.length] = createMarker(new GPoint(-96.87976074,37.26177979),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Country View Elementary School",'Winfield=' + Winfield.length); Dexter[Dexter.length] = createMarker(new GPoint(-96.71510315,37.18180084),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Dexter Elementary School",'Dexter=' + Dexter.length); Dexter[Dexter.length] = createMarker(new GPoint(-96.71510315,37.18180084),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Dexter High School",'Dexter=' + Dexter.length); Arkansas_City[Arkansas_City.length] = createMarker(new GPoint(-97.04417419,37.06364822),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Frances Willard Elementary School",'Arkansas_City=' + Arkansas_City.length); Arkansas_City[Arkansas_City.length] = createMarker(new GPoint(-97.04751587,37.01283646),"",iconRd); mySelect.options[mySelect.options.length] = new Option("I X L Elementary School",'Arkansas_City=' + Arkansas_City.length); Winfield[Winfield.length] = createMarker(new GPoint(-96.98741913,37.24723053),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Irving Elementary School",'Winfield=' + Winfield.length); Arkansas_City[Arkansas_City.length] = createMarker(new GPoint(-97.03934479,37.08156204),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Jefferson Elementary School",'Arkansas_City=' + Arkansas_City.length); Winfield[Winfield.length] = createMarker(new GPoint(-96.99577332,37.23520660),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Lowell Elementary School",'Winfield=' + Winfield.length); Winfield[Winfield.length] = createMarker(new GPoint(-96.99891663,37.18679810),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Pleasant Valley Elementary School",'Winfield=' + Winfield.length); Arkansas_City[Arkansas_City.length] = createMarker(new GPoint(-97.03632355,37.06483841),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Roosevelt Elementary School",'Arkansas_City=' + Arkansas_City.length); Winfield[Winfield.length] = createMarker(new GPoint(-97.05998230,37.25176239),"",iconRd); mySelect.options[mySelect.options.length] = new Option("South Vernon Elementary School",'Winfield=' + Winfield.length); Udall[Udall.length] = createMarker(new GPoint(-97.10310364,37.39250183),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Udall Elementary School",'Udall=' + Udall.length); Udall[Udall.length] = createMarker(new GPoint(-97.10310364,37.39250183),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Udall High School",'Udall=' + Udall.length); Udall[Udall.length] = createMarker(new GPoint(-97.12097168,37.38465500),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Udall Middle School",'Udall=' + Udall.length); Winfield[Winfield.length] = createMarker(new GPoint(-96.98693085,37.23733521),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Webster Elementary School",'Winfield=' + Winfield.length); Winfield[Winfield.length] = createMarker(new GPoint(-96.97773743,37.23553085),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Whittier Elementary School",'Winfield=' + Winfield.length); Winfield[Winfield.length] = createMarker(new GPoint(-96.96964264,37.24480438),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Winfield High School",'Winfield=' + Winfield.length); Winfield[Winfield.length] = createMarker(new GPoint(-96.99346161,37.24035645),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Winfield Middle School",'Winfield=' + Winfield.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(Arkansas_City); map.removeOverlays(Burden); map.removeOverlays(Dexter); map.removeOverlays(Udall); map.removeOverlays(Winfield); 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(Arkansas_City);map.removeOverlays(Arkansas_City); map.removeOverlays(Burden); map.removeOverlays(Dexter); map.removeOverlays(Udall); map.removeOverlays(Winfield); map.addOverlays(Arkansas_City); centerByArray(Arkansas_City, false, false); cntMarker += Arkansas_City.length; map.addOverlays(Burden); centerByArray(Burden, false, false); cntMarker += Burden.length; map.addOverlays(Dexter); centerByArray(Dexter, false, false); cntMarker += Dexter.length; map.addOverlays(Udall); centerByArray(Udall, false, false); cntMarker += Udall.length; map.addOverlays(Winfield); centerByArray(Winfield, false, false); cntMarker += Winfield.length; centerByArray(Arkansas_City,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'); } }