function addMarkers() { mySelect = document.getElementById('selection'); Ridgeland = [];Canton = [];Flora = [];Madison = [];Camden = [];mySelect.options[mySelect.options.length] = new Option("Camden schools",'all=Camden'); mySelect.options[mySelect.options.length] = new Option("Canton schools",'all=Canton'); mySelect.options[mySelect.options.length] = new Option("Flora schools",'all=Flora'); mySelect.options[mySelect.options.length] = new Option("Madison schools",'all=Madison'); mySelect.options[mySelect.options.length] = new Option("Ridgeland schools",'all=Ridgeland'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Ridgeland[Ridgeland.length] = createMarker(new GPoint(-90.12344360,32.42105484),"
",iconRd); mySelect.options[mySelect.options.length] = new Option("Ann Smith Elementary School",'Ridgeland=' + Ridgeland.length); Canton[Canton.length] = createMarker(new GPoint(-90.03611000,32.61975100),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Canton Career Center",'Canton=' + Canton.length); Canton[Canton.length] = createMarker(new GPoint(-90.01706696,32.60996628),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Canton Elementary School",'Canton=' + Canton.length); Canton[Canton.length] = createMarker(new GPoint(-90.00333405,32.63333511),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Canton Public High School",'Canton=' + Canton.length); Flora[Flora.length] = createMarker(new GPoint(-90.30548096,32.54586029),"",iconRd); mySelect.options[mySelect.options.length] = new Option("East Flora Elementary School",'Flora=' + Flora.length); Flora[Flora.length] = createMarker(new GPoint(-90.28701782,32.54595947),"",iconBl); mySelect.options[mySelect.options.length] = new Option("East Flora Middle School",'Flora=' + Flora.length); Ridgeland[Ridgeland.length] = createMarker(new GPoint(-90.15169525,32.41955948),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Highland Elementary School",'Ridgeland=' + Ridgeland.length); Canton[Canton.length] = createMarker(new GPoint(-89.81723022,32.66732407),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Luther Branson School",'Canton=' + Canton.length); Madison[Madison.length] = createMarker(new GPoint(-90.08919525,32.45735931),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Madison Avenue Lower Elementary School",'Madison=' + Madison.length); Madison[Madison.length] = createMarker(new GPoint(-90.09883881,32.45748520),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Madison Avenue Upper Elementary School",'Madison=' + Madison.length); Madison[Madison.length] = createMarker(new GPoint(-90.15341949,32.46825790),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Madison Central High School",'Madison=' + Madison.length); Canton[Canton.length] = createMarker(new GPoint(-90.07315600,32.60461200),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Madison Co Voc Complex",'Canton=' + Canton.length); Madison[Madison.length] = createMarker(new GPoint(-90.12376404,32.46586227),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Madison Middle School",'Madison=' + Madison.length); Madison[Madison.length] = createMarker(new GPoint(-90.12360382,32.46556091),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Madison Station Elementary School",'Madison=' + Madison.length); Canton[Canton.length] = createMarker(new GPoint(-90.03388977,32.62393570),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Mc Neal Elementary School",'Canton=' + Canton.length); Canton[Canton.length] = createMarker(new GPoint(-90.04875946,32.62007523),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Nichols Middle School",'Canton=' + Canton.length); Canton[Canton.length] = createMarker(new GPoint(-89.81845856,32.70965958),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Northeast Madison Middle School",'Canton=' + Canton.length); Ridgeland[Ridgeland.length] = createMarker(new GPoint(-90.14064789,32.43222046),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Olde Towne Middle School",'Ridgeland=' + Ridgeland.length); Ridgeland[Ridgeland.length] = createMarker(new GPoint(-90.13880157,32.42039871),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Ridgeland High School",'Ridgeland=' + Ridgeland.length); Madison[Madison.length] = createMarker(new GPoint(-90.12360382,32.46556091),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Rosa Scott Middle School",'Madison=' + Madison.length); Madison[Madison.length] = createMarker(new GPoint(-90.12359000,32.46571800),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Rosa Scott School",'Madison=' + Madison.length); Camden[Camden.length] = createMarker(new GPoint(-89.83999634,32.79119873),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Velma Jackson Elementary School",'Camden=' + Camden.length); Camden[Camden.length] = createMarker(new GPoint(-89.86633301,32.77473068),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Velma Jackson High School",'Camden=' + Camden.length); Camden[Camden.length] = createMarker(new GPoint(-89.86633301,32.77473068),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Velma Jackson Middle School",'Camden=' + Camden.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(Camden); map.removeOverlays(Canton); map.removeOverlays(Flora); map.removeOverlays(Madison); map.removeOverlays(Ridgeland); 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(Ridgeland);map.removeOverlays(Camden); map.removeOverlays(Canton); map.removeOverlays(Flora); map.removeOverlays(Madison); map.removeOverlays(Ridgeland); map.addOverlays(Camden); centerByArray(Camden, false, false); cntMarker += Camden.length; map.addOverlays(Canton); centerByArray(Canton, false, false); cntMarker += Canton.length; map.addOverlays(Flora); centerByArray(Flora, false, false); cntMarker += Flora.length; map.addOverlays(Madison); centerByArray(Madison, false, false); cntMarker += Madison.length; map.addOverlays(Ridgeland); centerByArray(Ridgeland, false, false); cntMarker += Ridgeland.length; centerByArray(Ridgeland,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'); } }