function addMarkers() { mySelect = document.getElementById('selection'); Littleton = [];Scotland_Neck = [];Roanoke_Rapids = [];Enfield = [];Hollister = [];Halifax = [];Weldon = [];mySelect.options[mySelect.options.length] = new Option("Enfield schools",'all=Enfield'); mySelect.options[mySelect.options.length] = new Option("Halifax schools",'all=Halifax'); mySelect.options[mySelect.options.length] = new Option("Hollister schools",'all=Hollister'); mySelect.options[mySelect.options.length] = new Option("Littleton schools",'all=Littleton'); mySelect.options[mySelect.options.length] = new Option("Roanoke Rapids schools",'all=Roanoke_Rapids'); mySelect.options[mySelect.options.length] = new Option("Scotland Neck schools",'all=Scotland_Neck'); mySelect.options[mySelect.options.length] = new Option("Weldon schools",'all=Weldon'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Littleton[Littleton.length] = createMarker(new GPoint(-77.80690765,36.36338043),"
",iconRd); mySelect.options[mySelect.options.length] = new Option("Aurelian Springs Elementary School",'Littleton=' + Littleton.length); Scotland_Neck[Scotland_Neck.length] = createMarker(new GPoint(-77.38282013,36.14580154),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Bakers Elementary School",'Scotland_Neck=' + Scotland_Neck.length); Roanoke_Rapids[Roanoke_Rapids.length] = createMarker(new GPoint(-77.67325592,36.46666336),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Belmont Elementary School",'Roanoke_Rapids=' + Roanoke_Rapids.length); Scotland_Neck[Scotland_Neck.length] = createMarker(new GPoint(-77.41970062,36.13230133),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Brawley Middle School",'Scotland_Neck=' + Scotland_Neck.length); Roanoke_Rapids[Roanoke_Rapids.length] = createMarker(new GPoint(-77.65924835,36.44032669),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Chaloner Middle School",'Roanoke_Rapids=' + Roanoke_Rapids.length); Scotland_Neck[Scotland_Neck.length] = createMarker(new GPoint(-77.52525330,36.16548920),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Dawson Elementary School",'Scotland_Neck=' + Scotland_Neck.length); Enfield[Enfield.length] = createMarker(new GPoint(-77.66718292,36.18054962),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Eastman Middle School",'Enfield=' + Enfield.length); Enfield[Enfield.length] = createMarker(new GPoint(-77.70809937,36.19860077),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Enfield Middle School",'Enfield=' + Enfield.length); Roanoke_Rapids[Roanoke_Rapids.length] = createMarker(new GPoint(-77.75688171,36.44256592),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Everetts Elementary School",'Roanoke_Rapids=' + Roanoke_Rapids.length); Littleton[Littleton.length] = createMarker(new GPoint(-77.79019165,36.38480759),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Halifax Co Education Center",'Littleton=' + Littleton.length); Hollister[Hollister.length] = createMarker(new GPoint(-77.93705750,36.25540924),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Hollister Elementary School",'Hollister=' + Hollister.length); Enfield[Enfield.length] = createMarker(new GPoint(-77.66795349,36.17183304),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Inborden Elementary School",'Enfield=' + Enfield.length); Littleton[Littleton.length] = createMarker(new GPoint(-77.89507294,36.43988037),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Mciver Elementary School",'Littleton=' + Littleton.length); Littleton[Littleton.length] = createMarker(new GPoint(-77.79016876,36.38481903),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Northwest High School",'Littleton=' + Littleton.length); Enfield[Enfield.length] = createMarker(new GPoint(-77.66718292,36.18054962),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Pittman Elementary School",'Enfield=' + Enfield.length); Roanoke_Rapids[Roanoke_Rapids.length] = createMarker(new GPoint(-77.65430450,36.45882034),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Roanoke Rapids High School",'Roanoke_Rapids=' + Roanoke_Rapids.length); Scotland_Neck[Scotland_Neck.length] = createMarker(new GPoint(-77.41970062,36.13230133),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Scotland Neck Primary",'Scotland_Neck=' + Scotland_Neck.length); Halifax[Halifax.length] = createMarker(new GPoint(-77.58885956,36.32783127),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Southeast Halifax High School",'Halifax=' + Halifax.length); Weldon[Weldon.length] = createMarker(new GPoint(-77.60440063,36.42229843),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Weldon Elementary School",'Weldon=' + Weldon.length); Weldon[Weldon.length] = createMarker(new GPoint(-77.61071777,36.41321945),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Weldon High School",'Weldon=' + Weldon.length); Halifax[Halifax.length] = createMarker(new GPoint(-77.57900238,36.30550003),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Weldon Middle School",'Halifax=' + Halifax.length); Roanoke_Rapids[Roanoke_Rapids.length] = createMarker(new GPoint(-77.64469910,36.45178223),"",iconRd); mySelect.options[mySelect.options.length] = new Option("William L Manning Elementary School",'Roanoke_Rapids=' + Roanoke_Rapids.length); Roanoke_Rapids[Roanoke_Rapids.length] = createMarker(new GPoint(-77.65453339,36.46134949),"",iconBl); mySelect.options[mySelect.options.length] = new Option("William R Davie Middle School",'Roanoke_Rapids=' + Roanoke_Rapids.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(Enfield); map.removeOverlays(Halifax); map.removeOverlays(Hollister); map.removeOverlays(Littleton); map.removeOverlays(Roanoke_Rapids); map.removeOverlays(Scotland_Neck); map.removeOverlays(Weldon); 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(Littleton);map.removeOverlays(Enfield); map.removeOverlays(Halifax); map.removeOverlays(Hollister); map.removeOverlays(Littleton); map.removeOverlays(Roanoke_Rapids); map.removeOverlays(Scotland_Neck); map.removeOverlays(Weldon); map.addOverlays(Enfield); centerByArray(Enfield, false, false); cntMarker += Enfield.length; map.addOverlays(Halifax); centerByArray(Halifax, false, false); cntMarker += Halifax.length; map.addOverlays(Hollister); centerByArray(Hollister, false, false); cntMarker += Hollister.length; map.addOverlays(Littleton); centerByArray(Littleton, false, false); cntMarker += Littleton.length; map.addOverlays(Roanoke_Rapids); centerByArray(Roanoke_Rapids, false, false); cntMarker += Roanoke_Rapids.length; map.addOverlays(Scotland_Neck); centerByArray(Scotland_Neck, false, false); cntMarker += Scotland_Neck.length; map.addOverlays(Weldon); centerByArray(Weldon, false, false); cntMarker += Weldon.length; centerByArray(Littleton,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'); } }