function addMarkers() { mySelect = document.getElementById('selection'); Colcord = [];Grove = [];Jay = [];Kansas = [];Salina = [];Twin_Oaks = [];Oaks = [];mySelect.options[mySelect.options.length] = new Option("Colcord schools",'all=Colcord'); mySelect.options[mySelect.options.length] = new Option("Grove schools",'all=Grove'); mySelect.options[mySelect.options.length] = new Option("Jay schools",'all=Jay'); mySelect.options[mySelect.options.length] = new Option("Kansas schools",'all=Kansas'); mySelect.options[mySelect.options.length] = new Option("Oaks schools",'all=Oaks'); mySelect.options[mySelect.options.length] = new Option("Salina schools",'all=Salina'); mySelect.options[mySelect.options.length] = new Option("Twin Oaks schools",'all=Twin_Oaks'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Colcord[Colcord.length] = createMarker(new GPoint(-94.67790222,36.21239853),"
",iconRd); mySelect.options[mySelect.options.length] = new Option("Colcord Elementary School",'Colcord=' + Colcord.length); Colcord[Colcord.length] = createMarker(new GPoint(-94.67790222,36.21239853),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Colcord High School",'Colcord=' + Colcord.length); Grove[Grove.length] = createMarker(new GPoint(-94.75810242,36.59450150),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Grove High School",'Grove=' + Grove.length); Grove[Grove.length] = createMarker(new GPoint(-94.75810242,36.59450150),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Grove Lower Elementary School",'Grove=' + Grove.length); Grove[Grove.length] = createMarker(new GPoint(-94.75810242,36.59450150),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Grove Middle School",'Grove=' + Grove.length); Grove[Grove.length] = createMarker(new GPoint(-94.75810242,36.59450150),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Grove Upper Elementary School",'Grove=' + Grove.length); Jay[Jay.length] = createMarker(new GPoint(-94.86060333,36.45069885),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Jay Elementary School",'Jay=' + Jay.length); Jay[Jay.length] = createMarker(new GPoint(-94.86060333,36.45069885),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Jay High School",'Jay=' + Jay.length); Jay[Jay.length] = createMarker(new GPoint(-94.86060333,36.45069885),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Jay Middle School",'Jay=' + Jay.length); Kansas[Kansas.length] = createMarker(new GPoint(-94.78890228,36.20240021),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Kansas Elementary School",'Kansas=' + Kansas.length); Kansas[Kansas.length] = createMarker(new GPoint(-94.78890228,36.20240021),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Kansas High School",'Kansas=' + Kansas.length); Kansas[Kansas.length] = createMarker(new GPoint(-94.78890228,36.20240021),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Kansas Middle School",'Kansas=' + Kansas.length); Salina[Salina.length] = createMarker(new GPoint(-95.12010193,36.31290054),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Kenwood Elementary School",'Salina=' + Salina.length); Twin_Oaks[Twin_Oaks.length] = createMarker(new GPoint(-94.85399628,36.19559860),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Leach Elementary School",'Twin_Oaks=' + Twin_Oaks.length); Colcord[Colcord.length] = createMarker(new GPoint(-94.67790222,36.21239853),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Moseley Elementary School",'Colcord=' + Colcord.length); Oaks[Oaks.length] = createMarker(new GPoint(-94.85140228,36.16500092),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Oaks-mission Elementary School",'Oaks=' + Oaks.length); Oaks[Oaks.length] = createMarker(new GPoint(-94.85140228,36.16500092),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Oaks-mission High School",'Oaks=' + Oaks.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(Colcord); map.removeOverlays(Grove); map.removeOverlays(Jay); map.removeOverlays(Kansas); map.removeOverlays(Oaks); map.removeOverlays(Salina); map.removeOverlays(Twin_Oaks); 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(Colcord);map.removeOverlays(Colcord); map.removeOverlays(Grove); map.removeOverlays(Jay); map.removeOverlays(Kansas); map.removeOverlays(Oaks); map.removeOverlays(Salina); map.removeOverlays(Twin_Oaks); map.addOverlays(Colcord); centerByArray(Colcord, false, false); cntMarker += Colcord.length; map.addOverlays(Grove); centerByArray(Grove, false, false); cntMarker += Grove.length; map.addOverlays(Jay); centerByArray(Jay, false, false); cntMarker += Jay.length; map.addOverlays(Kansas); centerByArray(Kansas, false, false); cntMarker += Kansas.length; map.addOverlays(Oaks); centerByArray(Oaks, false, false); cntMarker += Oaks.length; map.addOverlays(Salina); centerByArray(Salina, false, false); cntMarker += Salina.length; map.addOverlays(Twin_Oaks); centerByArray(Twin_Oaks, false, false); cntMarker += Twin_Oaks.length; centerByArray(Colcord,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'); } }