function addMarkers() { mySelect = document.getElementById('selection'); Crisfield = [];Deal_Island = [];Ewell = [];Princess_Anne = [];Westover = [];Marion = [];mySelect.options[mySelect.options.length] = new Option("Crisfield schools",'all=Crisfield'); mySelect.options[mySelect.options.length] = new Option("Deal Island schools",'all=Deal_Island'); mySelect.options[mySelect.options.length] = new Option("Ewell schools",'all=Ewell'); mySelect.options[mySelect.options.length] = new Option("Marion schools",'all=Marion'); mySelect.options[mySelect.options.length] = new Option("Princess Anne schools",'all=Princess_Anne'); mySelect.options[mySelect.options.length] = new Option("Westover schools",'all=Westover'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Crisfield[Crisfield.length] = createMarker(new GPoint(-75.85182953,37.97371292),"
Carter G. Woodson Middle School
281a Woodson School Rd
Crisfield, MD 21817

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Carter G. Woodson Middle School",'Crisfield=' + Crisfield.length); Crisfield[Crisfield.length] = createMarker(new GPoint(-75.84429932,37.98680115),"
Crisfield High School
210 N Somerset Avenue
Crisfield, MD 21817

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Crisfield High School",'Crisfield=' + Crisfield.length); Deal_Island[Deal_Island.length] = createMarker(new GPoint(-75.94743347,38.15773010),"
Deal Island School
23275 Lola Wheatley Rd
Deal Island, MD 21821

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Deal Island School",'Deal_Island=' + Deal_Island.length); Ewell[Ewell.length] = createMarker(new GPoint(-76.03432465,37.99444580),"
Ewell School
4005 Smith Island Rd
Ewell, MD 21824

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Ewell School",'Ewell=' + Ewell.length); Princess_Anne[Princess_Anne.length] = createMarker(new GPoint(-75.69388580,38.19356537),"
Greenwood Middle School
11412 Dryden Rd
Princess Anne, MD 21853

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Greenwood Middle School",'Princess_Anne=' + Princess_Anne.length); Crisfield[Crisfield.length] = createMarker(new GPoint(-75.84322357,37.97894669),"
H. Dewayne Whittington Primary
6 Asbury Avenue
Crisfield, MD 21817

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("H. Dewayne Whittington Primary",'Crisfield=' + Crisfield.length); Westover[Westover.length] = createMarker(new GPoint(-75.71565247,38.10272598),"
J. M. Tawes Vocational Center
7982 Crisfield Highway
Westover, MD 21871

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("J. M. Tawes Vocational Center",'Westover=' + Westover.length); Marion[Marion.length] = createMarker(new GPoint(-75.74839783,38.02669907),"
Marion Sarah Peyton School
Po Box G
Marion, MD 21838

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Marion Sarah Peyton School",'Marion=' + Marion.length); Princess_Anne[Princess_Anne.length] = createMarker(new GPoint(-75.69439697,38.19935989),"
Princess Anne Primary
11576 Lankford St
Princess Anne, MD 21853

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Princess Anne Primary",'Princess_Anne=' + Princess_Anne.length); Princess_Anne[Princess_Anne.length] = createMarker(new GPoint(-75.68556976,38.17974854),"
Washington High School
10902 Old Princess Anne Rd
Princess Anne, MD 21853

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Washington High School",'Princess_Anne=' + Princess_Anne.length); Westover[Westover.length] = createMarker(new GPoint(-75.70844269,38.12668610),"
Westover Elementary School
8928 Sign Post Rd
Westover, MD 21871

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Westover Elementary School",'Westover=' + Westover.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(Crisfield); map.removeOverlays(Deal_Island); map.removeOverlays(Ewell); map.removeOverlays(Marion); map.removeOverlays(Princess_Anne); map.removeOverlays(Westover); 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(Crisfield);map.removeOverlays(Crisfield); map.removeOverlays(Deal_Island); map.removeOverlays(Ewell); map.removeOverlays(Marion); map.removeOverlays(Princess_Anne); map.removeOverlays(Westover); map.addOverlays(Crisfield); centerByArray(Crisfield, false, false); cntMarker += Crisfield.length; map.addOverlays(Deal_Island); centerByArray(Deal_Island, false, false); cntMarker += Deal_Island.length; map.addOverlays(Ewell); centerByArray(Ewell, false, false); cntMarker += Ewell.length; map.addOverlays(Marion); centerByArray(Marion, false, false); cntMarker += Marion.length; map.addOverlays(Princess_Anne); centerByArray(Princess_Anne, false, false); cntMarker += Princess_Anne.length; map.addOverlays(Westover); centerByArray(Westover, false, false); cntMarker += Westover.length; centerByArray(Crisfield,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'); } }