function addMarkers() { mySelect = document.getElementById('selection'); Cambridge = [];Hurlock = [];Church_Creek = [];Vienna = [];Secretary = [];mySelect.options[mySelect.options.length] = new Option("Cambridge schools",'all=Cambridge'); mySelect.options[mySelect.options.length] = new Option("Church Creek schools",'all=Church_Creek'); mySelect.options[mySelect.options.length] = new Option("Hurlock schools",'all=Hurlock'); mySelect.options[mySelect.options.length] = new Option("Secretary schools",'all=Secretary'); mySelect.options[mySelect.options.length] = new Option("Vienna schools",'all=Vienna'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Cambridge[Cambridge.length] = createMarker(new GPoint(-76.06090546,38.55874252),"
Cambridge-south Dorchester High School
2475 Cambridge Bypass
Cambridge, MD 21613

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Cambridge-south Dorchester High School",'Cambridge=' + Cambridge.length); Cambridge[Cambridge.length] = createMarker(new GPoint(-76.08963776,38.56001663),"
Choptank Elementary School
1103 Mace''s Ln
Cambridge, MD 21613

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Choptank Elementary School",'Cambridge=' + Cambridge.length); Cambridge[Cambridge.length] = createMarker(new GPoint(-76.09204102,38.54590225),"
Dorchester County School Of Technology
2465 Cambridge Bypass
Cambridge, MD 21613

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Dorchester County School Of Technology",'Cambridge=' + Cambridge.length); Cambridge[Cambridge.length] = createMarker(new GPoint(-76.09048462,38.54600525),"
Dorchester Evening High School
2475 Cambridge Bypass
Cambridge, MD 21613

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Dorchester Evening High School",'Cambridge=' + Cambridge.length); Hurlock[Hurlock.length] = createMarker(new GPoint(-75.87190247,38.63930130),"
Hurlock Elementary School
301 Charles St
Hurlock, MD 21643

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Hurlock Elementary School",'Hurlock=' + Hurlock.length); Cambridge[Cambridge.length] = createMarker(new GPoint(-76.08924866,38.57922745),"
Judy Center
1405 Glasgow St
Cambridge, MD 21613

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Judy Center",'Cambridge=' + Cambridge.length); Cambridge[Cambridge.length] = createMarker(new GPoint(-76.08962250,38.56010818),"
Maces Lane Middle School
1101 Maces Ln
Cambridge, MD 21613

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Maces Lane Middle School",'Cambridge=' + Cambridge.length); Cambridge[Cambridge.length] = createMarker(new GPoint(-76.09370422,38.53936768),"
Maple Elementary School
5225 Egypt Rd
Cambridge, MD 21613

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Maple Elementary School",'Cambridge=' + Cambridge.length); Hurlock[Hurlock.length] = createMarker(new GPoint(-75.87524414,38.58721161),"
North Dorchester High School
5875 Cloverdale Rd
Hurlock, MD 21643

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("North Dorchester High School",'Hurlock=' + Hurlock.length); Hurlock[Hurlock.length] = createMarker(new GPoint(-75.87770844,38.58441162),"
North Dorchester Middle School
5745 Cloverdale Rd
Hurlock, MD 21643

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("North Dorchester Middle School",'Hurlock=' + Hurlock.length); Cambridge[Cambridge.length] = createMarker(new GPoint(-76.09033203,38.57981491),"
Sandy Hill Elementary School
1503 Glasgow St
Cambridge, MD 21613

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Sandy Hill Elementary School",'Cambridge=' + Cambridge.length); Church_Creek[Church_Creek.length] = createMarker(new GPoint(-76.14656067,38.50856781),"
South Dorchester School
3485 Church Creek Rd
Church Creek, MD 21622

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("South Dorchester School",'Church_Creek=' + Church_Creek.length); Vienna[Vienna.length] = createMarker(new GPoint(-75.84992218,38.49528122),"
Vienna Elementary School
4905 Ocean Gateway
Vienna, MD 21869

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Vienna Elementary School",'Vienna=' + Vienna.length); Secretary[Secretary.length] = createMarker(new GPoint(-75.94830322,38.60839844),"
Warwick Elementary School
Po Box 549
Secretary, MD 21664

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Warwick Elementary School",'Secretary=' + Secretary.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(Cambridge); map.removeOverlays(Church_Creek); map.removeOverlays(Hurlock); map.removeOverlays(Secretary); map.removeOverlays(Vienna); 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(Cambridge);map.removeOverlays(Cambridge); map.removeOverlays(Church_Creek); map.removeOverlays(Hurlock); map.removeOverlays(Secretary); map.removeOverlays(Vienna); map.addOverlays(Cambridge); centerByArray(Cambridge, false, false); cntMarker += Cambridge.length; map.addOverlays(Church_Creek); centerByArray(Church_Creek, false, false); cntMarker += Church_Creek.length; map.addOverlays(Hurlock); centerByArray(Hurlock, false, false); cntMarker += Hurlock.length; map.addOverlays(Secretary); centerByArray(Secretary, false, false); cntMarker += Secretary.length; map.addOverlays(Vienna); centerByArray(Vienna, false, false); cntMarker += Vienna.length; centerByArray(Cambridge,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'); } }