function addMarkers() { mySelect = document.getElementById('selection'); Huntington = [];Huntington[Huntington.length] = createMarker(new GPoint(-82.40032196,38.42703629),"
",iconGr); mySelect.options[mySelect.options.length] = new Option("Alternative Education High School",'Huntington=' + Huntington.length); Huntington[Huntington.length] = createMarker(new GPoint(-82.40032196,38.42703629),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Alternative Education Middle School",'Huntington=' + Huntington.length); Huntington[Huntington.length] = createMarker(new GPoint(-82.36442566,38.41471863),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Altizer Elementary School",'Huntington=' + Huntington.length); Huntington[Huntington.length] = createMarker(new GPoint(-82.39027405,38.40654755),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Beverly Hills Middle School",'Huntington=' + Huntington.length); Huntington[Huntington.length] = createMarker(new GPoint(-82.37512970,38.40586472),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Cabell County Career Technology Center",'Huntington=' + Huntington.length); Huntington[Huntington.length] = createMarker(new GPoint(-82.45336914,38.41046524),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Cammack Elementary School",'Huntington=' + Huntington.length); Huntington[Huntington.length] = createMarker(new GPoint(-82.45336914,38.41046524),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Cammack Middle School",'Huntington=' + Huntington.length); Huntington[Huntington.length] = createMarker(new GPoint(-82.49062347,38.41027832),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Central City Elementary School",'Huntington=' + Huntington.length); Huntington[Huntington.length] = createMarker(new GPoint(-82.40928650,38.42906570),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Enslow Middle School",'Huntington=' + Huntington.length); Huntington[Huntington.length] = createMarker(new GPoint(-82.38645935,38.40299225),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Geneva Kent Elementary School",'Huntington=' + Huntington.length); Huntington[Huntington.length] = createMarker(new GPoint(-82.44847870,38.41852188),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Guyandotte Elementary School",'Huntington=' + Huntington.length); Huntington[Huntington.length] = createMarker(new GPoint(-82.41187286,38.42996216),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Highlawn Elementary School",'Huntington=' + Huntington.length); Huntington[Huntington.length] = createMarker(new GPoint(-82.37667084,38.38274384),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Hite Saunders Elementary School",'Huntington=' + Huntington.length); Huntington[Huntington.length] = createMarker(new GPoint(-82.42479706,38.40098953),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Huntington High School",'Huntington=' + Huntington.length); Huntington[Huntington.length] = createMarker(new GPoint(-82.51641083,38.39776230),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Kellogg Elementary School",'Huntington=' + Huntington.length); Huntington[Huntington.length] = createMarker(new GPoint(-82.42823029,38.40436172),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Meadows Elementary School",'Huntington=' + Huntington.length); Huntington[Huntington.length] = createMarker(new GPoint(-82.44508362,38.40908432),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Miller Elementary School",'Huntington=' + Huntington.length); Huntington[Huntington.length] = createMarker(new GPoint(-82.52713776,38.38006210),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Northern Voc/tech Center",'Huntington=' + Huntington.length); Huntington[Huntington.length] = createMarker(new GPoint(-82.32261658,38.41830063),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Pea Ridge Elementary School",'Huntington=' + Huntington.length); Huntington[Huntington.length] = createMarker(new GPoint(-82.39941406,38.41460037),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Peyton Elementary School",'Huntington=' + Huntington.length); Huntington[Huntington.length] = createMarker(new GPoint(-82.42116547,38.41220093),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Spring Hill Elementary School",'Huntington=' + Huntington.length); Huntington[Huntington.length] = createMarker(new GPoint(-82.50640106,38.37990189),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Spring Valley High School",'Huntington=' + Huntington.length); Huntington[Huntington.length] = createMarker(new GPoint(-82.51084137,38.39946747),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Vinson Middle School",'Huntington=' + Huntington.length); Huntington[Huntington.length] = createMarker(new GPoint(-82.47263336,38.41182327),"",iconBl); mySelect.options[mySelect.options.length] = new Option("West Middle School",'Huntington=' + Huntington.length); map.removeOverlays(Huntington); setTimeout(function(){map.addOverlays(Huntington)},1000); maxLng = -82.32261658; maxLat = 38.42996216; minLng = -82.52713776; minLat = 38.37990189; reCenterMap(); } // 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(Huntington); 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(Huntington);map.removeOverlays(Huntington); map.addOverlays(Huntington); centerByArray(Huntington, false, false); cntMarker += Huntington.length; centerByArray(Huntington,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'); } }