function addMarkers() { mySelect = document.getElementById('selection'); Lincolnton = [];Denver = [];Iron_Station = [];Vale = [];mySelect.options[mySelect.options.length] = new Option("Denver schools",'all=Denver'); mySelect.options[mySelect.options.length] = new Option("Iron Station schools",'all=Iron_Station'); mySelect.options[mySelect.options.length] = new Option("Lincolnton schools",'all=Lincolnton'); mySelect.options[mySelect.options.length] = new Option("Vale schools",'all=Vale'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Lincolnton[Lincolnton.length] = createMarker(new GPoint(-81.20846558,35.47778702),"
Asbury School
221 Salem Church Road
Lincolnton, NC 28092

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Asbury School",'Lincolnton=' + Lincolnton.length); Lincolnton[Lincolnton.length] = createMarker(new GPoint(-81.26287079,35.47680664),"
Battleground Elementary School
201 Jeb Seagle Dr
Lincolnton, NC 28092

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Battleground Elementary School",'Lincolnton=' + Lincolnton.length); Denver[Denver.length] = createMarker(new GPoint(-81.02182770,35.45347977),"
Catawba Springs Elementary School
206 North Little Egypt Rd
Denver, NC 28037

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Catawba Springs Elementary School",'Denver=' + Denver.length); Denver[Denver.length] = createMarker(new GPoint(-81.02588654,35.45331955),"
East Lincoln High School
6471 Hwy 73
Denver, NC 28037

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("East Lincoln High School",'Denver=' + Denver.length); Iron_Station[Iron_Station.length] = createMarker(new GPoint(-81.09339905,35.47241592),"
East Lincoln Middle School
4137 Hwy 73
Iron Station, NC 28080

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("East Lincoln Middle School",'Iron_Station=' + Iron_Station.length); Lincolnton[Lincolnton.length] = createMarker(new GPoint(-81.23915100,35.47787094),"
G E Massey Elementary School
130 Newbold St
Lincolnton, NC 28092

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("G E Massey Elementary School",'Lincolnton=' + Lincolnton.length); Iron_Station[Iron_Station.length] = createMarker(new GPoint(-81.16803741,35.46023178),"
Iron Station Elementary School
4207 Hwy 27 E
Iron Station, NC 28080

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Iron Station Elementary School",'Iron_Station=' + Iron_Station.length); Lincolnton[Lincolnton.length] = createMarker(new GPoint(-81.23940277,35.47579956),"
Lincoln Charter
133 Eagles Nest Road
Lincolnton, NC 28092

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Lincoln Charter",'Lincolnton=' + Lincolnton.length); Lincolnton[Lincolnton.length] = createMarker(new GPoint(-81.23940277,35.47579956),"
Lincoln Co School Of Technology
1 Timken Dr
Lincolnton, NC 28092

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Lincoln Co School Of Technology",'Lincolnton=' + Lincolnton.length); Lincolnton[Lincolnton.length] = createMarker(new GPoint(-81.25894928,35.47966766),"
Lincolnton High School
803 N Aspen St
Lincolnton, NC 28092

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Lincolnton High School",'Lincolnton=' + Lincolnton.length); Lincolnton[Lincolnton.length] = createMarker(new GPoint(-81.26518250,35.47832489),"
Lincolnton Middle School
301 Jeb Seagle Dr
Lincolnton, NC 28092

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Lincolnton Middle School",'Lincolnton=' + Lincolnton.length); Lincolnton[Lincolnton.length] = createMarker(new GPoint(-81.27584076,35.44979095),"
Love Memorial Elementary School
1463 Love Memorial Sch Rd
Lincolnton, NC 28092

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Love Memorial Elementary School",'Lincolnton=' + Lincolnton.length); Vale[Vale.length] = createMarker(new GPoint(-81.45371246,35.49614334),"
North Brook Elementary School
642 Hwy 274
Vale, NC 28168

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("North Brook Elementary School",'Vale=' + Vale.length); Lincolnton[Lincolnton.length] = createMarker(new GPoint(-81.23940277,35.47579956),"
North Lincoln High School
2737 Lee Lawing Road
Lincolnton, NC 28092

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("North Lincoln High School",'Lincolnton=' + Lincolnton.length); Lincolnton[Lincolnton.length] = createMarker(new GPoint(-81.13592529,35.51947784),"
Pumpkin Center Elementary School
3970 King Wilkinson Road
Lincolnton, NC 28092

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Pumpkin Center Elementary School",'Lincolnton=' + Lincolnton.length); Lincolnton[Lincolnton.length] = createMarker(new GPoint(-81.13570404,35.51931000),"
Pumpkin Center Middle School
3980 King Wilkinson Road
Lincolnton, NC 28092

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Pumpkin Center Middle School",'Lincolnton=' + Lincolnton.length); Denver[Denver.length] = createMarker(new GPoint(-81.00630188,35.50260162),"
Rock Springs Elementary School
3633 Hwy 16 N
Denver, NC 28037

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Rock Springs Elementary School",'Denver=' + Denver.length); Lincolnton[Lincolnton.length] = createMarker(new GPoint(-81.24553680,35.46376038),"
S Ray Lowder Elementary School
350 Kennedy Dr
Lincolnton, NC 28092

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("S Ray Lowder Elementary School",'Lincolnton=' + Lincolnton.length); Denver[Denver.length] = createMarker(new GPoint(-81.00550079,35.50579834),"
St James Elementary School
1774 St James Church Road
Denver, NC 28037

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("St James Elementary School",'Denver=' + Denver.length); Vale[Vale.length] = createMarker(new GPoint(-81.36758423,35.51773453),"
Union Elementary School
4875 Reepsville Rd
Vale, NC 28168

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Union Elementary School",'Vale=' + Vale.length); Lincolnton[Lincolnton.length] = createMarker(new GPoint(-81.38815308,35.48577881),"
West Lincoln High School
172 Shoal Rd
Lincolnton, NC 28092

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("West Lincoln High School",'Lincolnton=' + Lincolnton.length); Lincolnton[Lincolnton.length] = createMarker(new GPoint(-81.38739014,35.48413467),"
West Lincoln Middle School
260 Shoal Rd
Lincolnton, NC 28092

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("West Lincoln Middle School",'Lincolnton=' + Lincolnton.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(Denver); map.removeOverlays(Iron_Station); map.removeOverlays(Lincolnton); 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(Lincolnton);map.removeOverlays(Denver); map.removeOverlays(Iron_Station); map.removeOverlays(Lincolnton); map.removeOverlays(Vale); map.addOverlays(Denver); centerByArray(Denver, false, false); cntMarker += Denver.length; map.addOverlays(Iron_Station); centerByArray(Iron_Station, false, false); cntMarker += Iron_Station.length; map.addOverlays(Lincolnton); centerByArray(Lincolnton, false, false); cntMarker += Lincolnton.length; map.addOverlays(Vale); centerByArray(Vale, false, false); cntMarker += Vale.length; centerByArray(Lincolnton,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'); } }