function addMarkers() { mySelect = document.getElementById('selection'); Middleville = [];Hastings = [];Delton = [];Nashville = [];Lake_Odessa = [];Woodland = [];Bellevue = [];mySelect.options[mySelect.options.length] = new Option("Bellevue schools",'all=Bellevue'); mySelect.options[mySelect.options.length] = new Option("Delton schools",'all=Delton'); mySelect.options[mySelect.options.length] = new Option("Hastings schools",'all=Hastings'); mySelect.options[mySelect.options.length] = new Option("Lake Odessa schools",'all=Lake_Odessa'); mySelect.options[mySelect.options.length] = new Option("Middleville schools",'all=Middleville'); mySelect.options[mySelect.options.length] = new Option("Nashville schools",'all=Nashville'); mySelect.options[mySelect.options.length] = new Option("Woodland schools",'all=Woodland'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Middleville[Middleville.length] = createMarker(new GPoint(-85.47213745,42.71086121),"
Alternative Education
507 West Main Street
Middleville, MI 49333

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Alternative Education",'Middleville=' + Middleville.length); Hastings[Hastings.length] = createMarker(new GPoint(-85.29507446,42.66103745),"
Barry Isd Special Education
555 W. Woodlawn Avenue
Hastings, MI 49058

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Barry Isd Special Education",'Hastings=' + Hastings.length); Hastings[Hastings.length] = createMarker(new GPoint(-85.29059601,42.64493942),"
Central Elementary School
509 S. Broadway Street
Hastings, MI 49058

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Central Elementary School",'Hastings=' + Hastings.length); Delton[Delton.length] = createMarker(new GPoint(-85.40834808,42.50257492),"
Delton Kellogg Elementary School
327 N. Grove Street
Delton, MI 49046

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Delton Kellogg Elementary School",'Delton=' + Delton.length); Delton[Delton.length] = createMarker(new GPoint(-85.40857697,42.50313568),"
Delton-kellogg Alternative H.s.
327 N. Grove Street
Delton, MI 49046

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Delton-kellogg Alternative H.s.",'Delton=' + Delton.length); Delton[Delton.length] = createMarker(new GPoint(-85.39969635,42.51039886),"
Delton-kellogg Elementary School
327 N. Grove Street
Delton, MI 49046

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Delton-kellogg Elementary School",'Delton=' + Delton.length); Delton[Delton.length] = createMarker(new GPoint(-85.40857697,42.50313568),"
Delton-kellogg High School
327 N. Grove Street
Delton, MI 49046

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Delton-kellogg High School",'Delton=' + Delton.length); Delton[Delton.length] = createMarker(new GPoint(-85.40857697,42.50313568),"
Delton-kellogg Middle School
327 N. Grove Street
Delton, MI 49046

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Delton-kellogg Middle School",'Delton=' + Delton.length); Nashville[Nashville.length] = createMarker(new GPoint(-85.09767914,42.59904099),"
Fuller Street Elementary School
251 Fuller Street
Nashville, MI 49073

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Fuller Street Elementary School",'Nashville=' + Nashville.length); Hastings[Hastings.length] = createMarker(new GPoint(-85.29385376,42.63954163),"
Hastings High School
520 W. South Street
Hastings, MI 49058

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Hastings High School",'Hastings=' + Hastings.length); Hastings[Hastings.length] = createMarker(new GPoint(-85.28887939,42.64413452),"
Hastings Middle School
232 W. Grand Street
Hastings, MI 49058

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Hastings Middle School",'Hastings=' + Hastings.length); Nashville[Nashville.length] = createMarker(new GPoint(-85.09091949,42.60528564),"
Kellogg Education Center
324 Queen Street
Nashville, MI 49073

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Kellogg Education Center",'Nashville=' + Nashville.length); Lake_Odessa[Lake_Odessa.length] = createMarker(new GPoint(-85.11375427,42.75967026),"
Lakewood High School
7223 Velte Road
Lake Odessa, MI 48849

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Lakewood High School",'Lake_Odessa=' + Lake_Odessa.length); Woodland[Woodland.length] = createMarker(new GPoint(-85.15131378,42.78473282),"
Lakewood Learning Center (leap)
223 W. Broadway
Woodland, MI 48897

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Lakewood Learning Center (leap)",'Woodland=' + Woodland.length); Woodland[Woodland.length] = createMarker(new GPoint(-85.12059784,42.75608063),"
Lakewood Middle School
8669 E. Brown Road
Woodland, MI 48897

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Lakewood Middle School",'Woodland=' + Woodland.length); Middleville[Middleville.length] = createMarker(new GPoint(-85.47756958,42.71113586),"
Lee Elementary School
840 West Main Street
Middleville, MI 49333

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Lee Elementary School",'Middleville=' + Middleville.length); Middleville[Middleville.length] = createMarker(new GPoint(-85.47214508,42.71086121),"
Mcfall Elementary School
509 W. Main Street
Middleville, MI 49333

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Mcfall Elementary School",'Middleville=' + Middleville.length); Hastings[Hastings.length] = createMarker(new GPoint(-85.28147125,42.65631866),"
Northeastern Elementary School
519 E. Grant Street
Hastings, MI 49058

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Northeastern Elementary School",'Hastings=' + Hastings.length); Middleville[Middleville.length] = createMarker(new GPoint(-85.48648834,42.70623398),"
Page Elementary School
3675 Bender Road
Middleville, MI 49333

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Page Elementary School",'Middleville=' + Middleville.length); Bellevue[Bellevue.length] = createMarker(new GPoint(-85.17349243,42.49328613),"
Pleasantview Elementary School
3754 Lacey Road
Bellevue, MI 49021

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Pleasantview Elementary School",'Bellevue=' + Bellevue.length); Hastings[Hastings.length] = createMarker(new GPoint(-85.28157806,42.63876724),"
Southeastern Elementary School
1300 S. East Street
Hastings, MI 49058

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Southeastern Elementary School",'Hastings=' + Hastings.length); Hastings[Hastings.length] = createMarker(new GPoint(-85.27083588,42.63204575),"
Star Elementary School
1900 Star School Road
Hastings, MI 49058

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Star Elementary School",'Hastings=' + Hastings.length); Middleville[Middleville.length] = createMarker(new GPoint(-85.48648834,42.70904922),"
Thornapple Kellogg High School
3885 Bender Road
Middleville, MI 49333

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Thornapple Kellogg High School",'Middleville=' + Middleville.length); Middleville[Middleville.length] = createMarker(new GPoint(-85.49397278,42.71086121),"
Thornapple Kellogg Middle School
10375 Green Lake Rd
Middleville, MI 49333

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Thornapple Kellogg Middle School",'Middleville=' + Middleville.length); Woodland[Woodland.length] = createMarker(new GPoint(-85.13780975,42.72697830),"
Woodland Elementary School
223 W. Broadway Street
Woodland, MI 48897

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Woodland Elementary School",'Woodland=' + Woodland.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(Bellevue); map.removeOverlays(Delton); map.removeOverlays(Hastings); map.removeOverlays(Lake_Odessa); map.removeOverlays(Middleville); map.removeOverlays(Nashville); map.removeOverlays(Woodland); 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(Middleville);map.removeOverlays(Bellevue); map.removeOverlays(Delton); map.removeOverlays(Hastings); map.removeOverlays(Lake_Odessa); map.removeOverlays(Middleville); map.removeOverlays(Nashville); map.removeOverlays(Woodland); map.addOverlays(Bellevue); centerByArray(Bellevue, false, false); cntMarker += Bellevue.length; map.addOverlays(Delton); centerByArray(Delton, false, false); cntMarker += Delton.length; map.addOverlays(Hastings); centerByArray(Hastings, false, false); cntMarker += Hastings.length; map.addOverlays(Lake_Odessa); centerByArray(Lake_Odessa, false, false); cntMarker += Lake_Odessa.length; map.addOverlays(Middleville); centerByArray(Middleville, false, false); cntMarker += Middleville.length; map.addOverlays(Nashville); centerByArray(Nashville, false, false); cntMarker += Nashville.length; map.addOverlays(Woodland); centerByArray(Woodland, false, false); cntMarker += Woodland.length; centerByArray(Middleville,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'); } }