function addMarkers() { mySelect = document.getElementById('selection'); Newton = [];Catawba = [];Vale = [];Claremont = [];Hickory = [];Maiden = [];Conover = [];Sherrills_Ford = [];mySelect.options[mySelect.options.length] = new Option("Catawba schools",'all=Catawba'); mySelect.options[mySelect.options.length] = new Option("Claremont schools",'all=Claremont'); mySelect.options[mySelect.options.length] = new Option("Conover schools",'all=Conover'); mySelect.options[mySelect.options.length] = new Option("Hickory schools",'all=Hickory'); mySelect.options[mySelect.options.length] = new Option("Maiden schools",'all=Maiden'); mySelect.options[mySelect.options.length] = new Option("Newton schools",'all=Newton'); mySelect.options[mySelect.options.length] = new Option("Sherrills Ford schools",'all=Sherrills_Ford'); mySelect.options[mySelect.options.length] = new Option("Vale schools",'all=Vale'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Newton[Newton.length] = createMarker(new GPoint(-81.12824249,35.63122177),"
",iconRd); mySelect.options[mySelect.options.length] = new Option("Balls Creek Elementary School",'Newton=' + Newton.length); Catawba[Catawba.length] = createMarker(new GPoint(-81.05960083,35.68610001),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Bandys High School",'Catawba=' + Catawba.length); Vale[Vale.length] = createMarker(new GPoint(-81.42120361,35.55039978),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Banoak Elementary School",'Vale=' + Vale.length); Newton[Newton.length] = createMarker(new GPoint(-81.23439789,35.65039825),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Blackburn Elementary School",'Newton=' + Newton.length); Claremont[Claremont.length] = createMarker(new GPoint(-81.11064148,35.74196625),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Bunker Hill High School",'Claremont=' + Claremont.length); Catawba[Catawba.length] = createMarker(new GPoint(-81.07620239,35.70273972),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Catawba Intermediate",'Catawba=' + Catawba.length); Hickory[Hickory.length] = createMarker(new GPoint(-81.35592200,35.69237000),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Catawba Valley Early College High School",'Hickory=' + Hickory.length); Hickory[Hickory.length] = createMarker(new GPoint(-81.33087921,35.74293518),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Catawba Valley High School",'Hickory=' + Hickory.length); Maiden[Maiden.length] = createMarker(new GPoint(-81.15625000,35.58747864),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Charles H Tuttle Middle School",'Maiden=' + Maiden.length); Claremont[Claremont.length] = createMarker(new GPoint(-81.14029694,35.72589874),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Claremont Elementary School",'Claremont=' + Claremont.length); Hickory[Hickory.length] = createMarker(new GPoint(-81.32659912,35.76499939),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Clyde Campbell Elementary School",'Hickory=' + Hickory.length); Conover[Conover.length] = createMarker(new GPoint(-81.22069550,35.70151138),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Conover Special Education",'Conover=' + Conover.length); Claremont[Claremont.length] = createMarker(new GPoint(-81.15452576,35.71735764),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Engelmann School Of Art And Sci",'Claremont=' + Claremont.length); Newton[Newton.length] = createMarker(new GPoint(-81.35803986,35.60586166),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Fred T Foard High School",'Newton=' + Newton.length); Hickory[Hickory.length] = createMarker(new GPoint(-81.33989716,35.73283005),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Frye School",'Hickory=' + Hickory.length); Hickory[Hickory.length] = createMarker(new GPoint(-81.38364400,35.72936100),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Grandview Middle School",'Hickory=' + Hickory.length); Hickory[Hickory.length] = createMarker(new GPoint(-81.32659912,35.76499939),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Harry M Arndt Middle School",'Hickory=' + Hickory.length); Hickory[Hickory.length] = createMarker(new GPoint(-81.33295441,35.74945068),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Hickory High School",'Hickory=' + Hickory.length); Newton[Newton.length] = createMarker(new GPoint(-81.35784912,35.60568619),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Jacobs Fork Middle School",'Newton=' + Newton.length); Hickory[Hickory.length] = createMarker(new GPoint(-81.38027191,35.72757339),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Longview Elementary School",'Hickory=' + Hickory.length); Conover[Conover.length] = createMarker(new GPoint(-81.33067322,35.80836487),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Lyle Creek Elementary School",'Conover=' + Conover.length); Maiden[Maiden.length] = createMarker(new GPoint(-81.21250153,35.57787704),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Maiden Elementary School",'Maiden=' + Maiden.length); Maiden[Maiden.length] = createMarker(new GPoint(-81.21688080,35.57973099),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Maiden High School",'Maiden=' + Maiden.length); Claremont[Claremont.length] = createMarker(new GPoint(-81.09722137,35.67012787),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Mill Creek Middle School",'Claremont=' + Claremont.length); Hickory[Hickory.length] = createMarker(new GPoint(-81.38487244,35.66369247),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Mountain View Elementary School",'Hickory=' + Hickory.length); Newton[Newton.length] = createMarker(new GPoint(-81.22101600,35.66741200),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Newton-conover Health/science",'Newton=' + Newton.length); Newton[Newton.length] = createMarker(new GPoint(-81.22380829,35.67753983),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Newton-conover High School",'Newton=' + Newton.length); Newton[Newton.length] = createMarker(new GPoint(-81.22021484,35.69054794),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Newton-conover Middle School",'Newton=' + Newton.length); Hickory[Hickory.length] = createMarker(new GPoint(-81.32577515,35.76824188),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Northview Middle School",'Hickory=' + Hickory.length); Hickory[Hickory.length] = createMarker(new GPoint(-81.34426880,35.73711777),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Oakwood Elementary School",'Hickory=' + Hickory.length); Claremont[Claremont.length] = createMarker(new GPoint(-81.16054535,35.73331451),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Oxford Elementary School",'Claremont=' + Claremont.length); Claremont[Claremont.length] = createMarker(new GPoint(-81.11109924,35.74214935),"",iconBl); mySelect.options[mySelect.options.length] = new Option("River Bend Middle School",'Claremont=' + Claremont.length); Conover[Conover.length] = createMarker(new GPoint(-81.27320862,35.73557663),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Saint Stephens Elementary School",'Conover=' + Conover.length); Hickory[Hickory.length] = createMarker(new GPoint(-81.32659912,35.76499939),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Saint Stephens High School",'Hickory=' + Hickory.length); Sherrills_Ford[Sherrills_Ford.length] = createMarker(new GPoint(-80.99539948,35.59479904),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Sherrills Ford Elementary School",'Sherrills_Ford=' + Sherrills_Ford.length); Conover[Conover.length] = createMarker(new GPoint(-81.19888306,35.71810913),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Shuford Elementary School",'Conover=' + Conover.length); Newton[Newton.length] = createMarker(new GPoint(-81.22606659,35.66509628),"",iconRd); mySelect.options[mySelect.options.length] = new Option("South Newton Elementary School",'Newton=' + Newton.length); Hickory[Hickory.length] = createMarker(new GPoint(-81.38689423,35.71021652),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Southwest Elementary School",'Hickory=' + Hickory.length); Newton[Newton.length] = createMarker(new GPoint(-81.26884460,35.64271927),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Startown Elementary School",'Newton=' + Newton.length); Hickory[Hickory.length] = createMarker(new GPoint(-81.29901886,35.73176956),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Sweetwater Elementary School",'Hickory=' + Hickory.length); Newton[Newton.length] = createMarker(new GPoint(-81.22139740,35.68057251),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Thornton Elementary School",'Newton=' + Newton.length); Hickory[Hickory.length] = createMarker(new GPoint(-81.33741760,35.75336456),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Viewmont Elementary School",'Hickory=' + Hickory.length); Hickory[Hickory.length] = createMarker(new GPoint(-81.32326508,35.78076172),"",iconRd); mySelect.options[mySelect.options.length] = new Option("W M Jenkins Elementary School",'Hickory=' + Hickory.length); Hickory[Hickory.length] = createMarker(new GPoint(-81.25127411,35.74149323),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Webb A Murray Elementary School",'Hickory=' + Hickory.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(Catawba); map.removeOverlays(Claremont); map.removeOverlays(Conover); map.removeOverlays(Hickory); map.removeOverlays(Maiden); map.removeOverlays(Newton); map.removeOverlays(Sherrills_Ford); map.removeOverlays(Vale); 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(Newton);map.removeOverlays(Catawba); map.removeOverlays(Claremont); map.removeOverlays(Conover); map.removeOverlays(Hickory); map.removeOverlays(Maiden); map.removeOverlays(Newton); map.removeOverlays(Sherrills_Ford); map.removeOverlays(Vale); map.addOverlays(Catawba); centerByArray(Catawba, false, false); cntMarker += Catawba.length; map.addOverlays(Claremont); centerByArray(Claremont, false, false); cntMarker += Claremont.length; map.addOverlays(Conover); centerByArray(Conover, false, false); cntMarker += Conover.length; map.addOverlays(Hickory); centerByArray(Hickory, false, false); cntMarker += Hickory.length; map.addOverlays(Maiden); centerByArray(Maiden, false, false); cntMarker += Maiden.length; map.addOverlays(Newton); centerByArray(Newton, false, false); cntMarker += Newton.length; map.addOverlays(Sherrills_Ford); centerByArray(Sherrills_Ford, false, false); cntMarker += Sherrills_Ford.length; map.addOverlays(Vale); centerByArray(Vale, false, false); cntMarker += Vale.length; centerByArray(Newton,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'); } }