function addMarkers() { mySelect = document.getElementById('selection'); Ridgely = [];Federalsburg = [];Denton = [];Greensboro = [];Preston = [];mySelect.options[mySelect.options.length] = new Option("Denton schools",'all=Denton'); mySelect.options[mySelect.options.length] = new Option("Federalsburg schools",'all=Federalsburg'); mySelect.options[mySelect.options.length] = new Option("Greensboro schools",'all=Greensboro'); mySelect.options[mySelect.options.length] = new Option("Preston schools",'all=Preston'); mySelect.options[mySelect.options.length] = new Option("Ridgely schools",'all=Ridgely'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Ridgely[Ridgely.length] = createMarker(new GPoint(-75.84188843,38.90742111),"
Caroline Career & Technology Center
10855 Central Ave
Ridgely, MD 21660

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Caroline Career & Technology Center",'Ridgely=' + Ridgely.length); Federalsburg[Federalsburg.length] = createMarker(new GPoint(-75.82724762,38.75376129),"
Colonel Richardson High School
25320 Richardson Rd
Federalsburg, MD 21632

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Colonel Richardson High School",'Federalsburg=' + Federalsburg.length); Federalsburg[Federalsburg.length] = createMarker(new GPoint(-75.82469940,38.75372314),"
Colonel Richardson Middle School
25390 Richardson Rd
Federalsburg, MD 21632

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Colonel Richardson Middle School",'Federalsburg=' + Federalsburg.length); Denton[Denton.length] = createMarker(new GPoint(-75.83113861,38.87074661),"
Denton Elementary School
303 Sharp Rd
Denton, MD 21629

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Denton Elementary School",'Denton=' + Denton.length); Federalsburg[Federalsburg.length] = createMarker(new GPoint(-75.78031921,38.69049072),"
Federalsburg Elementary School
302 S University Ave
Federalsburg, MD 21632

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Federalsburg Elementary School",'Federalsburg=' + Federalsburg.length); Greensboro[Greensboro.length] = createMarker(new GPoint(-75.80032349,38.98401642),"
Greensboro Elementary School
625 N Main St
Greensboro, MD 21639

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Greensboro Elementary School",'Greensboro=' + Greensboro.length); Denton[Denton.length] = createMarker(new GPoint(-75.82867432,38.88863373),"
Lockerman Middle School
410 Lockerman St
Denton, MD 21629

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Lockerman Middle School",'Denton=' + Denton.length); Ridgely[Ridgely.length] = createMarker(new GPoint(-75.83691406,38.92147446),"
North Caroline High School
10990 River Rd
Ridgely, MD 21660

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("North Caroline High School",'Ridgely=' + Ridgely.length); Preston[Preston.length] = createMarker(new GPoint(-75.91649628,38.73939896),"
Preston Elementary School
Po Box 69
Preston, MD 21655

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Preston Elementary School",'Preston=' + Preston.length); Ridgely[Ridgely.length] = createMarker(new GPoint(-75.88316345,38.94576263),"
Ridgely Elementary School
118 N Central Ave
Ridgely, MD 21660

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Ridgely Elementary School",'Ridgely=' + Ridgely.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(Denton); map.removeOverlays(Federalsburg); map.removeOverlays(Greensboro); map.removeOverlays(Preston); map.removeOverlays(Ridgely); 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(Ridgely);map.removeOverlays(Denton); map.removeOverlays(Federalsburg); map.removeOverlays(Greensboro); map.removeOverlays(Preston); map.removeOverlays(Ridgely); map.addOverlays(Denton); centerByArray(Denton, false, false); cntMarker += Denton.length; map.addOverlays(Federalsburg); centerByArray(Federalsburg, false, false); cntMarker += Federalsburg.length; map.addOverlays(Greensboro); centerByArray(Greensboro, false, false); cntMarker += Greensboro.length; map.addOverlays(Preston); centerByArray(Preston, false, false); cntMarker += Preston.length; map.addOverlays(Ridgely); centerByArray(Ridgely, false, false); cntMarker += Ridgely.length; centerByArray(Ridgely,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'); } }