function addMarkers() { mySelect = document.getElementById('selection'); Brunswick = [];Medina = [];Wadsworth = [];Spencer = [];Lodi = [];Seville = [];Hinckley = [];Litchfield = [];Sharon_Center = [];Westfield_Center = [];mySelect.options[mySelect.options.length] = new Option("Brunswick schools",'all=Brunswick'); mySelect.options[mySelect.options.length] = new Option("Hinckley schools",'all=Hinckley'); mySelect.options[mySelect.options.length] = new Option("Litchfield schools",'all=Litchfield'); mySelect.options[mySelect.options.length] = new Option("Lodi schools",'all=Lodi'); mySelect.options[mySelect.options.length] = new Option("Medina schools",'all=Medina'); mySelect.options[mySelect.options.length] = new Option("Seville schools",'all=Seville'); mySelect.options[mySelect.options.length] = new Option("Sharon Center schools",'all=Sharon_Center'); mySelect.options[mySelect.options.length] = new Option("Spencer schools",'all=Spencer'); mySelect.options[mySelect.options.length] = new Option("Wadsworth schools",'all=Wadsworth'); mySelect.options[mySelect.options.length] = new Option("Westfield Center schools",'all=Westfield_Center'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Brunswick[Brunswick.length] = createMarker(new GPoint(-81.82569885,41.22359085),"
",iconRd); mySelect.options[mySelect.options.length] = new Option("Applewood Elementary School",'Brunswick=' + Brunswick.length); Brunswick[Brunswick.length] = createMarker(new GPoint(-81.81389618,41.23839188),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Brunswick High School",'Brunswick=' + Brunswick.length); Brunswick[Brunswick.length] = createMarker(new GPoint(-81.82524872,41.26892471),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Brunswick Memorial Elementary School",'Brunswick=' + Brunswick.length); Medina[Medina.length] = createMarker(new GPoint(-81.92527771,41.19052124),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Buckeye High School",'Medina=' + Medina.length); Medina[Medina.length] = createMarker(new GPoint(-81.92527771,41.19154739),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Buckeye Junior High School",'Medina=' + Medina.length); Brunswick[Brunswick.length] = createMarker(new GPoint(-81.81301117,41.23839188),"",iconRd); mySelect.options[mySelect.options.length] = new Option("C R Towslee Elementary School",'Brunswick=' + Brunswick.length); Wadsworth[Wadsworth.length] = createMarker(new GPoint(-81.72939301,41.02439117),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Central Intermediate School",'Wadsworth=' + Wadsworth.length); Spencer[Spencer.length] = createMarker(new GPoint(-82.02448273,41.10228348),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Chatham Elementary School",'Spencer=' + Spencer.length); Medina[Medina.length] = createMarker(new GPoint(-81.85885620,41.14420319),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Claggett Middle School",'Medina=' + Medina.length); Lodi[Lodi.length] = createMarker(new GPoint(-81.96577454,41.04084396),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Cloverleaf High School",'Lodi=' + Lodi.length); Seville[Seville.length] = createMarker(new GPoint(-81.96170044,41.04149628),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Cloverleaf Middle School",'Seville=' + Seville.length); Brunswick[Brunswick.length] = createMarker(new GPoint(-81.78501892,41.26850510),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Crestview Elementary School",'Brunswick=' + Brunswick.length); Brunswick[Brunswick.length] = createMarker(new GPoint(-81.84123993,41.23410416),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Edwards Middle School",'Brunswick=' + Brunswick.length); Medina[Medina.length] = createMarker(new GPoint(-81.87006378,41.12774277),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Ella Canavan Elementary School",'Medina=' + Medina.length); Wadsworth[Wadsworth.length] = createMarker(new GPoint(-81.72612000,41.01303864),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Franklin Elementary School",'Wadsworth=' + Wadsworth.length); Medina[Medina.length] = createMarker(new GPoint(-81.86334991,41.13742447),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Garfield Elementary School",'Medina=' + Medina.length); Medina[Medina.length] = createMarker(new GPoint(-81.86401900,41.14032000),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Granger Elementary School",'Medina=' + Medina.length); Medina[Medina.length] = createMarker(new GPoint(-81.85719299,41.11354828),"",iconRd); mySelect.options[mySelect.options.length] = new Option("H G Blake Elementary School",'Medina=' + Medina.length); Medina[Medina.length] = createMarker(new GPoint(-81.84876251,41.12573242),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Heritage Elementary School",'Medina=' + Medina.length); Brunswick[Brunswick.length] = createMarker(new GPoint(-81.85308838,41.24574280),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Hickory Ridge Elementary School",'Brunswick=' + Brunswick.length); Medina[Medina.length] = createMarker(new GPoint(-81.74198151,41.16927338),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Highland High School",'Medina=' + Medina.length); Medina[Medina.length] = createMarker(new GPoint(-81.74188232,41.16746902),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Highland Middle School",'Medina=' + Medina.length); Hinckley[Hinckley.length] = createMarker(new GPoint(-81.74283600,41.23836136),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Hinckley Elementary School",'Hinckley=' + Hinckley.length); Brunswick[Brunswick.length] = createMarker(new GPoint(-81.81511688,41.22349167),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Huntington Elementary School",'Brunswick=' + Brunswick.length); Wadsworth[Wadsworth.length] = createMarker(new GPoint(-81.73851776,41.02553558),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Isham Memorial Elementary School",'Wadsworth=' + Wadsworth.length); Medina[Medina.length] = createMarker(new GPoint(-81.93496704,41.10017776),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Lafayette Elementary School",'Medina=' + Medina.length); Wadsworth[Wadsworth.length] = createMarker(new GPoint(-81.72795868,41.03029633),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Lincoln Elementary School",'Wadsworth=' + Wadsworth.length); Litchfield[Litchfield.length] = createMarker(new GPoint(-82.02536774,41.17003632),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Litchfield Elementary School",'Litchfield=' + Litchfield.length); Medina[Medina.length] = createMarker(new GPoint(-81.93255615,41.23867035),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Liverpool Elementary School",'Medina=' + Medina.length); Lodi[Lodi.length] = createMarker(new GPoint(-82.00853729,41.03302765),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Lodi Elementary School",'Lodi=' + Lodi.length); Medina[Medina.length] = createMarker(new GPoint(-81.85099030,41.14220047),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Medina City Kdg Center Elementary School",'Medina=' + Medina.length); Medina[Medina.length] = createMarker(new GPoint(-81.90301514,41.15523529),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Medina County Career Center",'Medina=' + Medina.length); Medina[Medina.length] = createMarker(new GPoint(-81.85126495,41.14315414),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Medina High School",'Medina=' + Medina.length); Wadsworth[Wadsworth.length] = createMarker(new GPoint(-81.71411133,41.02573776),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Overlook Elementary School",'Wadsworth=' + Wadsworth.length); Medina[Medina.length] = createMarker(new GPoint(-81.87220764,41.11996460),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Root Middle School",'Medina=' + Medina.length); Seville[Seville.length] = createMarker(new GPoint(-81.86097717,41.00996399),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Seville Elementary School",'Seville=' + Seville.length); Sharon_Center[Sharon_Center.length] = createMarker(new GPoint(-81.73580170,41.09970093),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Sharon Elementary School",'Sharon_Center=' + Sharon_Center.length); Medina[Medina.length] = createMarker(new GPoint(-81.85549164,41.14260864),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Sidney Fenn Elementary School",'Medina=' + Medina.length); Wadsworth[Wadsworth.length] = createMarker(new GPoint(-81.73139191,41.03913879),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Valley View Elementary School",'Wadsworth=' + Wadsworth.length); Brunswick[Brunswick.length] = createMarker(new GPoint(-81.84111786,41.23569107),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Visintainer Middle School",'Brunswick=' + Brunswick.length); Wadsworth[Wadsworth.length] = createMarker(new GPoint(-81.71015930,41.02546310),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Wadsworth High School",'Wadsworth=' + Wadsworth.length); Wadsworth[Wadsworth.length] = createMarker(new GPoint(-81.70402527,41.02447891),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Wadsworth Middle School",'Wadsworth=' + Wadsworth.length); Brunswick[Brunswick.length] = createMarker(new GPoint(-81.81745148,41.26127243),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Walter Kidder Elementary School",'Brunswick=' + Brunswick.length); Westfield_Center[Westfield_Center.length] = createMarker(new GPoint(-81.92960358,41.02949905),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Westfield Elementary School",'Westfield_Center=' + Westfield_Center.length); Brunswick[Brunswick.length] = createMarker(new GPoint(-81.82363892,41.24734879),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Willetts Middle School",'Brunswick=' + Brunswick.length); Medina[Medina.length] = createMarker(new GPoint(-81.92862701,41.16743851),"",iconRd); mySelect.options[mySelect.options.length] = new Option("York Elementary School",'Medina=' + Medina.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(Brunswick); map.removeOverlays(Hinckley); map.removeOverlays(Litchfield); map.removeOverlays(Lodi); map.removeOverlays(Medina); map.removeOverlays(Seville); map.removeOverlays(Sharon_Center); map.removeOverlays(Spencer); map.removeOverlays(Wadsworth); map.removeOverlays(Westfield_Center); 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(Brunswick);map.removeOverlays(Brunswick); map.removeOverlays(Hinckley); map.removeOverlays(Litchfield); map.removeOverlays(Lodi); map.removeOverlays(Medina); map.removeOverlays(Seville); map.removeOverlays(Sharon_Center); map.removeOverlays(Spencer); map.removeOverlays(Wadsworth); map.removeOverlays(Westfield_Center); map.addOverlays(Brunswick); centerByArray(Brunswick, false, false); cntMarker += Brunswick.length; map.addOverlays(Hinckley); centerByArray(Hinckley, false, false); cntMarker += Hinckley.length; map.addOverlays(Litchfield); centerByArray(Litchfield, false, false); cntMarker += Litchfield.length; map.addOverlays(Lodi); centerByArray(Lodi, false, false); cntMarker += Lodi.length; map.addOverlays(Medina); centerByArray(Medina, false, false); cntMarker += Medina.length; map.addOverlays(Seville); centerByArray(Seville, false, false); cntMarker += Seville.length; map.addOverlays(Sharon_Center); centerByArray(Sharon_Center, false, false); cntMarker += Sharon_Center.length; map.addOverlays(Spencer); centerByArray(Spencer, false, false); cntMarker += Spencer.length; map.addOverlays(Wadsworth); centerByArray(Wadsworth, false, false); cntMarker += Wadsworth.length; map.addOverlays(Westfield_Center); centerByArray(Westfield_Center, false, false); cntMarker += Westfield_Center.length; centerByArray(Brunswick,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'); } }