function addMarkers() { mySelect = document.getElementById('selection'); Pineville = [];Middlesboro = [];Frakes = [];Fourmile = [];Stoney_Fork = [];mySelect.options[mySelect.options.length] = new Option("Fourmile schools",'all=Fourmile'); mySelect.options[mySelect.options.length] = new Option("Frakes schools",'all=Frakes'); mySelect.options[mySelect.options.length] = new Option("Middlesboro schools",'all=Middlesboro'); mySelect.options[mySelect.options.length] = new Option("Pineville schools",'all=Pineville'); mySelect.options[mySelect.options.length] = new Option("Stoney Fork schools",'all=Stoney_Fork'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Pineville[Pineville.length] = createMarker(new GPoint(-83.68859863,36.72840118),"
Bell Central School Center
Rr 1 Box 87-c
Pineville, KY 40977

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Bell Central School Center",'Pineville=' + Pineville.length); Pineville[Pineville.length] = createMarker(new GPoint(-83.69228900,36.76473000),"
Bell County High School
Rr 1 Box 88
Pineville, KY 40977

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Bell County High School",'Pineville=' + Pineville.length); Middlesboro[Middlesboro.length] = createMarker(new GPoint(-83.71004486,36.61159897),"
East End Elementary School
502 Ashbury Ave
Middlesboro, KY 40965

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("East End Elementary School",'Middlesboro=' + Middlesboro.length); Frakes[Frakes.length] = createMarker(new GPoint(-83.92807007,36.64252853),"
Frakes School Center
Hwy 190
Frakes, KY 40940

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Frakes School Center",'Frakes=' + Frakes.length); Fourmile[Fourmile.length] = createMarker(new GPoint(-83.74172974,36.79344177),"
Lone Jack School Center
Hwy 25 E
Fourmile, KY 40939

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Lone Jack School Center",'Fourmile=' + Fourmile.length); Middlesboro[Middlesboro.length] = createMarker(new GPoint(-83.71441650,36.60863113),"
Middlesboro Central Alternative High School
220 N 20th St
Middlesboro, KY 40965

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Middlesboro Central Alternative High School",'Middlesboro=' + Middlesboro.length); Middlesboro[Middlesboro.length] = createMarker(new GPoint(-83.70962524,36.60760117),"
Middlesboro High School
4404 Cumberland Ave
Middlesboro, KY 40965

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Middlesboro High School",'Middlesboro=' + Middlesboro.length); Middlesboro[Middlesboro.length] = createMarker(new GPoint(-83.70962524,36.60760117),"
Middlesboro Middle School
4400 Cumberland Ave
Middlesboro, KY 40965

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Middlesboro Middle School",'Middlesboro=' + Middlesboro.length); Pineville[Pineville.length] = createMarker(new GPoint(-83.68859863,36.72840118),"
Page School Center
Rr 1 Box 174
Pineville, KY 40977

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Page School Center",'Pineville=' + Pineville.length); Pineville[Pineville.length] = createMarker(new GPoint(-83.69783783,36.76297760),"
Pineville Elementary School
401 Virginia Ave
Pineville, KY 40977

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Pineville Elementary School",'Pineville=' + Pineville.length); Pineville[Pineville.length] = createMarker(new GPoint(-83.69783783,36.76297760),"
Pineville High School
401 Virginia Ave
Pineville, KY 40977

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Pineville High School",'Pineville=' + Pineville.length); Pineville[Pineville.length] = createMarker(new GPoint(-83.65280151,37.32870102),"
Recovery Alt School/day Treatment
Rt 7 Box 198e
Pineville, KY 40977

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Recovery Alt School/day Treatment",'Pineville=' + Pineville.length); Stoney_Fork[Stoney_Fork.length] = createMarker(new GPoint(-83.52770233,36.88059998),"
Rightfork School Center
Hc 86 Box 1250
Stoney Fork, KY 40988

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Rightfork School Center",'Stoney_Fork=' + Stoney_Fork.length); Middlesboro[Middlesboro.length] = createMarker(new GPoint(-83.73623657,36.60554504),"
West End Elementary School
3400 W Cumberland Ave
Middlesboro, KY 40965

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("West End Elementary School",'Middlesboro=' + Middlesboro.length); Middlesboro[Middlesboro.length] = createMarker(new GPoint(-83.77709961,36.58969879),"
Yellow Creek School Center
4840 West Cumberland Avenue
Middlesboro, KY 40965

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Yellow Creek School Center",'Middlesboro=' + Middlesboro.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(Fourmile); map.removeOverlays(Frakes); map.removeOverlays(Middlesboro); map.removeOverlays(Pineville); map.removeOverlays(Stoney_Fork); 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(Pineville);map.removeOverlays(Fourmile); map.removeOverlays(Frakes); map.removeOverlays(Middlesboro); map.removeOverlays(Pineville); map.removeOverlays(Stoney_Fork); map.addOverlays(Fourmile); centerByArray(Fourmile, false, false); cntMarker += Fourmile.length; map.addOverlays(Frakes); centerByArray(Frakes, false, false); cntMarker += Frakes.length; map.addOverlays(Middlesboro); centerByArray(Middlesboro, false, false); cntMarker += Middlesboro.length; map.addOverlays(Pineville); centerByArray(Pineville, false, false); cntMarker += Pineville.length; map.addOverlays(Stoney_Fork); centerByArray(Stoney_Fork, false, false); cntMarker += Stoney_Fork.length; centerByArray(Pineville,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'); } }