function addMarkers() { mySelect = document.getElementById('selection'); Magnolia = [];Emerson = [];Mcneil = [];Taylor = [];Waldo = [];mySelect.options[mySelect.options.length] = new Option("Emerson schools",'all=Emerson'); mySelect.options[mySelect.options.length] = new Option("Magnolia schools",'all=Magnolia'); mySelect.options[mySelect.options.length] = new Option("Mcneil schools",'all=Mcneil'); mySelect.options[mySelect.options.length] = new Option("Taylor schools",'all=Taylor'); mySelect.options[mySelect.options.length] = new Option("Waldo schools",'all=Waldo'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Magnolia[Magnolia.length] = createMarker(new GPoint(-93.23474121,33.26923752),"
Central Elementary School
456 E North Street
Magnolia, AR 71753

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Central Elementary School",'Magnolia=' + Magnolia.length); Magnolia[Magnolia.length] = createMarker(new GPoint(-93.22380829,33.27116394),"
East-west Elementary School
1310 Hollensworth St
Magnolia, AR 71753

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("East-west Elementary School",'Magnolia=' + Magnolia.length); Emerson[Emerson.length] = createMarker(new GPoint(-93.19776154,33.09735870),"
Emerson Elementary School
508 West Main
Emerson, AR 71740

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Emerson Elementary School",'Emerson=' + Emerson.length); Emerson[Emerson.length] = createMarker(new GPoint(-93.19580078,33.09899902),"
Emerson High School
400 Church Street
Emerson, AR 71740

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Emerson High School",'Emerson=' + Emerson.length); Magnolia[Magnolia.length] = createMarker(new GPoint(-93.26519775,33.23419952),"
Magnolia High School
Po Box 649
Magnolia, AR 71753

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Magnolia High School",'Magnolia=' + Magnolia.length); Magnolia[Magnolia.length] = createMarker(new GPoint(-93.23361206,33.26906204),"
Magnolia Junior High School
540 E North Street
Magnolia, AR 71753

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Magnolia Junior High School",'Magnolia=' + Magnolia.length); Mcneil[Mcneil.length] = createMarker(new GPoint(-93.21298218,33.34873199),"
Mcneil Elementary School
202 Walnut St
Mcneil, AR 71752

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Mcneil Elementary School",'Mcneil=' + Mcneil.length); Mcneil[Mcneil.length] = createMarker(new GPoint(-93.21298218,33.34873199),"
Mcneil High School
202 Walnut St
Mcneil, AR 71752

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Mcneil High School",'Mcneil=' + Mcneil.length); Taylor[Taylor.length] = createMarker(new GPoint(-93.45542145,33.09933090),"
Taylor Elementary School
506 E Pine Street
Taylor, AR 71861

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Taylor Elementary School",'Taylor=' + Taylor.length); Taylor[Taylor.length] = createMarker(new GPoint(-93.45542145,33.09933090),"
Taylor High School
506 E Pine Street
Taylor, AR 71861

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Taylor High School",'Taylor=' + Taylor.length); Waldo[Waldo.length] = createMarker(new GPoint(-93.30200195,33.35910034),"
Waldo Elementary School
Po Box 367
Waldo, AR 71770

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Waldo Elementary School",'Waldo=' + Waldo.length); Waldo[Waldo.length] = createMarker(new GPoint(-93.30200195,33.35910034),"
Waldo High School
Po Box 367
Waldo, AR 71770

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Waldo High School",'Waldo=' + Waldo.length); Magnolia[Magnolia.length] = createMarker(new GPoint(-93.22640228,33.22977066),"
Walker Elementary School
655 Highway 79 South
Magnolia, AR 71753

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Walker Elementary School",'Magnolia=' + Magnolia.length); Magnolia[Magnolia.length] = createMarker(new GPoint(-93.22640228,33.22977066),"
Walker High School
655 Highway 79 South
Magnolia, AR 71753

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Walker High School",'Magnolia=' + Magnolia.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(Emerson); map.removeOverlays(Magnolia); map.removeOverlays(Mcneil); map.removeOverlays(Taylor); map.removeOverlays(Waldo); 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(Magnolia);map.removeOverlays(Emerson); map.removeOverlays(Magnolia); map.removeOverlays(Mcneil); map.removeOverlays(Taylor); map.removeOverlays(Waldo); map.addOverlays(Emerson); centerByArray(Emerson, false, false); cntMarker += Emerson.length; map.addOverlays(Magnolia); centerByArray(Magnolia, false, false); cntMarker += Magnolia.length; map.addOverlays(Mcneil); centerByArray(Mcneil, false, false); cntMarker += Mcneil.length; map.addOverlays(Taylor); centerByArray(Taylor, false, false); cntMarker += Taylor.length; map.addOverlays(Waldo); centerByArray(Waldo, false, false); cntMarker += Waldo.length; centerByArray(Magnolia,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'); } }