function addMarkers()
{
mySelect = document.getElementById('selection');
Villa_Rica = [];Bowdon = [];Carrollton = [];Mount_Zion = [];Roopville = [];Temple = [];Whitesburg = [];mySelect.options[mySelect.options.length] = new Option("Bowdon schools",'all=Bowdon');
mySelect.options[mySelect.options.length] = new Option("Carrollton schools",'all=Carrollton');
mySelect.options[mySelect.options.length] = new Option("Mount Zion schools",'all=Mount_Zion');
mySelect.options[mySelect.options.length] = new Option("Roopville schools",'all=Roopville');
mySelect.options[mySelect.options.length] = new Option("Temple schools",'all=Temple');
mySelect.options[mySelect.options.length] = new Option("Villa Rica schools",'all=Villa_Rica');
mySelect.options[mySelect.options.length] = new Option("Whitesburg schools",'all=Whitesburg');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Villa_Rica[Villa_Rica.length] = createMarker(new GPoint(-84.93815613,33.68929291),"
",iconBl);
mySelect.options[mySelect.options.length] = new Option("Bay Springs Middle School",'Villa_Rica=' + Villa_Rica.length);
Bowdon[Bowdon.length] = createMarker(new GPoint(-85.25363922,33.52643585),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Bowdon Elementary School",'Bowdon=' + Bowdon.length);
Bowdon[Bowdon.length] = createMarker(new GPoint(-85.26062775,33.53741837),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bowdon High School",'Bowdon=' + Bowdon.length);
Carrollton[Carrollton.length] = createMarker(new GPoint(-85.08037800,33.58053900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Burwell Psychoeducational Program",'Carrollton=' + Carrollton.length);
Bowdon[Bowdon.length] = createMarker(new GPoint(-85.23114014,33.53179932),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Carroll County/carrollton City Alternative",'Bowdon=' + Bowdon.length);
Carrollton[Carrollton.length] = createMarker(new GPoint(-85.08263397,33.55764389),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Carrollton Elementary School",'Carrollton=' + Carrollton.length);
Carrollton[Carrollton.length] = createMarker(new GPoint(-85.07963562,33.56733322),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Carrollton High School",'Carrollton=' + Carrollton.length);
Carrollton[Carrollton.length] = createMarker(new GPoint(-85.08296204,33.55814743),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Carrollton Junior High School",'Carrollton=' + Carrollton.length);
Carrollton[Carrollton.length] = createMarker(new GPoint(-10.00000000,10.00000000),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Carrollton Middle-upper Elementary School",'Carrollton=' + Carrollton.length);
Carrollton[Carrollton.length] = createMarker(new GPoint(-85.06934357,33.54141235),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Central Elementary School",'Carrollton=' + Carrollton.length);
Bowdon[Bowdon.length] = createMarker(new GPoint(-85.25123596,33.53889847),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Central Evening Program High School",'Bowdon=' + Bowdon.length);
Carrollton[Carrollton.length] = createMarker(new GPoint(-85.07688904,33.55510330),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Central High School",'Carrollton=' + Carrollton.length);
Carrollton[Carrollton.length] = createMarker(new GPoint(-85.06211090,33.53670502),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Central Middle School",'Carrollton=' + Carrollton.length);
Villa_Rica[Villa_Rica.length] = createMarker(new GPoint(-84.94715100,33.67922900),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Ithica Elementary School",'Villa_Rica=' + Villa_Rica.length);
Bowdon[Bowdon.length] = createMarker(new GPoint(-85.23053741,33.56347275),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Jonesville Middle School",'Bowdon=' + Bowdon.length);
Bowdon[Bowdon.length] = createMarker(new GPoint(-10.00000000,10.00000000),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Kidspeace",'Bowdon=' + Bowdon.length);
Mount_Zion[Mount_Zion.length] = createMarker(new GPoint(-85.18571472,33.63433838),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Mount Zion Elementary School",'Mount_Zion=' + Mount_Zion.length);
Mount_Zion[Mount_Zion.length] = createMarker(new GPoint(-85.18437958,33.63695908),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mount Zion High School",'Mount_Zion=' + Mount_Zion.length);
Roopville[Roopville.length] = createMarker(new GPoint(-85.12881470,33.46220016),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Roopville Elementary School",'Roopville=' + Roopville.length);
Carrollton[Carrollton.length] = createMarker(new GPoint(-84.99240112,33.63790131),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Sand Hill Elementary School",'Carrollton=' + Carrollton.length);
Carrollton[Carrollton.length] = createMarker(new GPoint(-85.04898834,33.64916229),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Sharp Creek Elementary School",'Carrollton=' + Carrollton.length);
Carrollton[Carrollton.length] = createMarker(new GPoint(-85.16517639,33.55812073),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Technical High School Of Carroll County",'Carrollton=' + Carrollton.length);
Temple[Temple.length] = createMarker(new GPoint(-85.03847504,33.73949432),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Temple Elementary School",'Temple=' + Temple.length);
Temple[Temple.length] = createMarker(new GPoint(-85.02510834,33.73278809),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Temple High School",'Temple=' + Temple.length);
Temple[Temple.length] = createMarker(new GPoint(-85.01885986,33.76940155),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Temple Middle School",'Temple=' + Temple.length);
Villa_Rica[Villa_Rica.length] = createMarker(new GPoint(-84.92685699,33.73491669),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Villa Rica Elementary School",'Villa_Rica=' + Villa_Rica.length);
Villa_Rica[Villa_Rica.length] = createMarker(new GPoint(-84.94543457,33.72946167),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Villa Rica High School",'Villa_Rica=' + Villa_Rica.length);
Temple[Temple.length] = createMarker(new GPoint(-84.97430700,33.77807800),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Villa Rica Middle School",'Temple=' + Temple.length);
Villa_Rica[Villa_Rica.length] = createMarker(new GPoint(-84.91366577,33.72872925),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Villa Rica Primary School",'Villa_Rica=' + Villa_Rica.length);
Whitesburg[Whitesburg.length] = createMarker(new GPoint(-84.91746521,33.49837112),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Whitesburg Elementary School",'Whitesburg=' + Whitesburg.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(Bowdon);
map.removeOverlays(Carrollton);
map.removeOverlays(Mount_Zion);
map.removeOverlays(Roopville);
map.removeOverlays(Temple);
map.removeOverlays(Villa_Rica);
map.removeOverlays(Whitesburg);
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(Villa_Rica);map.removeOverlays(Bowdon);
map.removeOverlays(Carrollton);
map.removeOverlays(Mount_Zion);
map.removeOverlays(Roopville);
map.removeOverlays(Temple);
map.removeOverlays(Villa_Rica);
map.removeOverlays(Whitesburg);
map.addOverlays(Bowdon);
centerByArray(Bowdon, false, false);
cntMarker += Bowdon.length;
map.addOverlays(Carrollton);
centerByArray(Carrollton, false, false);
cntMarker += Carrollton.length;
map.addOverlays(Mount_Zion);
centerByArray(Mount_Zion, false, false);
cntMarker += Mount_Zion.length;
map.addOverlays(Roopville);
centerByArray(Roopville, false, false);
cntMarker += Roopville.length;
map.addOverlays(Temple);
centerByArray(Temple, false, false);
cntMarker += Temple.length;
map.addOverlays(Villa_Rica);
centerByArray(Villa_Rica, false, false);
cntMarker += Villa_Rica.length;
map.addOverlays(Whitesburg);
centerByArray(Whitesburg, false, false);
cntMarker += Whitesburg.length;
centerByArray(Villa_Rica,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');
}
}