function addMarkers() { mySelect = document.getElementById('selection'); Clarksville = [];Lamar = [];Oark = [];Hartman = [];Coal_Hill = [];mySelect.options[mySelect.options.length] = new Option("Clarksville schools",'all=Clarksville'); mySelect.options[mySelect.options.length] = new Option("Coal Hill schools",'all=Coal_Hill'); mySelect.options[mySelect.options.length] = new Option("Hartman schools",'all=Hartman'); mySelect.options[mySelect.options.length] = new Option("Lamar schools",'all=Lamar'); mySelect.options[mySelect.options.length] = new Option("Oark schools",'all=Oark'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Clarksville[Clarksville.length] = createMarker(new GPoint(-93.48426819,35.46151733),"
Clarksville High School
1703 Clark Road
Clarksville, AR 72830

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Clarksville High School",'Clarksville=' + Clarksville.length); Clarksville[Clarksville.length] = createMarker(new GPoint(-93.48756409,35.46146393),"
Clarksville Junior High School
1801 Clark Road
Clarksville, AR 72830

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Clarksville Junior High School",'Clarksville=' + Clarksville.length); Clarksville[Clarksville.length] = createMarker(new GPoint(-93.48912048,35.46166229),"
Clarksville Primary School
2023 Clark Road
Clarksville, AR 72830

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Clarksville Primary School",'Clarksville=' + Clarksville.length); Clarksville[Clarksville.length] = createMarker(new GPoint(-93.48539734,35.46157074),"
Kraus Middle School
1901 Clark Road
Clarksville, AR 72830

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Kraus Middle School",'Clarksville=' + Clarksville.length); Lamar[Lamar.length] = createMarker(new GPoint(-93.39659882,35.43587875),"
Lamar Elementary School
301 Elberta St.
Lamar, AR 72846

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Lamar Elementary School",'Lamar=' + Lamar.length); Lamar[Lamar.length] = createMarker(new GPoint(-93.39659882,35.43587875),"
Lamar High School
301 Elberta St.
Lamar, AR 72846

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Lamar High School",'Lamar=' + Lamar.length); Lamar[Lamar.length] = createMarker(new GPoint(-93.39664800,35.43553600),"
Lamar Middle School
301 Elberta St
Lamar, AR 72846

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Lamar Middle School",'Lamar=' + Lamar.length); Oark[Oark.length] = createMarker(new GPoint(-93.58159637,35.70930099),"
Oark Elementary School
General Delivery
Oark, AR 72852

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Oark Elementary School",'Oark=' + Oark.length); Oark[Oark.length] = createMarker(new GPoint(-93.58159637,35.70930099),"
Oark High School
General Delivery
Oark, AR 72852

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Oark High School",'Oark=' + Oark.length); Clarksville[Clarksville.length] = createMarker(new GPoint(-93.48545074,35.46157455),"
Pyron Elementary School
1903 Clark Road
Clarksville, AR 72830

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Pyron Elementary School",'Clarksville=' + Clarksville.length); Hartman[Hartman.length] = createMarker(new GPoint(-93.61119843,35.44100189),"
Westside Elementary School
Po Box 230
Hartman, AR 72840

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Westside Elementary School",'Hartman=' + Hartman.length); Coal_Hill[Coal_Hill.length] = createMarker(new GPoint(-93.66680145,35.43230057),"
Westside High School
Po Box 189
Coal Hill, AR 72832

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Westside High School",'Coal_Hill=' + Coal_Hill.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(Clarksville); map.removeOverlays(Coal_Hill); map.removeOverlays(Hartman); map.removeOverlays(Lamar); map.removeOverlays(Oark); 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(Clarksville);map.removeOverlays(Clarksville); map.removeOverlays(Coal_Hill); map.removeOverlays(Hartman); map.removeOverlays(Lamar); map.removeOverlays(Oark); map.addOverlays(Clarksville); centerByArray(Clarksville, false, false); cntMarker += Clarksville.length; map.addOverlays(Coal_Hill); centerByArray(Coal_Hill, false, false); cntMarker += Coal_Hill.length; map.addOverlays(Hartman); centerByArray(Hartman, false, false); cntMarker += Hartman.length; map.addOverlays(Lamar); centerByArray(Lamar, false, false); cntMarker += Lamar.length; map.addOverlays(Oark); centerByArray(Oark, false, false); cntMarker += Oark.length; centerByArray(Clarksville,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'); } }