function addMarkers() { mySelect = document.getElementById('selection'); Lebanon = [];Zionsville = [];Jamestown = [];Sheridan = [];Thorntown = [];Whitestown = [];mySelect.options[mySelect.options.length] = new Option("Jamestown schools",'all=Jamestown'); mySelect.options[mySelect.options.length] = new Option("Lebanon schools",'all=Lebanon'); mySelect.options[mySelect.options.length] = new Option("Sheridan schools",'all=Sheridan'); mySelect.options[mySelect.options.length] = new Option("Thorntown schools",'all=Thorntown'); mySelect.options[mySelect.options.length] = new Option("Whitestown schools",'all=Whitestown'); mySelect.options[mySelect.options.length] = new Option("Zionsville schools",'all=Zionsville'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Lebanon[Lebanon.length] = createMarker(new GPoint(-86.46447754,40.05006409),"
Central Elementary School
515 E Williams St
Lebanon, IN 46052

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Central Elementary School",'Lebanon=' + Lebanon.length); Zionsville[Zionsville.length] = createMarker(new GPoint(-86.26715088,39.95455170),"
Eagle Elementary School
350 N 6th St
Zionsville, IN 46077

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Eagle Elementary School",'Zionsville=' + Zionsville.length); Jamestown[Jamestown.length] = createMarker(new GPoint(-86.62911987,39.92749023),"
Granville Wells Elementary School
5046 S Sr 75
Jamestown, IN 46147

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Granville Wells Elementary School",'Jamestown=' + Jamestown.length); Lebanon[Lebanon.length] = createMarker(new GPoint(-86.47727203,40.05924988),"
Harney Elementary School
1500 N Garfield St
Lebanon, IN 46052

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Harney Elementary School",'Lebanon=' + Lebanon.length); Lebanon[Lebanon.length] = createMarker(new GPoint(-86.46791840,40.03964996),"
Hattie B Stokes Elementary School
1005 Hendricks Dr
Lebanon, IN 46052

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Hattie B Stokes Elementary School",'Lebanon=' + Lebanon.length); Lebanon[Lebanon.length] = createMarker(new GPoint(-86.46028137,40.06096649),"
Lebanon Middle School
1800 N Grant St
Lebanon, IN 46052

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Lebanon Middle School",'Lebanon=' + Lebanon.length); Lebanon[Lebanon.length] = createMarker(new GPoint(-86.46410370,40.05723572),"
Lebanon Senior High School
510 Essex Dr
Lebanon, IN 46052

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Lebanon Senior High School",'Lebanon=' + Lebanon.length); Sheridan[Sheridan.length] = createMarker(new GPoint(-86.35691071,40.17093277),"
Marion Elementary School
6070 N 900 E
Sheridan, IN 46069

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Marion Elementary School",'Sheridan=' + Sheridan.length); Lebanon[Lebanon.length] = createMarker(new GPoint(-86.39599609,39.99681473),"
Perry Worth Elementary School
3900 E 300 S
Lebanon, IN 46052

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Perry Worth Elementary School",'Lebanon=' + Lebanon.length); Zionsville[Zionsville.length] = createMarker(new GPoint(-86.28408051,39.97317505),"
Pleasant View Lower Elementary School
4700 S 975 E
Zionsville, IN 46077

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Pleasant View Lower Elementary School",'Zionsville=' + Zionsville.length); Zionsville[Zionsville.length] = createMarker(new GPoint(-86.28404236,39.97214508),"
Pleasant View Upper Elementary School
4800 S 975 E
Zionsville, IN 46077

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Pleasant View Upper Elementary School",'Zionsville=' + Zionsville.length); Zionsville[Zionsville.length] = createMarker(new GPoint(-86.37513733,39.96036148),"
Stonegate Elementary School
7312 W Stonegate Dr
Zionsville, IN 46077

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Stonegate Elementary School",'Zionsville=' + Zionsville.length); Thorntown[Thorntown.length] = createMarker(new GPoint(-86.60817719,40.12483597),"
Thorntown Elementary School
200 Mill St
Thorntown, IN 46071

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Thorntown Elementary School",'Thorntown=' + Thorntown.length); Zionsville[Zionsville.length] = createMarker(new GPoint(-86.26168060,39.95075989),"
Union Elementary School
9275 E Sr 32
Zionsville, IN 46077

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Union Elementary School",'Zionsville=' + Zionsville.length); Thorntown[Thorntown.length] = createMarker(new GPoint(-86.60665894,40.12939835),"
Western Boone Junior Senior High School
1205 N Sr 75
Thorntown, IN 46071

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Western Boone Junior Senior High School",'Thorntown=' + Thorntown.length); Zionsville[Zionsville.length] = createMarker(new GPoint(-86.27160645,39.96168900),"
Zionsville Community High School
1000 Mulberry St
Zionsville, IN 46077

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Zionsville Community High School",'Zionsville=' + Zionsville.length); Zionsville[Zionsville.length] = createMarker(new GPoint(-86.27897644,39.95149612),"
Zionsville Lower Middle School
900 N Ford Rd
Zionsville, IN 46077

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Zionsville Lower Middle School",'Zionsville=' + Zionsville.length); Zionsville[Zionsville.length] = createMarker(new GPoint(-86.27897644,39.95149612),"
Zionsville Middle School
900 N Ford Rd
Zionsville, IN 46077

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Zionsville Middle School",'Zionsville=' + Zionsville.length); Whitestown[Whitestown.length] = createMarker(new GPoint(-86.34593100,39.97814200),"
Zionsville West Middle School
5555 S 650 E
Whitestown, IN 46075

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Zionsville West Middle School",'Whitestown=' + Whitestown.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(Jamestown); map.removeOverlays(Lebanon); map.removeOverlays(Sheridan); map.removeOverlays(Thorntown); map.removeOverlays(Whitestown); map.removeOverlays(Zionsville); 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(Lebanon);map.removeOverlays(Jamestown); map.removeOverlays(Lebanon); map.removeOverlays(Sheridan); map.removeOverlays(Thorntown); map.removeOverlays(Whitestown); map.removeOverlays(Zionsville); map.addOverlays(Jamestown); centerByArray(Jamestown, false, false); cntMarker += Jamestown.length; map.addOverlays(Lebanon); centerByArray(Lebanon, false, false); cntMarker += Lebanon.length; map.addOverlays(Sheridan); centerByArray(Sheridan, false, false); cntMarker += Sheridan.length; map.addOverlays(Thorntown); centerByArray(Thorntown, false, false); cntMarker += Thorntown.length; map.addOverlays(Whitestown); centerByArray(Whitestown, false, false); cntMarker += Whitestown.length; map.addOverlays(Zionsville); centerByArray(Zionsville, false, false); cntMarker += Zionsville.length; centerByArray(Lebanon,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'); } }