function addMarkers() { mySelect = document.getElementById('selection'); Huntingdon = [];Bruceton = [];Clarksburg = [];Mckenzie = [];Trezevant = [];Atwood = [];Mclemoresville = [];mySelect.options[mySelect.options.length] = new Option("Atwood schools",'all=Atwood'); mySelect.options[mySelect.options.length] = new Option("Bruceton schools",'all=Bruceton'); mySelect.options[mySelect.options.length] = new Option("Clarksburg schools",'all=Clarksburg'); mySelect.options[mySelect.options.length] = new Option("Huntingdon schools",'all=Huntingdon'); mySelect.options[mySelect.options.length] = new Option("Mckenzie schools",'all=Mckenzie'); mySelect.options[mySelect.options.length] = new Option("Mclemoresville schools",'all=Mclemoresville'); mySelect.options[mySelect.options.length] = new Option("Trezevant schools",'all=Trezevant'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Huntingdon[Huntingdon.length] = createMarker(new GPoint(-88.43936920,36.01937103),"
",iconGr); mySelect.options[mySelect.options.length] = new Option("Carroll County Special Learning Center",'Huntingdon=' + Huntingdon.length); Huntingdon[Huntingdon.length] = createMarker(new GPoint(-88.38517761,36.00449371),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Carroll County Technical Center",'Huntingdon=' + Huntingdon.length); Bruceton[Bruceton.length] = createMarker(new GPoint(-88.26069641,36.04280090),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Central Elementary School",'Bruceton=' + Bruceton.length); Bruceton[Bruceton.length] = createMarker(new GPoint(-88.26069641,36.04280090),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Central High School",'Bruceton=' + Bruceton.length); Clarksburg[Clarksburg.length] = createMarker(new GPoint(-88.35949707,35.90047836),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Clarksburg School",'Clarksburg=' + Clarksburg.length); Huntingdon[Huntingdon.length] = createMarker(new GPoint(-88.38504028,36.01138306),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Huntingdon High School",'Huntingdon=' + Huntingdon.length); Huntingdon[Huntingdon.length] = createMarker(new GPoint(-88.42138672,36.00576782),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Huntingdon Middle School",'Huntingdon=' + Huntingdon.length); Huntingdon[Huntingdon.length] = createMarker(new GPoint(-88.43325043,36.00856400),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Huntingdon Primary School",'Huntingdon=' + Huntingdon.length); Mckenzie[Mckenzie.length] = createMarker(new GPoint(-88.52212524,36.14346313),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Mckenzie Elementary School",'Mckenzie=' + Mckenzie.length); Mckenzie[Mckenzie.length] = createMarker(new GPoint(-88.48577118,36.13635254),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Mckenzie High School",'Mckenzie=' + Mckenzie.length); Mckenzie[Mckenzie.length] = createMarker(new GPoint(-88.52111053,36.13823700),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Mckenzie Middle School",'Mckenzie=' + Mckenzie.length); Trezevant[Trezevant.length] = createMarker(new GPoint(-88.61820221,36.01750183),"",iconRd); mySelect.options[mySelect.options.length] = new Option("West Carroll Elementary School",'Trezevant=' + Trezevant.length); Atwood[Atwood.length] = createMarker(new GPoint(-88.67846680,35.97315979),"",iconGr); mySelect.options[mySelect.options.length] = new Option("West Carroll Junior / Senior High School",'Atwood=' + Atwood.length); Mclemoresville[Mclemoresville.length] = createMarker(new GPoint(-88.57434845,35.98775101),"",iconRd); mySelect.options[mySelect.options.length] = new Option("West Carroll Primary",'Mclemoresville=' + Mclemoresville.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(Atwood); map.removeOverlays(Bruceton); map.removeOverlays(Clarksburg); map.removeOverlays(Huntingdon); map.removeOverlays(Mckenzie); map.removeOverlays(Mclemoresville); map.removeOverlays(Trezevant); 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(Huntingdon);map.removeOverlays(Atwood); map.removeOverlays(Bruceton); map.removeOverlays(Clarksburg); map.removeOverlays(Huntingdon); map.removeOverlays(Mckenzie); map.removeOverlays(Mclemoresville); map.removeOverlays(Trezevant); map.addOverlays(Atwood); centerByArray(Atwood, false, false); cntMarker += Atwood.length; map.addOverlays(Bruceton); centerByArray(Bruceton, false, false); cntMarker += Bruceton.length; map.addOverlays(Clarksburg); centerByArray(Clarksburg, false, false); cntMarker += Clarksburg.length; map.addOverlays(Huntingdon); centerByArray(Huntingdon, false, false); cntMarker += Huntingdon.length; map.addOverlays(Mckenzie); centerByArray(Mckenzie, false, false); cntMarker += Mckenzie.length; map.addOverlays(Mclemoresville); centerByArray(Mclemoresville, false, false); cntMarker += Mclemoresville.length; map.addOverlays(Trezevant); centerByArray(Trezevant, false, false); cntMarker += Trezevant.length; centerByArray(Huntingdon,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'); } }