function addMarkers() { mySelect = document.getElementById('selection'); Quincy = [];Golden = [];Camp_Point = [];Ursa = [];Liberty = [];Loraine = [];Mendon = [];Payson = [];mySelect.options[mySelect.options.length] = new Option("Camp Point schools",'all=Camp_Point'); mySelect.options[mySelect.options.length] = new Option("Golden schools",'all=Golden'); mySelect.options[mySelect.options.length] = new Option("Liberty schools",'all=Liberty'); mySelect.options[mySelect.options.length] = new Option("Loraine schools",'all=Loraine'); mySelect.options[mySelect.options.length] = new Option("Mendon schools",'all=Mendon'); mySelect.options[mySelect.options.length] = new Option("Payson schools",'all=Payson'); mySelect.options[mySelect.options.length] = new Option("Quincy schools",'all=Quincy'); mySelect.options[mySelect.options.length] = new Option("Ursa schools",'all=Ursa'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Quincy[Quincy.length] = createMarker(new GPoint(-91.40451813,39.93176270),"
",iconGr); mySelect.options[mySelect.options.length] = new Option("Adams County R S S P",'Quincy=' + Quincy.length); Quincy[Quincy.length] = createMarker(new GPoint(-91.33419800,39.93643951),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Adams County Youth Home",'Quincy=' + Quincy.length); Quincy[Quincy.length] = createMarker(new GPoint(-91.38401031,39.92093658),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Adams Elementary School",'Quincy=' + Quincy.length); Quincy[Quincy.length] = createMarker(new GPoint(-91.40312195,39.92785263),"",iconRd); mySelect.options[mySelect.options.length] = new Option("At Risk Pre-kindergarten",'Quincy=' + Quincy.length); Quincy[Quincy.length] = createMarker(new GPoint(-91.36762238,39.93146133),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Baldwin Intermediate",'Quincy=' + Quincy.length); Quincy[Quincy.length] = createMarker(new GPoint(-91.40312195,39.91558456),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Berrian School",'Quincy=' + Quincy.length); Quincy[Quincy.length] = createMarker(new GPoint(-91.40451813,39.93176270),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Cares Program High School",'Quincy=' + Quincy.length); Golden[Golden.length] = createMarker(new GPoint(-91.04219818,40.12620163),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Central 3-4 Middle School",'Golden=' + Golden.length); Camp_Point[Camp_Point.length] = createMarker(new GPoint(-91.10990143,40.01300049),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Central Elementary Grade School",'Camp_Point=' + Camp_Point.length); Camp_Point[Camp_Point.length] = createMarker(new GPoint(-91.06954193,40.03989029),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Central High School",'Camp_Point=' + Camp_Point.length); Camp_Point[Camp_Point.length] = createMarker(new GPoint(-91.02971649,40.07130814),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Central Junior High School",'Camp_Point=' + Camp_Point.length); Quincy[Quincy.length] = createMarker(new GPoint(-91.37741852,39.93025970),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Chaddock School",'Quincy=' + Quincy.length); Quincy[Quincy.length] = createMarker(new GPoint(-91.38360596,39.94406128),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Dewey Elementary School",'Quincy=' + Quincy.length); Quincy[Quincy.length] = createMarker(new GPoint(-91.36750031,39.94193649),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Ellington Elementary School",'Quincy=' + Quincy.length); Ursa[Ursa.length] = createMarker(new GPoint(-91.36631012,40.11467743),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Greenfield Elementary School",'Ursa=' + Ursa.length); Quincy[Quincy.length] = createMarker(new GPoint(-91.40312195,39.92785263),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Headstart School",'Quincy=' + Quincy.length); Quincy[Quincy.length] = createMarker(new GPoint(-91.40298462,39.92413712),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Irving Elementary School",'Quincy=' + Quincy.length); Liberty[Liberty.length] = createMarker(new GPoint(-91.10621643,39.88014221),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Liberty Elementary School",'Liberty=' + Liberty.length); Liberty[Liberty.length] = createMarker(new GPoint(-91.10621643,39.88014221),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Liberty High School",'Liberty=' + Liberty.length); Loraine[Loraine.length] = createMarker(new GPoint(-91.22290039,40.15319824),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Loraine Elementary School",'Loraine=' + Loraine.length); Quincy[Quincy.length] = createMarker(new GPoint(-91.37677002,39.93193817),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Madison School",'Quincy=' + Quincy.length); Mendon[Mendon.length] = createMarker(new GPoint(-91.28209686,40.08570099),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Mendon Elementary School",'Mendon=' + Mendon.length); Quincy[Quincy.length] = createMarker(new GPoint(-91.36491394,39.89743805),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Monroe Elementary School",'Quincy=' + Quincy.length); Quincy[Quincy.length] = createMarker(new GPoint(-91.40451813,39.93176270),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Ombudsman Program",'Quincy=' + Quincy.length); Quincy[Quincy.length] = createMarker(new GPoint(-91.39954376,39.92271423),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Ombudsman-career/life Skills Prg",'Quincy=' + Quincy.length); Quincy[Quincy.length] = createMarker(new GPoint(-91.36317444,39.92792511),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Quincy Area Voc Center",'Quincy=' + Quincy.length); Quincy[Quincy.length] = createMarker(new GPoint(-91.39386749,39.93165588),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Quincy Junior High School",'Quincy=' + Quincy.length); Quincy[Quincy.length] = createMarker(new GPoint(-91.36251068,39.93146133),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Quincy Senior High School",'Quincy=' + Quincy.length); Payson[Payson.length] = createMarker(new GPoint(-91.24905396,39.81761551),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Seymour Elementary School",'Payson=' + Payson.length); Payson[Payson.length] = createMarker(new GPoint(-91.24759674,39.81633759),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Seymour High School",'Payson=' + Payson.length); Mendon[Mendon.length] = createMarker(new GPoint(-91.28209686,40.08570099),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Unity High School",'Mendon=' + Mendon.length); Mendon[Mendon.length] = createMarker(new GPoint(-91.28209686,40.08570099),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Unity Middle School",'Mendon=' + Mendon.length); Quincy[Quincy.length] = createMarker(new GPoint(-91.40322113,39.94833755),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Washington Elementary School",'Quincy=' + Quincy.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(Camp_Point); map.removeOverlays(Golden); map.removeOverlays(Liberty); map.removeOverlays(Loraine); map.removeOverlays(Mendon); map.removeOverlays(Payson); map.removeOverlays(Quincy); map.removeOverlays(Ursa); 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(Quincy);map.removeOverlays(Camp_Point); map.removeOverlays(Golden); map.removeOverlays(Liberty); map.removeOverlays(Loraine); map.removeOverlays(Mendon); map.removeOverlays(Payson); map.removeOverlays(Quincy); map.removeOverlays(Ursa); map.addOverlays(Camp_Point); centerByArray(Camp_Point, false, false); cntMarker += Camp_Point.length; map.addOverlays(Golden); centerByArray(Golden, false, false); cntMarker += Golden.length; map.addOverlays(Liberty); centerByArray(Liberty, false, false); cntMarker += Liberty.length; map.addOverlays(Loraine); centerByArray(Loraine, false, false); cntMarker += Loraine.length; map.addOverlays(Mendon); centerByArray(Mendon, false, false); cntMarker += Mendon.length; map.addOverlays(Payson); centerByArray(Payson, false, false); cntMarker += Payson.length; map.addOverlays(Quincy); centerByArray(Quincy, false, false); cntMarker += Quincy.length; map.addOverlays(Ursa); centerByArray(Ursa, false, false); cntMarker += Ursa.length; centerByArray(Quincy,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'); } }