function addMarkers() { mySelect = document.getElementById('selection'); Pageland = [];Cheraw = [];Chesterfield = [];Jefferson = [];Mcbee_S_C = [];Mcbee = [];Patrick = [];Ruby = [];mySelect.options[mySelect.options.length] = new Option("Cheraw schools",'all=Cheraw'); mySelect.options[mySelect.options.length] = new Option("Chesterfield schools",'all=Chesterfield'); mySelect.options[mySelect.options.length] = new Option("Jefferson schools",'all=Jefferson'); mySelect.options[mySelect.options.length] = new Option("Mcbee schools",'all=Mcbee'); mySelect.options[mySelect.options.length] = new Option("Mcbee S C schools",'all=Mcbee_S_C'); mySelect.options[mySelect.options.length] = new Option("Pageland schools",'all=Pageland'); mySelect.options[mySelect.options.length] = new Option("Patrick schools",'all=Patrick'); mySelect.options[mySelect.options.length] = new Option("Ruby schools",'all=Ruby'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Pageland[Pageland.length] = createMarker(new GPoint(-80.35686493,34.75567245),"
",iconGr); mySelect.options[mySelect.options.length] = new Option("Central High School",'Pageland=' + Pageland.length); Cheraw[Cheraw.length] = createMarker(new GPoint(-79.91605377,34.69467163),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Cheraw High School",'Cheraw=' + Cheraw.length); Cheraw[Cheraw.length] = createMarker(new GPoint(-79.90613556,34.69195175),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Cheraw Intermediate School",'Cheraw=' + Cheraw.length); Cheraw[Cheraw.length] = createMarker(new GPoint(-79.89418793,34.69684219),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Cheraw Primary School",'Cheraw=' + Cheraw.length); Chesterfield[Chesterfield.length] = createMarker(new GPoint(-80.10780334,34.79290009),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Chesterfield High School",'Chesterfield=' + Chesterfield.length); Chesterfield[Chesterfield.length] = createMarker(new GPoint(-80.08067322,34.73324203),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Chesterfield Middle School",'Chesterfield=' + Chesterfield.length); Chesterfield[Chesterfield.length] = createMarker(new GPoint(-80.08534241,34.73072052),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Chesterfield-ruby Middle School",'Chesterfield=' + Chesterfield.length); Chesterfield[Chesterfield.length] = createMarker(new GPoint(-80.08834839,34.73601913),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Edwards Elementary School",'Chesterfield=' + Chesterfield.length); Jefferson[Jefferson.length] = createMarker(new GPoint(-80.38887024,34.65024185),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Jefferson Elementary School",'Jefferson=' + Jefferson.length); Cheraw[Cheraw.length] = createMarker(new GPoint(-79.90676880,34.69609833),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Long Middle School",'Cheraw=' + Cheraw.length); Mcbee_S_C[Mcbee_S_C.length] = createMarker(new GPoint(-80.90660095,34.03099823),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Mcbee Elementary School",'Mcbee_S_C=' + Mcbee_S_C.length); Mcbee[Mcbee.length] = createMarker(new GPoint(-80.24900055,34.47119904),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Mcbee High School",'Mcbee=' + Mcbee.length); Pageland[Pageland.length] = createMarker(new GPoint(-80.40078735,34.76937866),"",iconBl); mySelect.options[mySelect.options.length] = new Option("New Heights Middle School",'Pageland=' + Pageland.length); Pageland[Pageland.length] = createMarker(new GPoint(-80.39077400,34.77212000),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Pageland Elementary School",'Pageland=' + Pageland.length); Pageland[Pageland.length] = createMarker(new GPoint(-80.40830231,34.77220154),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Petersburg Elementary School",'Pageland=' + Pageland.length); Patrick[Patrick.length] = createMarker(new GPoint(-80.04686737,34.57392883),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Plainview Elementary School",'Patrick=' + Patrick.length); Ruby[Ruby.length] = createMarker(new GPoint(-80.20390320,34.73519897),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Ruby Elementary School",'Ruby=' + Ruby.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(Cheraw); map.removeOverlays(Chesterfield); map.removeOverlays(Jefferson); map.removeOverlays(Mcbee); map.removeOverlays(Mcbee_S_C); map.removeOverlays(Pageland); map.removeOverlays(Patrick); map.removeOverlays(Ruby); 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(Pageland);map.removeOverlays(Cheraw); map.removeOverlays(Chesterfield); map.removeOverlays(Jefferson); map.removeOverlays(Mcbee); map.removeOverlays(Mcbee_S_C); map.removeOverlays(Pageland); map.removeOverlays(Patrick); map.removeOverlays(Ruby); map.addOverlays(Cheraw); centerByArray(Cheraw, false, false); cntMarker += Cheraw.length; map.addOverlays(Chesterfield); centerByArray(Chesterfield, false, false); cntMarker += Chesterfield.length; map.addOverlays(Jefferson); centerByArray(Jefferson, false, false); cntMarker += Jefferson.length; map.addOverlays(Mcbee); centerByArray(Mcbee, false, false); cntMarker += Mcbee.length; map.addOverlays(Mcbee_S_C); centerByArray(Mcbee_S_C, false, false); cntMarker += Mcbee_S_C.length; map.addOverlays(Pageland); centerByArray(Pageland, false, false); cntMarker += Pageland.length; map.addOverlays(Patrick); centerByArray(Patrick, false, false); cntMarker += Patrick.length; map.addOverlays(Ruby); centerByArray(Ruby, false, false); cntMarker += Ruby.length; centerByArray(Pageland,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'); } }