function addMarkers(){ mySelect = document.getElementById('selection'); Fayetteville = [];Marion = [];Fletcher = [];Charlotte = [];Goldsboro = [];Sanford = [];Garner = [];Salisbury = [];Chapel_Hill = [];Winston_Salem = [];Greensboro = [];Mocksville = [];mySelect.options[mySelect.options.length] = new Option("Chapel Hill schools",'all=Chapel_Hill'); mySelect.options[mySelect.options.length] = new Option("Charlotte schools",'all=Charlotte'); mySelect.options[mySelect.options.length] = new Option("Fayetteville schools",'all=Fayetteville'); mySelect.options[mySelect.options.length] = new Option("Fletcher schools",'all=Fletcher'); mySelect.options[mySelect.options.length] = new Option("Garner schools",'all=Garner'); mySelect.options[mySelect.options.length] = new Option("Goldsboro schools",'all=Goldsboro'); mySelect.options[mySelect.options.length] = new Option("Greensboro schools",'all=Greensboro'); mySelect.options[mySelect.options.length] = new Option("Marion schools",'all=Marion'); mySelect.options[mySelect.options.length] = new Option("Mocksville schools",'all=Mocksville'); mySelect.options[mySelect.options.length] = new Option("Salisbury schools",'all=Salisbury'); mySelect.options[mySelect.options.length] = new Option("Sanford schools",'all=Sanford'); mySelect.options[mySelect.options.length] = new Option("Winston Salem schools",'all=Winston_Salem'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Fayetteville[Fayetteville.length] = createMarker(new GPoint(-78.93350000,34.98880000),"
Adventist Christian School
Po Box 64397 2601 Lone Pine Dr
Fayetteville, NC 28306
Co-ed school, K-11
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Adventist Christian School",'Fayetteville=' + Fayetteville.length); Marion[Marion.length] = createMarker(new GPoint(-82.01617000,35.69525800),"
Brian Johnson Education Center
Po Box 984
Marion, NC 28752
All-boys school, 5-11
[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Brian Johnson Education Center",'Marion=' + Marion.length); Fletcher[Fletcher.length] = createMarker(new GPoint(-82.49500000,35.43930000),"
Captain Gilmer School
Po Box 5338
Fletcher, NC 28732
Co-ed school, PK-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Captain Gilmer School",'Fletcher=' + Fletcher.length); Charlotte[Charlotte.length] = createMarker(new GPoint(-80.84584100,35.23140200),"
Charlotte Jewish Day School
Po Box 79180
Charlotte, NC 28271
Co-ed school, PK-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Charlotte Jewish Day School",'Charlotte=' + Charlotte.length); Charlotte[Charlotte.length] = createMarker(new GPoint(-80.81107700,35.05823000),"
Chesterbrook Academy
7801 Ballantyne Commons Parkway
Charlotte, NC 28277
Co-ed school, K-2
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Chesterbrook Academy",'Charlotte=' + Charlotte.length); Goldsboro[Goldsboro.length] = createMarker(new GPoint(-86.29871600,33.27349600),"
Faith Christian Academy
1200 W Grantham Street
Goldsboro, NC 27530
Co-ed school, PK-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Faith Christian Academy",'Goldsboro=' + Goldsboro.length); Sanford[Sanford.length] = createMarker(new GPoint(-79.22248000,35.42797600),"
Grace Christian School
2601 Jefferson Davis Highway
Sanford, NC 27332
Co-ed school, K-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Grace Christian School",'Sanford=' + Sanford.length); Garner[Garner.length] = createMarker(new GPoint(-78.62506700,35.67670800),"
Lord Of Life Preschool & Kindergarten
2100 Buffaloe Road
Garner, NC 27529
Co-ed school, PK-1
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Lord Of Life Preschool & Kindergarten",'Garner=' + Garner.length); Salisbury[Salisbury.length] = createMarker(new GPoint(-80.48379300,35.70431300),"
North Hills Christian School
2970 W Innes Street
Salisbury, NC 28144
Co-ed school, PK-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("North Hills Christian School",'Salisbury=' + Salisbury.length); Chapel_Hill[Chapel_Hill.length] = createMarker(new GPoint(-79.02929500,35.90615000),"
St. Thomas More School
920 Carmichael Street
Chapel Hill, NC 27514
Co-ed school, PK-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("St. Thomas More School",'Chapel_Hill=' + Chapel_Hill.length); Winston_Salem[Winston_Salem.length] = createMarker(new GPoint(-80.23736300,36.08929100),"
Salem Academy
500 E Salem Avenue
Winston Salem, NC 27101
All-girls school, 9-12
[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Salem Academy",'Winston_Salem=' + Winston_Salem.length); Greensboro[Greensboro.length] = createMarker(new GPoint(-79.90728400,36.05391700),"
Shining Light Academy
4530 W Wendover Avenue
Greensboro, NC 27409
Co-ed school, PK-10
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Shining Light Academy",'Greensboro=' + Greensboro.length); Greensboro[Greensboro.length] = createMarker(new GPoint(-79.78772900,36.10284000),"
St Pius X Catholic School
2200 N Elm Street
Greensboro, NC 27408
Co-ed school, K-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("St Pius X Catholic School",'Greensboro=' + Greensboro.length); Mocksville[Mocksville.length] = createMarker(new GPoint(-80.53049000,35.82781800),"
Trinity Baptist Academy
2722 Us Highway 601 S
Mocksville, NC 27028
Co-ed school, 5-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Trinity Baptist Academy",'Mocksville=' + Mocksville.length); map.removeOverlays(Chapel_Hill); map.removeOverlays(Charlotte); map.removeOverlays(Fayetteville); map.removeOverlays(Fletcher); map.removeOverlays(Garner); map.removeOverlays(Goldsboro); map.removeOverlays(Greensboro); map.removeOverlays(Marion); map.removeOverlays(Mocksville); map.removeOverlays(Salisbury); map.removeOverlays(Sanford); map.removeOverlays(Winston_Salem); setTimeout(function(){map.addOverlays(Chapel_Hill)},1000); setTimeout(function(){map.addOverlays(Charlotte)},1000); setTimeout(function(){map.addOverlays(Fayetteville)},1000); setTimeout(function(){map.addOverlays(Fletcher)},1000); setTimeout(function(){map.addOverlays(Garner)},1000); setTimeout(function(){map.addOverlays(Goldsboro)},1000); setTimeout(function(){map.addOverlays(Greensboro)},1000); setTimeout(function(){map.addOverlays(Marion)},1000); setTimeout(function(){map.addOverlays(Mocksville)},1000); setTimeout(function(){map.addOverlays(Salisbury)},1000); setTimeout(function(){map.addOverlays(Sanford)},1000); setTimeout(function(){map.addOverlays(Winston_Salem)},1000); maxLng = -78.62506700; maxLat = 36.10284000; minLng = -86.29871600; minLat = 33.27349600; reCenterMap(); } // 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,11); /* 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(Chapel_Hill); map.removeOverlays(Charlotte); map.removeOverlays(Fayetteville); map.removeOverlays(Fletcher); map.removeOverlays(Garner); map.removeOverlays(Goldsboro); map.removeOverlays(Greensboro); map.removeOverlays(Marion); map.removeOverlays(Mocksville); map.removeOverlays(Salisbury); map.removeOverlays(Sanford); map.removeOverlays(Winston_Salem); 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(Fayetteville);map.removeOverlays(Chapel_Hill); map.removeOverlays(Charlotte); map.removeOverlays(Fayetteville); map.removeOverlays(Fletcher); map.removeOverlays(Garner); map.removeOverlays(Goldsboro); map.removeOverlays(Greensboro); map.removeOverlays(Marion); map.removeOverlays(Mocksville); map.removeOverlays(Salisbury); map.removeOverlays(Sanford); map.removeOverlays(Winston_Salem); map.addOverlays(Chapel_Hill); centerByArray(Chapel_Hill, false, false); cntMarker += Chapel_Hill.length; map.addOverlays(Charlotte); centerByArray(Charlotte, false, false); cntMarker += Charlotte.length; map.addOverlays(Fayetteville); centerByArray(Fayetteville, false, false); cntMarker += Fayetteville.length; map.addOverlays(Fletcher); centerByArray(Fletcher, false, false); cntMarker += Fletcher.length; map.addOverlays(Garner); centerByArray(Garner, false, false); cntMarker += Garner.length; map.addOverlays(Goldsboro); centerByArray(Goldsboro, false, false); cntMarker += Goldsboro.length; map.addOverlays(Greensboro); centerByArray(Greensboro, false, false); cntMarker += Greensboro.length; map.addOverlays(Marion); centerByArray(Marion, false, false); cntMarker += Marion.length; map.addOverlays(Mocksville); centerByArray(Mocksville, false, false); cntMarker += Mocksville.length; map.addOverlays(Salisbury); centerByArray(Salisbury, false, false); cntMarker += Salisbury.length; map.addOverlays(Sanford); centerByArray(Sanford, false, false); cntMarker += Sanford.length; map.addOverlays(Winston_Salem); centerByArray(Winston_Salem, false, false); cntMarker += Winston_Salem.length; centerByArray(Fayetteville,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///20830,20727,88,21142,35473,21066,20934,21128,21178,20830,20834,20727,20807,21001,88,21142,21174,35473,21232,21066,20934,/all'); //window.open('/map.php?type=2&schools=20830,20727,88,21142,35473,21066,20934,21128,21178,20830,20834,20727,20807,21001,88,21142,21174,35473,21232,21066,20934,&school_level=&radius=&zipcode=&school_type_search=&school_type_code='); } } function createMarker(point, label, icon) { var marker = new GMarker(point, icon); var html = label; GEvent.addListener(marker, "click", function() { marker.openInfoWindowHtml(html); }); return marker; }