function addMarkers() { mySelect = document.getElementById('selection'); Chicago_Heights = [];Ford_Heights = [];Sauk_Village = [];Lynwood = [];South_Chicago_Hts = [];S_Chicago_Heights = [];Chicago_Heights[Chicago_Heights.length] = createMarker(new GPoint(-87.66170502,41.49763870),"
",iconRd); mySelect.options[mySelect.options.length] = new Option("Beacon Hill Primary Cntr",'Chicago_Heights=' + Chicago_Heights.length); Chicago_Heights[Chicago_Heights.length] = createMarker(new GPoint(-87.64542389,41.51343536),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Bloom High School",'Chicago_Heights=' + Chicago_Heights.length); Chicago_Heights[Chicago_Heights.length] = createMarker(new GPoint(-87.59632874,41.48486328),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Bloom Trail High School",'Chicago_Heights=' + Chicago_Heights.length); Ford_Heights[Ford_Heights.length] = createMarker(new GPoint(-87.63150024,41.50619888),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Cottage Grove Middle School",'Ford_Heights=' + Ford_Heights.length); Chicago_Heights[Chicago_Heights.length] = createMarker(new GPoint(-87.64538574,41.51316452),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Dist 206 Alternative High School",'Chicago_Heights=' + Chicago_Heights.length); Chicago_Heights[Chicago_Heights.length] = createMarker(new GPoint(-87.62331390,41.50966263),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Dr Charles E Gavin Elementary School",'Chicago_Heights=' + Chicago_Heights.length); Chicago_Heights[Chicago_Heights.length] = createMarker(new GPoint(-87.63185120,41.49416351),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Garfield Elementary School",'Chicago_Heights=' + Chicago_Heights.length); Chicago_Heights[Chicago_Heights.length] = createMarker(new GPoint(-87.64524841,41.52450180),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Greenbriar Elementary School",'Chicago_Heights=' + Chicago_Heights.length); Chicago_Heights[Chicago_Heights.length] = createMarker(new GPoint(-87.64939117,41.51634216),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Highland School",'Chicago_Heights=' + Chicago_Heights.length); Chicago_Heights[Chicago_Heights.length] = createMarker(new GPoint(-87.63591766,41.49969864),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Jefferson Elementary School",'Chicago_Heights=' + Chicago_Heights.length); Chicago_Heights[Chicago_Heights.length] = createMarker(new GPoint(-87.66451263,41.51286316),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Kennedy Elementary School",'Chicago_Heights=' + Chicago_Heights.length); Chicago_Heights[Chicago_Heights.length] = createMarker(new GPoint(-87.63591766,41.49969864),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Lincoln Elementary School",'Chicago_Heights=' + Chicago_Heights.length); Chicago_Heights[Chicago_Heights.length] = createMarker(new GPoint(-87.63591766,41.49969864),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Mckinley Elementary School",'Chicago_Heights=' + Chicago_Heights.length); Ford_Heights[Ford_Heights.length] = createMarker(new GPoint(-87.59028625,41.51363754),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Medgar Evers Primary",'Ford_Heights=' + Ford_Heights.length); Sauk_Village[Sauk_Village.length] = createMarker(new GPoint(-87.55781555,41.48760986),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Rickover Junior High School",'Sauk_Village=' + Sauk_Village.length); Chicago_Heights[Chicago_Heights.length] = createMarker(new GPoint(-87.65231323,41.50696945),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Roosevelt Elementary School",'Chicago_Heights=' + Chicago_Heights.length); Chicago_Heights[Chicago_Heights.length] = createMarker(new GPoint(-87.65299225,41.52073669),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Safe School Program",'Chicago_Heights=' + Chicago_Heights.length); Lynwood[Lynwood.length] = createMarker(new GPoint(-87.54427338,41.51755524),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Sandridge Elementary School",'Lynwood=' + Lynwood.length); South_Chicago_Hts[South_Chicago_Hts.length] = createMarker(new GPoint(-87.64001465,41.47807312),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Saukview Elementary School",'South_Chicago_Hts=' + South_Chicago_Hts.length); Chicago_Heights[Chicago_Heights.length] = createMarker(new GPoint(-87.65272522,41.53273773),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Serena Hills Elementary School",'Chicago_Heights=' + Chicago_Heights.length); Chicago_Heights[Chicago_Heights.length] = createMarker(new GPoint(-87.66441345,41.51135254),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Speed Seja 802 Pal Pgrm",'Chicago_Heights=' + Chicago_Heights.length); Sauk_Village[Sauk_Village.length] = createMarker(new GPoint(-87.56739044,41.48436356),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Strassburg Elementary & L J Morales Cnt",'Sauk_Village=' + Sauk_Village.length); Ford_Heights[Ford_Heights.length] = createMarker(new GPoint(-87.58709717,41.50743866),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Tidye A Phillips Elementary School",'Ford_Heights=' + Ford_Heights.length); S_Chicago_Heights[S_Chicago_Heights.length] = createMarker(new GPoint(-87.64048004,41.48946381),"",iconRd); mySelect.options[mySelect.options.length] = new Option("U S Grant Elementary School",'S_Chicago_Heights=' + S_Chicago_Heights.length); Sauk_Village[Sauk_Village.length] = createMarker(new GPoint(-87.57123566,41.49666595),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Wagoner Elementary & Dr T E Ryan Lrn Cn",'Sauk_Village=' + Sauk_Village.length); Chicago_Heights[Chicago_Heights.length] = createMarker(new GPoint(-87.64192963,41.50163651),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Washington Junior High School",'Chicago_Heights=' + Chicago_Heights.length); Chicago_Heights[Chicago_Heights.length] = createMarker(new GPoint(-87.63591766,41.49969864),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Wilson Elementary School",'Chicago_Heights=' + Chicago_Heights.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(Chicago_Heights); map.removeOverlays(Ford_Heights); map.removeOverlays(Sauk_Village); map.removeOverlays(Lynwood); map.removeOverlays(South_Chicago_Hts); map.removeOverlays(S_Chicago_Heights); 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(Chicago_Heights);map.removeOverlays(Chicago_Heights); map.removeOverlays(Ford_Heights); map.removeOverlays(Sauk_Village); map.removeOverlays(Lynwood); map.removeOverlays(South_Chicago_Hts); map.removeOverlays(S_Chicago_Heights); map.addOverlays(Chicago_Heights); centerByArray(Chicago_Heights, false, false); cntMarker += Chicago_Heights.length; map.addOverlays(Ford_Heights); centerByArray(Ford_Heights, false, false); cntMarker += Ford_Heights.length; map.addOverlays(Sauk_Village); centerByArray(Sauk_Village, false, false); cntMarker += Sauk_Village.length; map.addOverlays(Lynwood); centerByArray(Lynwood, false, false); cntMarker += Lynwood.length; map.addOverlays(South_Chicago_Hts); centerByArray(South_Chicago_Hts, false, false); cntMarker += South_Chicago_Hts.length; map.addOverlays(S_Chicago_Heights); centerByArray(S_Chicago_Heights, false, false); cntMarker += S_Chicago_Heights.length; centerByArray(Chicago_Heights,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'); } }