function addMarkers() { mySelect = document.getElementById('selection'); Lusby = [];Chesapeake_Beach = [];Prince_Frederick = [];Huntingtown = [];Owings = [];St_Leonard = [];Sunderland = [];mySelect.options[mySelect.options.length] = new Option("Chesapeake Beach schools",'all=Chesapeake_Beach'); mySelect.options[mySelect.options.length] = new Option("Huntingtown schools",'all=Huntingtown'); mySelect.options[mySelect.options.length] = new Option("Lusby schools",'all=Lusby'); mySelect.options[mySelect.options.length] = new Option("Owings schools",'all=Owings'); mySelect.options[mySelect.options.length] = new Option("Prince Frederick schools",'all=Prince_Frederick'); mySelect.options[mySelect.options.length] = new Option("St Leonard schools",'all=St_Leonard'); mySelect.options[mySelect.options.length] = new Option("Sunderland schools",'all=Sunderland'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Lusby[Lusby.length] = createMarker(new GPoint(-76.43769836,38.37426376),"
Appeal Elementary School
11655 Hg Trueman Rd
Lusby, MD 20657

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Appeal Elementary School",'Lusby=' + Lusby.length); Chesapeake_Beach[Chesapeake_Beach.length] = createMarker(new GPoint(-76.53372900,38.69534000),"
Beach Elementary School
7900 Old Bayside Rd
Chesapeake Beach, MD 20732

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Beach Elementary School",'Chesapeake_Beach=' + Chesapeake_Beach.length); Prince_Frederick[Prince_Frederick.length] = createMarker(new GPoint(-76.58191681,38.55493927),"
Calvert Career Center
330 Dorsey Road
Prince Frederick, MD 20678

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Calvert Career Center",'Prince_Frederick=' + Prince_Frederick.length); Prince_Frederick[Prince_Frederick.length] = createMarker(new GPoint(-76.57126617,38.55266190),"
Calvert Country School
1350 Dares Beach Rd
Prince Frederick, MD 20678

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Calvert Country School",'Prince_Frederick=' + Prince_Frederick.length); Prince_Frederick[Prince_Frederick.length] = createMarker(new GPoint(-76.57214355,38.55261230),"
Calvert County Evening High School
1305 Dares Beach Rd
Prince Frederick, MD 20678

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Calvert County Evening High School",'Prince_Frederick=' + Prince_Frederick.length); Prince_Frederick[Prince_Frederick.length] = createMarker(new GPoint(-76.57160950,38.55268860),"
Calvert County Home & Hospital School
1305 Dares Beach Rd
Prince Frederick, MD 20678

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Calvert County Home & Hospital School",'Prince_Frederick=' + Prince_Frederick.length); Prince_Frederick[Prince_Frederick.length] = createMarker(new GPoint(-76.56945038,38.55254745),"
Calvert Elementary School
1450 Dares Beach Rd
Prince Frederick, MD 20678

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Calvert Elementary School",'Prince_Frederick=' + Prince_Frederick.length); Prince_Frederick[Prince_Frederick.length] = createMarker(new GPoint(-76.57993317,38.55267715),"
Calvert High School
600 Dares Beach Rd
Prince Frederick, MD 20678

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Calvert High School",'Prince_Frederick=' + Prince_Frederick.length); Prince_Frederick[Prince_Frederick.length] = createMarker(new GPoint(-76.56970978,38.51669312),"
Calvert Middle School
435 Solomons Island Rd N
Prince Frederick, MD 20678

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Calvert Middle School",'Prince_Frederick=' + Prince_Frederick.length); Lusby[Lusby.length] = createMarker(new GPoint(-76.45334625,38.35545731),"
Dowell Elementary School
12680 H G Trueman Rd
Lusby, MD 20657

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Dowell Elementary School",'Lusby=' + Lusby.length); Huntingtown[Huntingtown.length] = createMarker(new GPoint(-76.62492371,38.61968613),"
Huntingtown Elementary School
4345 Huntingtown Rd
Huntingtown, MD 20639

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Huntingtown Elementary School",'Huntingtown=' + Huntingtown.length); Huntingtown[Huntingtown.length] = createMarker(new GPoint(-76.61089600,38.62096000),"
Huntingtown High School
4125 N Solomons Island Rd
Huntingtown, MD 20639

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Huntingtown High School",'Huntingtown=' + Huntingtown.length); Lusby[Lusby.length] = createMarker(new GPoint(-76.45581055,38.41067886),"
Mill Creek Middle School
12200 Margaret Taylor Rd
Lusby, MD 20657

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Mill Creek Middle School",'Lusby=' + Lusby.length); Owings[Owings.length] = createMarker(new GPoint(-76.62230800,38.70599000),"
Mount Harmony Elementary School
900 W Mount Harmony Rd
Owings, MD 20736

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Mount Harmony Elementary School",'Owings=' + Owings.length); Owings[Owings.length] = createMarker(new GPoint(-76.65153503,38.68729401),"
Northern High School
2950 Chaneyville Rd
Owings, MD 20736

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Northern High School",'Owings=' + Owings.length); Owings[Owings.length] = createMarker(new GPoint(-76.65179443,38.68721771),"
Northern Middle School
2954 Chaneyville Rd
Owings, MD 20736

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Northern Middle School",'Owings=' + Owings.length); Lusby[Lusby.length] = createMarker(new GPoint(-76.43557739,38.37630081),"
Patuxent Elementary School
35 Appeal Lane
Lusby, MD 20657

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Patuxent Elementary School",'Lusby=' + Lusby.length); Lusby[Lusby.length] = createMarker(new GPoint(-76.42862701,38.35592651),"
Patuxent High School
12485 Rousby Hall Rd
Lusby, MD 20657

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Patuxent High School",'Lusby=' + Lusby.length); Huntingtown[Huntingtown.length] = createMarker(new GPoint(-76.58841705,38.59600830),"
Plum Point Elementary School
1245 Plum Point Rd
Huntingtown, MD 20639

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Plum Point Elementary School",'Huntingtown=' + Huntingtown.length); Huntingtown[Huntingtown.length] = createMarker(new GPoint(-76.58322906,38.59828949),"
Plum Point Middle School
1475 Plum Point Rd
Huntingtown, MD 20639

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Plum Point Middle School",'Huntingtown=' + Huntingtown.length); Lusby[Lusby.length] = createMarker(new GPoint(-76.45142365,38.40967560),"
Southern Middle School
9615 H G Trueman Rd
Lusby, MD 20657

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Southern Middle School",'Lusby=' + Lusby.length); St_Leonard[St_Leonard.length] = createMarker(new GPoint(-76.49659729,38.46066666),"
St Leonard Elementary School
5370 St Leonard Rd
St Leonard, MD 20685

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("St Leonard Elementary School",'St_Leonard=' + St_Leonard.length); Sunderland[Sunderland.length] = createMarker(new GPoint(-76.60108185,38.67013168),"
Sunderland Elementary School
150 Clyde Jones Rd
Sunderland, MD 20689

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Sunderland Elementary School",'Sunderland=' + Sunderland.length); Owings[Owings.length] = createMarker(new GPoint(-76.56899261,38.71331024),"
Windy Hill Elementary School
9550 Boyds Turn Rd
Owings, MD 20736

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Windy Hill Elementary School",'Owings=' + Owings.length); Owings[Owings.length] = createMarker(new GPoint(-76.56886292,38.71347046),"
Windy Hill Middle School
9560 Boyd''s Turn Rd
Owings, MD 20736

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Windy Hill Middle School",'Owings=' + Owings.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(Chesapeake_Beach); map.removeOverlays(Huntingtown); map.removeOverlays(Lusby); map.removeOverlays(Owings); map.removeOverlays(Prince_Frederick); map.removeOverlays(St_Leonard); map.removeOverlays(Sunderland); 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(Lusby);map.removeOverlays(Chesapeake_Beach); map.removeOverlays(Huntingtown); map.removeOverlays(Lusby); map.removeOverlays(Owings); map.removeOverlays(Prince_Frederick); map.removeOverlays(St_Leonard); map.removeOverlays(Sunderland); map.addOverlays(Chesapeake_Beach); centerByArray(Chesapeake_Beach, false, false); cntMarker += Chesapeake_Beach.length; map.addOverlays(Huntingtown); centerByArray(Huntingtown, false, false); cntMarker += Huntingtown.length; map.addOverlays(Lusby); centerByArray(Lusby, false, false); cntMarker += Lusby.length; map.addOverlays(Owings); centerByArray(Owings, false, false); cntMarker += Owings.length; map.addOverlays(Prince_Frederick); centerByArray(Prince_Frederick, false, false); cntMarker += Prince_Frederick.length; map.addOverlays(St_Leonard); centerByArray(St_Leonard, false, false); cntMarker += St_Leonard.length; map.addOverlays(Sunderland); centerByArray(Sunderland, false, false); cntMarker += Sunderland.length; centerByArray(Lusby,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'); } }