function addMarkers(){ mySelect = document.getElementById('selection'); Windsor = [];Charlotte = [];Statesville = [];Asheville = [];Gastonia = [];Winston_Salem = [];Concord = [];Wallace = [];Raleigh = [];Stanley = [];Goldsboro = [];Wanchese = [];mySelect.options[mySelect.options.length] = new Option("Asheville schools",'all=Asheville'); mySelect.options[mySelect.options.length] = new Option("Charlotte schools",'all=Charlotte'); mySelect.options[mySelect.options.length] = new Option("Concord schools",'all=Concord'); mySelect.options[mySelect.options.length] = new Option("Gastonia schools",'all=Gastonia'); mySelect.options[mySelect.options.length] = new Option("Goldsboro schools",'all=Goldsboro'); mySelect.options[mySelect.options.length] = new Option("Raleigh schools",'all=Raleigh'); mySelect.options[mySelect.options.length] = new Option("Stanley schools",'all=Stanley'); mySelect.options[mySelect.options.length] = new Option("Statesville schools",'all=Statesville'); mySelect.options[mySelect.options.length] = new Option("Wallace schools",'all=Wallace'); mySelect.options[mySelect.options.length] = new Option("Wanchese schools",'all=Wanchese'); mySelect.options[mySelect.options.length] = new Option("Windsor schools",'all=Windsor'); mySelect.options[mySelect.options.length] = new Option("Winston Salem schools",'all=Winston_Salem'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Windsor[Windsor.length] = createMarker(new GPoint(-76.94420300,36.11153700),"
Bethel Assembly Christian Academy
105 Askewville Bryant Street
Windsor, NC 27983
Co-ed school, PK-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Bethel Assembly Christian Academy",'Windsor=' + Windsor.length); Charlotte[Charlotte.length] = createMarker(new GPoint(-80.97725100,35.11639700),"
Cathedral Of The Cross Chr School
13925 Erwin Rd.
Charlotte, NC 28273
Co-ed school, KG-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Cathedral Of The Cross Chr School",'Charlotte=' + Charlotte.length); Statesville[Statesville.length] = createMarker(new GPoint(-80.85539700,35.78196400),"
Cornerstone Christian Academy
650 Glover Street
Statesville, NC 28625
Co-ed school, PK-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Cornerstone Christian Academy",'Statesville=' + Statesville.length); Asheville[Asheville.length] = createMarker(new GPoint(-82.60750900,35.56418800),"
Crossroads Christian Academy
20 S Bear Creek Rd
Asheville, NC 28806
Co-ed school, PK-4
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Crossroads Christian Academy",'Asheville=' + Asheville.length); Gastonia[Gastonia.length] = createMarker(new GPoint(-81.24215900,35.19901000),"
First Assembly Christian Academy
Po Box 12367
Gastonia, NC 28052
Co-ed school, PK-K
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("First Assembly Christian Academy",'Gastonia=' + Gastonia.length); Winston_Salem[Winston_Salem.length] = createMarker(new GPoint(-80.27678100,36.14177800),"
First Assembly Christian School
3730 University Parkway
Winston Salem, NC 27106
Co-ed school, PK-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("First Assembly Christian School",'Winston_Salem=' + Winston_Salem.length); Concord[Concord.length] = createMarker(new GPoint(-80.60785600,35.39947500),"
First Assembly Christian School
154 Warren C Coleman Blvd N
Concord, NC 28027
Co-ed school, PK-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("First Assembly Christian School",'Concord=' + Concord.length); Wallace[Wallace.length] = createMarker(new GPoint(-77.99820000,34.73445100),"
New Hope Christian Academy
212 West Main Street
Wallace, NC 28466
Co-ed school, PK-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("New Hope Christian Academy",'Wallace=' + Wallace.length); Raleigh[Raleigh.length] = createMarker(new GPoint(-78.53233000,35.82686300),"
Raleigh Chr Community School
7000 Destiny Dr
Raleigh, NC 27604
school, PK-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Raleigh Chr Community School",'Raleigh=' + Raleigh.length); Stanley[Stanley.length] = createMarker(new GPoint(-81.05610000,35.38490000),"
Stanley Christian Academy
Po Box 307
Stanley, NC 28164
Co-ed school, PK-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Stanley Christian Academy",'Stanley=' + Stanley.length); Goldsboro[Goldsboro.length] = createMarker(new GPoint(-77.93698700,35.37646200),"
Summit Christian Academy
3000 Summit Rd
Goldsboro, NC 27534
Co-ed school, PK-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Summit Christian Academy",'Goldsboro=' + Goldsboro.length); Charlotte[Charlotte.length] = createMarker(new GPoint(-80.77544000,35.09075900),"
United Faith Christian Academy
8617 Providence Road
Charlotte, NC 28277
Co-ed school, PK-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("United Faith Christian Academy",'Charlotte=' + Charlotte.length); Wanchese[Wanchese.length] = createMarker(new GPoint(-75.64942000,35.84466800),"
Wanchese Christian Academy
Po Box 201
Wanchese, NC 27981
Co-ed school, PK-11
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Wanchese Christian Academy",'Wanchese=' + Wanchese.length); map.removeOverlays(Asheville); map.removeOverlays(Charlotte); map.removeOverlays(Concord); map.removeOverlays(Gastonia); map.removeOverlays(Goldsboro); map.removeOverlays(Raleigh); map.removeOverlays(Stanley); map.removeOverlays(Statesville); map.removeOverlays(Wallace); map.removeOverlays(Wanchese); map.removeOverlays(Windsor); map.removeOverlays(Winston_Salem); setTimeout(function(){map.addOverlays(Asheville)},1000); setTimeout(function(){map.addOverlays(Charlotte)},1000); setTimeout(function(){map.addOverlays(Concord)},1000); setTimeout(function(){map.addOverlays(Gastonia)},1000); setTimeout(function(){map.addOverlays(Goldsboro)},1000); setTimeout(function(){map.addOverlays(Raleigh)},1000); setTimeout(function(){map.addOverlays(Stanley)},1000); setTimeout(function(){map.addOverlays(Statesville)},1000); setTimeout(function(){map.addOverlays(Wallace)},1000); setTimeout(function(){map.addOverlays(Wanchese)},1000); setTimeout(function(){map.addOverlays(Windsor)},1000); setTimeout(function(){map.addOverlays(Winston_Salem)},1000); maxLng = -75.64942000; maxLat = 36.14177800; minLng = -82.60750900; minLat = 34.73445100; 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(Asheville); map.removeOverlays(Charlotte); map.removeOverlays(Concord); map.removeOverlays(Gastonia); map.removeOverlays(Goldsboro); map.removeOverlays(Raleigh); map.removeOverlays(Stanley); map.removeOverlays(Statesville); map.removeOverlays(Wallace); map.removeOverlays(Wanchese); map.removeOverlays(Windsor); 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(Windsor);map.removeOverlays(Asheville); map.removeOverlays(Charlotte); map.removeOverlays(Concord); map.removeOverlays(Gastonia); map.removeOverlays(Goldsboro); map.removeOverlays(Raleigh); map.removeOverlays(Stanley); map.removeOverlays(Statesville); map.removeOverlays(Wallace); map.removeOverlays(Wanchese); map.removeOverlays(Windsor); map.removeOverlays(Winston_Salem); map.addOverlays(Asheville); centerByArray(Asheville, false, false); cntMarker += Asheville.length; map.addOverlays(Charlotte); centerByArray(Charlotte, false, false); cntMarker += Charlotte.length; map.addOverlays(Concord); centerByArray(Concord, false, false); cntMarker += Concord.length; map.addOverlays(Gastonia); centerByArray(Gastonia, false, false); cntMarker += Gastonia.length; map.addOverlays(Goldsboro); centerByArray(Goldsboro, false, false); cntMarker += Goldsboro.length; map.addOverlays(Raleigh); centerByArray(Raleigh, false, false); cntMarker += Raleigh.length; map.addOverlays(Stanley); centerByArray(Stanley, false, false); cntMarker += Stanley.length; map.addOverlays(Statesville); centerByArray(Statesville, false, false); cntMarker += Statesville.length; map.addOverlays(Wallace); centerByArray(Wallace, false, false); cntMarker += Wallace.length; map.addOverlays(Wanchese); centerByArray(Wanchese, false, false); cntMarker += Wanchese.length; map.addOverlays(Windsor); centerByArray(Windsor, false, false); cntMarker += Windsor.length; map.addOverlays(Winston_Salem); centerByArray(Winston_Salem, false, false); cntMarker += Winston_Salem.length; centerByArray(Windsor,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///20820,21241,20904,21186,20854,21055,33814,20765,21111,20820,21241,20904,20902,20816,21103,21186,20854,21055,33814,20765,20903,/all'); //window.open('/map.php?type=2&schools=20820,21241,20904,21186,20854,21055,33814,20765,21111,20820,21241,20904,20902,20816,21103,21186,20854,21055,33814,20765,20903,&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; }