function addMarkers(){
mySelect = document.getElementById('selection');
Goshen = [];Middlebury = [];Elkhart = [];Bristol = [];Nappanee = [];Granger = [];Wakarusa = [];Millersburg = [];mySelect.options[mySelect.options.length] = new Option("Bristol schools",'all=Bristol');
mySelect.options[mySelect.options.length] = new Option("Elkhart schools",'all=Elkhart');
mySelect.options[mySelect.options.length] = new Option("Goshen schools",'all=Goshen');
mySelect.options[mySelect.options.length] = new Option("Granger schools",'all=Granger');
mySelect.options[mySelect.options.length] = new Option("Middlebury schools",'all=Middlebury');
mySelect.options[mySelect.options.length] = new Option("Millersburg schools",'all=Millersburg');
mySelect.options[mySelect.options.length] = new Option("Nappanee schools",'all=Nappanee');
mySelect.options[mySelect.options.length] = new Option("Wakarusa schools",'all=Wakarusa');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Goshen[Goshen.length] = createMarker(new GPoint(-85.84120000,41.58900000),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Basher Alternative School",'Goshen=' + Goshen.length);
Goshen[Goshen.length] = createMarker(new GPoint(-85.82815700,41.54565400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bethany Christian Schools",'Goshen=' + Goshen.length);
Goshen[Goshen.length] = createMarker(new GPoint(-85.84120000,41.58900000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Brennerman Daycare Center",'Goshen=' + Goshen.length);
Goshen[Goshen.length] = createMarker(new GPoint(-85.71321500,41.57478200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Clinton Center Amish School",'Goshen=' + Goshen.length);
Goshen[Goshen.length] = createMarker(new GPoint(-85.82510000,41.61010000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Clinton Christian School",'Goshen=' + Goshen.length);
Goshen[Goshen.length] = createMarker(new GPoint(-85.74466500,41.58116100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cloverleaf School",'Goshen=' + Goshen.length);
Middlebury[Middlebury.length] = createMarker(new GPoint(-85.73428300,41.61751200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Eight Square School",'Middlebury=' + Middlebury.length);
Elkhart[Elkhart.length] = createMarker(new GPoint(-85.92822400,41.70218800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Elkhart Adventist Christian School",'Elkhart=' + Elkhart.length);
Elkhart[Elkhart.length] = createMarker(new GPoint(-85.96349200,41.63789900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Elkhart Christian Academy",'Elkhart=' + Elkhart.length);
Elkhart[Elkhart.length] = createMarker(new GPoint(-85.92475300,41.70206300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Elkhart S D A School",'Elkhart=' + Elkhart.length);
Middlebury[Middlebury.length] = createMarker(new GPoint(-85.67122200,41.62791700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Forest Grove School",'Middlebury=' + Middlebury.length);
Goshen[Goshen.length] = createMarker(new GPoint(-85.82841600,41.56556300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Goshen College Laboratory Kindergarten",'Goshen=' + Goshen.length);
Goshen[Goshen.length] = createMarker(new GPoint(-85.82510000,41.61010000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Grace Christian School",'Goshen=' + Goshen.length);
Middlebury[Middlebury.length] = createMarker(new GPoint(-85.70060000,41.68630000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Grace Christian School",'Middlebury=' + Middlebury.length);
Goshen[Goshen.length] = createMarker(new GPoint(-85.84690000,41.56810000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Harrison Christian School",'Goshen=' + Goshen.length);
Goshen[Goshen.length] = createMarker(new GPoint(-85.73334800,41.58483800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Hillside Amish School",'Goshen=' + Goshen.length);
Bristol[Bristol.length] = createMarker(new GPoint(-85.82750000,41.72050000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Kessington Christian School",'Bristol=' + Bristol.length);
Nappanee[Nappanee.length] = createMarker(new GPoint(-85.93242700,41.49369600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Meadow Valley School",'Nappanee=' + Nappanee.length);
Elkhart[Elkhart.length] = createMarker(new GPoint(-85.92412100,41.71664800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Michiana Christian Montessori School, Inc.",'Elkhart=' + Elkhart.length);
Goshen[Goshen.length] = createMarker(new GPoint(-85.79694200,41.56134900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Montessori Academy Of Goshen",'Goshen=' + Goshen.length);
Goshen[Goshen.length] = createMarker(new GPoint(-85.79941600,41.55706700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Montessori Discovery House",'Goshen=' + Goshen.length);
Elkhart[Elkhart.length] = createMarker(new GPoint(-85.96998300,41.69343700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Montessori School Of Elkhart",'Elkhart=' + Elkhart.length);
Goshen[Goshen.length] = createMarker(new GPoint(-85.94123400,41.51571000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Morning Star School",'Goshen=' + Goshen.length);
Granger[Granger.length] = createMarker(new GPoint(-86.04733300,41.72939100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("New Creation Academy",'Granger=' + Granger.length);
Nappanee[Nappanee.length] = createMarker(new GPoint(-85.94375900,41.50607300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Old Brethren Christian School",'Nappanee=' + Nappanee.length);
Wakarusa[Wakarusa.length] = createMarker(new GPoint(-85.84690000,41.56810000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Old Order Mennonite Garden Spot School",'Wakarusa=' + Wakarusa.length);
Middlebury[Middlebury.length] = createMarker(new GPoint(-85.76255000,41.63846300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Pine Creek Amish School",'Middlebury=' + Middlebury.length);
Middlebury[Middlebury.length] = createMarker(new GPoint(-85.70060000,41.68630000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Plainview Amish School",'Middlebury=' + Middlebury.length);
Middlebury[Middlebury.length] = createMarker(new GPoint(-85.67852700,41.67613500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Plainview School",'Middlebury=' + Middlebury.length);
Middlebury[Middlebury.length] = createMarker(new GPoint(-85.73476300,41.64414700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Pumpkin Vine School",'Middlebury=' + Middlebury.length);
Elkhart[Elkhart.length] = createMarker(new GPoint(-85.97480000,41.71270000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Redeemer Community Christian School",'Elkhart=' + Elkhart.length);
Middlebury[Middlebury.length] = createMarker(new GPoint(-85.70060000,41.68630000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Rolling Acres School",'Middlebury=' + Middlebury.length);
Goshen[Goshen.length] = createMarker(new GPoint(-85.83479400,41.58133700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. John The Evangelist",'Goshen=' + Goshen.length);
Elkhart[Elkhart.length] = createMarker(new GPoint(-85.97652100,41.70126200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Thomas Elementary School",'Elkhart=' + Elkhart.length);
Nappanee[Nappanee.length] = createMarker(new GPoint(-86.00121600,41.43534900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("South Side Christian School",'Nappanee=' + Nappanee.length);
Elkhart[Elkhart.length] = createMarker(new GPoint(-85.96499900,41.67762300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Vincent De Paul Elementary School",'Elkhart=' + Elkhart.length);
Millersburg[Millersburg.length] = createMarker(new GPoint(-85.65534600,41.54532900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Stoney Creek School",'Millersburg=' + Millersburg.length);
Elkhart[Elkhart.length] = createMarker(new GPoint(-86.05985100,41.72433200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Trinity Lutheran School",'Elkhart=' + Elkhart.length);
Nappanee[Nappanee.length] = createMarker(new GPoint(-86.03099000,41.45706300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("United Christian School",'Nappanee=' + Nappanee.length);
Wakarusa[Wakarusa.length] = createMarker(new GPoint(-86.03520000,41.53660000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Wabash School",'Wakarusa=' + Wakarusa.length);
Nappanee[Nappanee.length] = createMarker(new GPoint(-86.04948800,41.45373600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Weldy Amish School",'Nappanee=' + Nappanee.length);
Nappanee[Nappanee.length] = createMarker(new GPoint(-85.94833900,41.45723800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("West Union Center School",'Nappanee=' + Nappanee.length);
Goshen[Goshen.length] = createMarker(new GPoint(-85.84690000,41.56810000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Willow Spring School",'Goshen=' + Goshen.length);
Goshen[Goshen.length] = createMarker(new GPoint(-85.71667100,41.58157900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Woodlawn Christian School",'Goshen=' + Goshen.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,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/////1/' + showArray);
map.removeOverlays(Bristol);
map.removeOverlays(Elkhart);
map.removeOverlays(Goshen);
map.removeOverlays(Granger);
map.removeOverlays(Middlebury);
map.removeOverlays(Millersburg);
map.removeOverlays(Nappanee);
map.removeOverlays(Wakarusa);
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(Goshen);map.removeOverlays(Bristol);
map.removeOverlays(Elkhart);
map.removeOverlays(Goshen);
map.removeOverlays(Granger);
map.removeOverlays(Middlebury);
map.removeOverlays(Millersburg);
map.removeOverlays(Nappanee);
map.removeOverlays(Wakarusa);
map.addOverlays(Bristol);
centerByArray(Bristol, false, false);
cntMarker += Bristol.length;
map.addOverlays(Elkhart);
centerByArray(Elkhart, false, false);
cntMarker += Elkhart.length;
map.addOverlays(Goshen);
centerByArray(Goshen, false, false);
cntMarker += Goshen.length;
map.addOverlays(Granger);
centerByArray(Granger, false, false);
cntMarker += Granger.length;
map.addOverlays(Middlebury);
centerByArray(Middlebury, false, false);
cntMarker += Middlebury.length;
map.addOverlays(Millersburg);
centerByArray(Millersburg, false, false);
cntMarker += Millersburg.length;
map.addOverlays(Nappanee);
centerByArray(Nappanee, false, false);
cntMarker += Nappanee.length;
map.addOverlays(Wakarusa);
centerByArray(Wakarusa, false, false);
cntMarker += Wakarusa.length;
centerByArray(Goshen,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');
//window.open('/map.php?type=1&schools=&school_level=1&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;
}