function addMarkers() { mySelect = document.getElementById('selection'); Auburn = [];Bay_City = [];Essexville = [];Pinconning = [];Linwood = [];mySelect.options[mySelect.options.length] = new Option("Auburn schools",'all=Auburn'); mySelect.options[mySelect.options.length] = new Option("Bay City schools",'all=Bay_City'); mySelect.options[mySelect.options.length] = new Option("Essexville schools",'all=Essexville'); mySelect.options[mySelect.options.length] = new Option("Linwood schools",'all=Linwood'); mySelect.options[mySelect.options.length] = new Option("Pinconning schools",'all=Pinconning'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Auburn[Auburn.length] = createMarker(new GPoint(-84.07509613,43.60336304),"
",iconRd); mySelect.options[mySelect.options.length] = new Option("Auburn Elementary School",'Auburn=' + Auburn.length); Bay_City[Bay_City.length] = createMarker(new GPoint(-83.89801025,43.64117432),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Bangor Central School",'Bay_City=' + Bay_City.length); Bay_City[Bay_City.length] = createMarker(new GPoint(-83.91230774,43.65959549),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Bangor Lincoln School",'Bay_City=' + Bay_City.length); Bay_City[Bay_City.length] = createMarker(new GPoint(-83.89269257,43.65815353),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Bangor North Preschool And Day Care",'Bay_City=' + Bay_City.length); Bay_City[Bay_City.length] = createMarker(new GPoint(-83.92690277,43.62403870),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Bangor West Central School",'Bay_City=' + Bay_City.length); Bay_City[Bay_City.length] = createMarker(new GPoint(-83.89440918,43.61675262),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Bay County Psa Elementary School",'Bay_City=' + Bay_City.length); Essexville[Essexville.length] = createMarker(new GPoint(-83.83943939,43.61096191),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Bay-arenac Community High School",'Essexville=' + Essexville.length); Bay_City[Bay_City.length] = createMarker(new GPoint(-83.94606781,43.62017441),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Career Center",'Bay_City=' + Bay_City.length); Bay_City[Bay_City.length] = createMarker(new GPoint(-83.87445831,43.58926392),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Central High School",'Bay_City=' + Bay_City.length); Bay_City[Bay_City.length] = createMarker(new GPoint(-83.92089081,43.61673737),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Christa Mcauliffe Middle School",'Bay_City=' + Bay_City.length); Bay_City[Bay_City.length] = createMarker(new GPoint(-83.93185600,43.61730400),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Community Based - Early Childhood",'Bay_City=' + Bay_City.length); Essexville[Essexville.length] = createMarker(new GPoint(-83.83720398,43.60631943),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Cramer Junior High School",'Essexville=' + Essexville.length); Essexville[Essexville.length] = createMarker(new GPoint(-83.80165100,43.61603546),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Detention Center",'Essexville=' + Essexville.length); Bay_City[Bay_City.length] = createMarker(new GPoint(-83.86546400,43.60537500),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Eastside Middle School",'Bay_City=' + Bay_City.length); Auburn[Auburn.length] = createMarker(new GPoint(-84.13537598,43.60442352),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Forest Center",'Auburn=' + Auburn.length); Essexville[Essexville.length] = createMarker(new GPoint(-83.83720398,43.60506058),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Garber High School",'Essexville=' + Essexville.length); Pinconning[Pinconning.length] = createMarker(new GPoint(-84.08679962,43.79710007),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Garfield-fraser Elementary S",'Pinconning=' + Pinconning.length); Bay_City[Bay_City.length] = createMarker(new GPoint(-83.85314178,43.58013535),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Hampton Elementary School",'Bay_City=' + Bay_City.length); Bay_City[Bay_City.length] = createMarker(new GPoint(-83.90938568,43.60674667),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Handy Middle School",'Bay_City=' + Bay_City.length); Essexville[Essexville.length] = createMarker(new GPoint(-83.83966064,43.61189651),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Hughes Elementary School",'Essexville=' + Essexville.length); Bay_City[Bay_City.length] = createMarker(new GPoint(-83.92258453,43.61673737),"",iconGr); mySelect.options[mySelect.options.length] = new Option("John Glenn High School",'Bay_City=' + Bay_City.length); Bay_City[Bay_City.length] = createMarker(new GPoint(-83.90772247,43.59256363),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Kolb Elementary School",'Bay_City=' + Bay_City.length); Bay_City[Bay_City.length] = createMarker(new GPoint(-83.88967133,43.59421921),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Linsday Elementary School",'Bay_City=' + Bay_City.length); Linwood[Linwood.length] = createMarker(new GPoint(-83.96675110,43.73856354),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Linwood Elementary School",'Linwood=' + Linwood.length); Essexville[Essexville.length] = createMarker(new GPoint(-83.83477020,43.59410477),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Llc---bay Campus",'Essexville=' + Essexville.length); Bay_City[Bay_City.length] = createMarker(new GPoint(-83.88491400,43.59527000),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Macgregor Elementary School",'Bay_City=' + Bay_City.length); Bay_City[Bay_City.length] = createMarker(new GPoint(-83.93446350,43.57970428),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Mackensen Elementary School",'Bay_City=' + Bay_City.length); Bay_City[Bay_City.length] = createMarker(new GPoint(-83.95716095,43.60236359),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Mcalear-sawden Elementary School",'Bay_City=' + Bay_City.length); Pinconning[Pinconning.length] = createMarker(new GPoint(-84.10518646,43.85849380),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Mt. Forest Elementary School",'Pinconning=' + Pinconning.length); Pinconning[Pinconning.length] = createMarker(new GPoint(-83.96743774,43.85326385),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Pinconning Central Elementary School",'Pinconning=' + Pinconning.length); Pinconning[Pinconning.length] = createMarker(new GPoint(-83.96743774,43.85326385),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Pinconning Community Education",'Pinconning=' + Pinconning.length); Pinconning[Pinconning.length] = createMarker(new GPoint(-83.96743774,43.85326385),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Pinconning High School",'Pinconning=' + Pinconning.length); Pinconning[Pinconning.length] = createMarker(new GPoint(-83.96586400,43.85398500),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Pinconning Middle School",'Pinconning=' + Pinconning.length); Bay_City[Bay_City.length] = createMarker(new GPoint(-83.91011047,43.58242035),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Reigel Elementary School",'Bay_City=' + Bay_City.length); Bay_City[Bay_City.length] = createMarker(new GPoint(-83.91024780,43.58254623),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Riegel Elementary School",'Bay_City=' + Bay_City.length); Bay_City[Bay_City.length] = createMarker(new GPoint(-83.86238861,43.59209824),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Thomas Jefferson Elementary School",'Bay_City=' + Bay_City.length); Bay_City[Bay_City.length] = createMarker(new GPoint(-83.88092041,43.61682510),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Trombley Center",'Bay_City=' + Bay_City.length); Essexville[Essexville.length] = createMarker(new GPoint(-83.75420380,43.60883713),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Verellen Elementary School",'Essexville=' + Essexville.length); Essexville[Essexville.length] = createMarker(new GPoint(-83.81099701,43.60132980),"",iconRd); mySelect.options[mySelect.options.length] = new Option("W.r. Bush Elementary School",'Essexville=' + Essexville.length); Bay_City[Bay_City.length] = createMarker(new GPoint(-83.87091827,43.59379578),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Washington Elementary School",'Bay_City=' + Bay_City.length); Bay_City[Bay_City.length] = createMarker(new GPoint(-83.90438843,43.59965134),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Wenona Center",'Bay_City=' + Bay_City.length); Auburn[Auburn.length] = createMarker(new GPoint(-84.07769012,43.60363770),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Western High School",'Auburn=' + Auburn.length); Auburn[Auburn.length] = createMarker(new GPoint(-84.07769012,43.60363770),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Western Middle School",'Auburn=' + Auburn.length); Bay_City[Bay_City.length] = createMarker(new GPoint(-83.89392090,43.63232040),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Westside Alternative School",'Bay_City=' + Bay_City.length); Bay_City[Bay_City.length] = createMarker(new GPoint(-83.89370728,43.56252670),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Whittier Elementary School",'Bay_City=' + Bay_City.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(Auburn); map.removeOverlays(Bay_City); map.removeOverlays(Essexville); map.removeOverlays(Linwood); map.removeOverlays(Pinconning); 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(Auburn);map.removeOverlays(Auburn); map.removeOverlays(Bay_City); map.removeOverlays(Essexville); map.removeOverlays(Linwood); map.removeOverlays(Pinconning); map.addOverlays(Auburn); centerByArray(Auburn, false, false); cntMarker += Auburn.length; map.addOverlays(Bay_City); centerByArray(Bay_City, false, false); cntMarker += Bay_City.length; map.addOverlays(Essexville); centerByArray(Essexville, false, false); cntMarker += Essexville.length; map.addOverlays(Linwood); centerByArray(Linwood, false, false); cntMarker += Linwood.length; map.addOverlays(Pinconning); centerByArray(Pinconning, false, false); cntMarker += Pinconning.length; centerByArray(Auburn,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'); } }