function addMarkers()
{
mySelect = document.getElementById('selection');
Jeffersonville = [];Charlestown = [];Clarksville = [];Henryville = [];New_Washington = [];Sellersburg = [];Borden = [];mySelect.options[mySelect.options.length] = new Option("Borden schools",'all=Borden');
mySelect.options[mySelect.options.length] = new Option("Charlestown schools",'all=Charlestown');
mySelect.options[mySelect.options.length] = new Option("Clarksville schools",'all=Clarksville');
mySelect.options[mySelect.options.length] = new Option("Henryville schools",'all=Henryville');
mySelect.options[mySelect.options.length] = new Option("Jeffersonville schools",'all=Jeffersonville');
mySelect.options[mySelect.options.length] = new Option("New Washington schools",'all=New_Washington');
mySelect.options[mySelect.options.length] = new Option("Sellersburg schools",'all=Sellersburg');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Jeffersonville[Jeffersonville.length] = createMarker(new GPoint(-85.70931244,38.29023743),"
",iconRd);
mySelect.options[mySelect.options.length] = new Option("Bridgepoint Elementary School",'Jeffersonville=' + Jeffersonville.length);
Charlestown[Charlestown.length] = createMarker(new GPoint(-85.67226410,38.43494415),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Charlestown Middle School",'Charlestown=' + Charlestown.length);
Charlestown[Charlestown.length] = createMarker(new GPoint(-85.66605377,38.45336151),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Charlestown Senior High School",'Charlestown=' + Charlestown.length);
Clarksville[Clarksville.length] = createMarker(new GPoint(-85.76456451,38.30259705),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Clarksville Middle School",'Clarksville=' + Clarksville.length);
Clarksville[Clarksville.length] = createMarker(new GPoint(-85.76856232,38.29927063),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Clarksville Senior High School",'Clarksville=' + Clarksville.length);
Jeffersonville[Jeffersonville.length] = createMarker(new GPoint(-85.73602295,38.27749252),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Corden Porter Edu Center",'Jeffersonville=' + Jeffersonville.length);
Clarksville[Clarksville.length] = createMarker(new GPoint(-85.75348663,38.28456879),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("George Rogers Clark Elementary School",'Clarksville=' + Clarksville.length);
Clarksville[Clarksville.length] = createMarker(new GPoint(-85.76864624,38.29669189),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Greenacres Elementary School",'Clarksville=' + Clarksville.length);
Henryville[Henryville.length] = createMarker(new GPoint(-85.76837158,38.54280472),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Henryville Elementary School",'Henryville=' + Henryville.length);
Henryville[Henryville.length] = createMarker(new GPoint(-85.76837158,38.54280472),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Henryville Junior & Senior High School",'Henryville=' + Henryville.length);
Jeffersonville[Jeffersonville.length] = createMarker(new GPoint(-85.73654175,38.27820206),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Instr Srvs Cntr-options Alt Prog",'Jeffersonville=' + Jeffersonville.length);
Jeffersonville[Jeffersonville.length] = createMarker(new GPoint(-85.70838928,38.31753540),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Jeffersonville High School",'Jeffersonville=' + Jeffersonville.length);
Charlestown[Charlestown.length] = createMarker(new GPoint(-85.66515350,38.44596863),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Jonathan Jennings Elementary School",'Charlestown=' + Charlestown.length);
Jeffersonville[Jeffersonville.length] = createMarker(new GPoint(-85.72772980,38.28035736),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Maple Elementary School",'Jeffersonville=' + Jeffersonville.length);
New_Washington[New_Washington.length] = createMarker(new GPoint(-85.48619843,38.54909897),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("New Washington Elementary School",'New_Washington=' + New_Washington.length);
New_Washington[New_Washington.length] = createMarker(new GPoint(-85.54209900,38.55080032),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("New Washington Middle/high School",'New_Washington=' + New_Washington.length);
Jeffersonville[Jeffersonville.length] = createMarker(new GPoint(-85.72470856,38.30810547),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Northaven Elementary School",'Jeffersonville=' + Jeffersonville.length);
Jeffersonville[Jeffersonville.length] = createMarker(new GPoint(-85.72225952,38.28731537),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Parkview Middle School",'Jeffersonville=' + Jeffersonville.length);
Clarksville[Clarksville.length] = createMarker(new GPoint(-85.77427673,38.32566833),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Parkwood Elementary School",'Clarksville=' + Clarksville.length);
Charlestown[Charlestown.length] = createMarker(new GPoint(-85.66806030,38.45983505),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Pleasant Ridge Elementary School",'Charlestown=' + Charlestown.length);
Jeffersonville[Jeffersonville.length] = createMarker(new GPoint(-85.73609161,38.32830048),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("River Valley Middle School",'Jeffersonville=' + Jeffersonville.length);
Jeffersonville[Jeffersonville.length] = createMarker(new GPoint(-85.69354248,38.31056213),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Riverside Elementary School",'Jeffersonville=' + Jeffersonville.length);
Sellersburg[Sellersburg.length] = createMarker(new GPoint(-85.76339722,38.38769913),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Sellersburg Elementary School",'Sellersburg=' + Sellersburg.length);
Sellersburg[Sellersburg.length] = createMarker(new GPoint(-85.75387573,38.40354919),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Silver Creek Elementary School",'Sellersburg=' + Sellersburg.length);
Sellersburg[Sellersburg.length] = createMarker(new GPoint(-85.75351715,38.40856552),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Silver Creek High School",'Sellersburg=' + Sellersburg.length);
Sellersburg[Sellersburg.length] = createMarker(new GPoint(-85.75391388,38.40342712),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Silver Creek Middle School",'Sellersburg=' + Sellersburg.length);
Jeffersonville[Jeffersonville.length] = createMarker(new GPoint(-85.74777222,38.28617477),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Spring Hill Elementary School",'Jeffersonville=' + Jeffersonville.length);
Jeffersonville[Jeffersonville.length] = createMarker(new GPoint(-85.74468994,38.30578613),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Thomas Jefferson Elementary School",'Jeffersonville=' + Jeffersonville.length);
Jeffersonville[Jeffersonville.length] = createMarker(new GPoint(-85.68003845,38.33655548),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Utica Elementary School",'Jeffersonville=' + Jeffersonville.length);
Jeffersonville[Jeffersonville.length] = createMarker(new GPoint(-85.72460175,38.33336639),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("W E Wilson Elementary School",'Jeffersonville=' + Jeffersonville.length);
Borden[Borden.length] = createMarker(new GPoint(-85.94641876,38.46928024),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("William W Borden Elementary School",'Borden=' + Borden.length);
Borden[Borden.length] = createMarker(new GPoint(-85.94641876,38.46928024),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("William W Borden High School",'Borden=' + Borden.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(Borden);
map.removeOverlays(Charlestown);
map.removeOverlays(Clarksville);
map.removeOverlays(Henryville);
map.removeOverlays(Jeffersonville);
map.removeOverlays(New_Washington);
map.removeOverlays(Sellersburg);
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(Jeffersonville);map.removeOverlays(Borden);
map.removeOverlays(Charlestown);
map.removeOverlays(Clarksville);
map.removeOverlays(Henryville);
map.removeOverlays(Jeffersonville);
map.removeOverlays(New_Washington);
map.removeOverlays(Sellersburg);
map.addOverlays(Borden);
centerByArray(Borden, false, false);
cntMarker += Borden.length;
map.addOverlays(Charlestown);
centerByArray(Charlestown, false, false);
cntMarker += Charlestown.length;
map.addOverlays(Clarksville);
centerByArray(Clarksville, false, false);
cntMarker += Clarksville.length;
map.addOverlays(Henryville);
centerByArray(Henryville, false, false);
cntMarker += Henryville.length;
map.addOverlays(Jeffersonville);
centerByArray(Jeffersonville, false, false);
cntMarker += Jeffersonville.length;
map.addOverlays(New_Washington);
centerByArray(New_Washington, false, false);
cntMarker += New_Washington.length;
map.addOverlays(Sellersburg);
centerByArray(Sellersburg, false, false);
cntMarker += Sellersburg.length;
centerByArray(Jeffersonville,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');
}
}