function addMarkers() { mySelect = document.getElementById('selection'); Jackson = [];Lost_Creek = [];Rousseau = [];mySelect.options[mySelect.options.length] = new Option("Jackson schools",'all=Jackson'); mySelect.options[mySelect.options.length] = new Option("Lost Creek schools",'all=Lost_Creek'); mySelect.options[mySelect.options.length] = new Option("Rousseau schools",'all=Rousseau'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Jackson[Jackson.length] = createMarker(new GPoint(-83.38403320,37.55257034),"
Breathitt Co Juvenile Detention Center Alt
Hwy 30 W
Jackson, KY 41339

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Breathitt Co Juvenile Detention Center Alt",'Jackson=' + Jackson.length); Jackson[Jackson.length] = createMarker(new GPoint(-83.34139252,37.53151703),"
Breathitt County Day Treatment Ctr Alt
3875 Highway 15 S
Jackson, KY 41339

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Breathitt County Day Treatment Ctr Alt",'Jackson=' + Jackson.length); Jackson[Jackson.length] = createMarker(new GPoint(-83.38452148,37.55558777),"
Breathitt County High School
2307 Bobcat Lane
Jackson, KY 41339

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Breathitt County High School",'Jackson=' + Jackson.length); Jackson[Jackson.length] = createMarker(new GPoint(-83.41327667,37.52772141),"
Cadet Leadership & Education Alt Program High School
2665 Hwy 30 W
Jackson, KY 41339

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Cadet Leadership & Education Alt Program High School",'Jackson=' + Jackson.length); Jackson[Jackson.length] = createMarker(new GPoint(-83.37950897,37.55332565),"
Jackson City School
940 Highland Ave
Jackson, KY 41339

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Jackson City School",'Jackson=' + Jackson.length); Jackson[Jackson.length] = createMarker(new GPoint(-83.37168121,37.56021881),"
L B J Elementary School
90 L B J Road
Jackson, KY 41339

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("L B J Elementary School",'Jackson=' + Jackson.length); Lost_Creek[Lost_Creek.length] = createMarker(new GPoint(-83.32674408,37.46613312),"
Marie Roberts-caney Elementary School
115 Redskin Run
Lost Creek, KY 41348

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Marie Roberts-caney Elementary School",'Lost_Creek=' + Lost_Creek.length); Rousseau[Rousseau.length] = createMarker(new GPoint(-83.37390137,37.53850174),"
Rousseau Elementary School
13456 Hwy 30 East
Rousseau, KY 41366

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Rousseau Elementary School",'Rousseau=' + Rousseau.length); Jackson[Jackson.length] = createMarker(new GPoint(-83.37086487,37.56056213),"
Sebastian Middle School
244 L B J Road
Jackson, KY 41339

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Sebastian Middle School",'Jackson=' + Jackson.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(Jackson); map.removeOverlays(Lost_Creek); map.removeOverlays(Rousseau); 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(Jackson);map.removeOverlays(Jackson); map.removeOverlays(Lost_Creek); map.removeOverlays(Rousseau); map.addOverlays(Jackson); centerByArray(Jackson, false, false); cntMarker += Jackson.length; map.addOverlays(Lost_Creek); centerByArray(Lost_Creek, false, false); cntMarker += Lost_Creek.length; map.addOverlays(Rousseau); centerByArray(Rousseau, false, false); cntMarker += Rousseau.length; centerByArray(Jackson,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'); } }