function addMarkers() { mySelect = document.getElementById('selection'); Rocky_Mount = [];Tarboro = [];Battleboro = [];Pinetops = [];mySelect.options[mySelect.options.length] = new Option("Battleboro schools",'all=Battleboro'); mySelect.options[mySelect.options.length] = new Option("Pinetops schools",'all=Pinetops'); mySelect.options[mySelect.options.length] = new Option("Rocky Mount schools",'all=Rocky_Mount'); mySelect.options[mySelect.options.length] = new Option("Tarboro schools",'all=Tarboro'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Rocky_Mount[Rocky_Mount.length] = createMarker(new GPoint(-77.77098083,35.94992828),"
Baskerville Elementary School
1100 Stokes Ave
Rocky Mount, NC 27801

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Baskerville Elementary School",'Rocky_Mount=' + Rocky_Mount.length); Tarboro[Tarboro.length] = createMarker(new GPoint(-77.53645325,35.90722656),"
C B Martin Middle School
400 E Johnston Street
Tarboro, NC 27886

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("C B Martin Middle School",'Tarboro=' + Tarboro.length); Tarboro[Tarboro.length] = createMarker(new GPoint(-77.53732300,35.90794373),"
Center For Ed Achievement
152 Nc 97 West
Tarboro, NC 27886

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Center For Ed Achievement",'Tarboro=' + Tarboro.length); Battleboro[Battleboro.length] = createMarker(new GPoint(-77.75110900,36.05110100),"
Coker-wimberly Elementary School
1619 Nc 97 West
Battleboro, NC 27809

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Coker-wimberly Elementary School",'Battleboro=' + Battleboro.length); Rocky_Mount[Rocky_Mount.length] = createMarker(new GPoint(-77.77577209,35.93614197),"
D S Johnson Elementary School
600 Fairview Rd
Rocky Mount, NC 27801

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("D S Johnson Elementary School",'Rocky_Mount=' + Rocky_Mount.length); Tarboro[Tarboro.length] = createMarker(new GPoint(-77.57076600,35.88269600),"
Edgecombe Early College High School
2009 West Wilson St
Tarboro, NC 27886

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Edgecombe Early College High School",'Tarboro=' + Tarboro.length); Rocky_Mount[Rocky_Mount.length] = createMarker(new GPoint(-77.77559662,35.93606186),"
Fairview Early Childhood Center
Fairview Road
Rocky Mount, NC 27801

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Fairview Early Childhood Center",'Rocky_Mount=' + Rocky_Mount.length); Rocky_Mount[Rocky_Mount.length] = createMarker(new GPoint(-77.74269867,35.93199921),"
G W Bulluck Elementary School
3090 Bulluck School Road
Rocky Mount, NC 27801

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("G W Bulluck Elementary School",'Rocky_Mount=' + Rocky_Mount.length); Pinetops[Pinetops.length] = createMarker(new GPoint(-77.65699768,35.79710007),"
G W Carver Elementary School
Po Box 48
Pinetops, NC 27864

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("G W Carver Elementary School",'Pinetops=' + Pinetops.length); Rocky_Mount[Rocky_Mount.length] = createMarker(new GPoint(-77.76959991,35.95130539),"
J W Parker Middle School
1500 E Virginia St
Rocky Mount, NC 27801

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("J W Parker Middle School",'Rocky_Mount=' + Rocky_Mount.length); Tarboro[Tarboro.length] = createMarker(new GPoint(-77.56680298,35.95669937),"
North Edgecombe High School
7589 Nc 33-nw
Tarboro, NC 27886

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("North Edgecombe High School",'Tarboro=' + Tarboro.length); Rocky_Mount[Rocky_Mount.length] = createMarker(new GPoint(-77.78480530,35.94262695),"
O R Pope Elementary School
226 Coleman Ave
Rocky Mount, NC 27801

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("O R Pope Elementary School",'Rocky_Mount=' + Rocky_Mount.length); Tarboro[Tarboro.length] = createMarker(new GPoint(-77.55339813,35.90219879),"
Pattillo A+ School
Po Box 609
Tarboro, NC 27886

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Pattillo A+ School",'Tarboro=' + Tarboro.length); Battleboro[Battleboro.length] = createMarker(new GPoint(-77.74240112,36.04199982),"
Phillips Middle School
1407 Leggett-battleboro Road
Battleboro, NC 27809

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Phillips Middle School",'Battleboro=' + Battleboro.length); Tarboro[Tarboro.length] = createMarker(new GPoint(-77.52711487,35.88726044),"
Princeville Montessori
306 Walston Street
Tarboro, NC 27886

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Princeville Montessori",'Tarboro=' + Tarboro.length); Tarboro[Tarboro.length] = createMarker(new GPoint(-77.55339813,35.90219879),"
Roberson Elementary School
Po Box 370
Tarboro, NC 27886

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Roberson Elementary School",'Tarboro=' + Tarboro.length); Pinetops[Pinetops.length] = createMarker(new GPoint(-77.63870239,35.78960037),"
South Edgecombe Middle School
230 Pinetops-crisp Road
Pinetops, NC 27864

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("South Edgecombe Middle School",'Pinetops=' + Pinetops.length); Pinetops[Pinetops.length] = createMarker(new GPoint(-77.63870239,35.78960037),"
Southwest Edgecombe High School
5912 Nc 43 North
Pinetops, NC 27864

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Southwest Edgecombe High School",'Pinetops=' + Pinetops.length); Tarboro[Tarboro.length] = createMarker(new GPoint(-77.55163574,35.90958786),"
Stocks Elementary School
400 Hope Lodge Street
Tarboro, NC 27886

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Stocks Elementary School",'Tarboro=' + Tarboro.length); Tarboro[Tarboro.length] = createMarker(new GPoint(-77.55702209,35.90106201),"
Tarboro High School
1400 Howard Avenue
Tarboro, NC 27886

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Tarboro High School",'Tarboro=' + Tarboro.length); Rocky_Mount[Rocky_Mount.length] = createMarker(new GPoint(-77.80599976,35.90739822),"
West Edgecombe Middle School
6301 Nobles Mill Pond Road
Rocky Mount, NC 27801

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("West Edgecombe Middle School",'Rocky_Mount=' + Rocky_Mount.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(Battleboro); map.removeOverlays(Pinetops); map.removeOverlays(Rocky_Mount); map.removeOverlays(Tarboro); 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(Rocky_Mount);map.removeOverlays(Battleboro); map.removeOverlays(Pinetops); map.removeOverlays(Rocky_Mount); map.removeOverlays(Tarboro); map.addOverlays(Battleboro); centerByArray(Battleboro, false, false); cntMarker += Battleboro.length; map.addOverlays(Pinetops); centerByArray(Pinetops, false, false); cntMarker += Pinetops.length; map.addOverlays(Rocky_Mount); centerByArray(Rocky_Mount, false, false); cntMarker += Rocky_Mount.length; map.addOverlays(Tarboro); centerByArray(Tarboro, false, false); cntMarker += Tarboro.length; centerByArray(Rocky_Mount,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'); } }