function addMarkers(){
mySelect = document.getElementById('selection');
Stonington = [];Baltic = [];Gales_Ferry = [];Waterford = [];New_London = [];Norwich = [];Ledyard = [];North_Stonington = [];Groton = [];Taftville = [];Uncasville = [];Pawcatuck = [];Oakdale = [];Jewett_City = [];Quaker_Hill = [];mySelect.options[mySelect.options.length] = new Option("Baltic schools",'all=Baltic');
mySelect.options[mySelect.options.length] = new Option("Gales Ferry schools",'all=Gales_Ferry');
mySelect.options[mySelect.options.length] = new Option("Groton schools",'all=Groton');
mySelect.options[mySelect.options.length] = new Option("Jewett City schools",'all=Jewett_City');
mySelect.options[mySelect.options.length] = new Option("Ledyard schools",'all=Ledyard');
mySelect.options[mySelect.options.length] = new Option("New London schools",'all=New_London');
mySelect.options[mySelect.options.length] = new Option("North Stonington schools",'all=North_Stonington');
mySelect.options[mySelect.options.length] = new Option("Norwich schools",'all=Norwich');
mySelect.options[mySelect.options.length] = new Option("Oakdale schools",'all=Oakdale');
mySelect.options[mySelect.options.length] = new Option("Pawcatuck schools",'all=Pawcatuck');
mySelect.options[mySelect.options.length] = new Option("Quaker Hill schools",'all=Quaker_Hill');
mySelect.options[mySelect.options.length] = new Option("Stonington schools",'all=Stonington');
mySelect.options[mySelect.options.length] = new Option("Taftville schools",'all=Taftville');
mySelect.options[mySelect.options.length] = new Option("Uncasville schools",'all=Uncasville');
mySelect.options[mySelect.options.length] = new Option("Waterford schools",'all=Waterford');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Stonington[Stonington.length] = createMarker(new GPoint(-71.96220000,41.39130000),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("A Child's Garden Montessori School",'Stonington=' + Stonington.length);
Baltic[Baltic.length] = createMarker(new GPoint(-72.08453500,41.61682500),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Academy Of The Holy Family",'Baltic=' + Baltic.length);
Gales_Ferry[Gales_Ferry.length] = createMarker(new GPoint(-72.08508900,41.42836100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Academy Of Saint Therese",'Gales_Ferry=' + Gales_Ferry.length);
Waterford[Waterford.length] = createMarker(new GPoint(-72.17974800,41.40238000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Baptist Bible Academy",'Waterford=' + Waterford.length);
Waterford[Waterford.length] = createMarker(new GPoint(-72.14504300,41.38411700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Childrens Discovery Center",'Waterford=' + Waterford.length);
New_London[New_London.length] = createMarker(new GPoint(-72.11223100,41.35118600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Coastline Christian Academy",'New_London=' + New_London.length);
New_London[New_London.length] = createMarker(new GPoint(-72.10486200,41.33522400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lawrence & Memorial Chld Care",'New_London=' + New_London.length);
Norwich[Norwich.length] = createMarker(new GPoint(-72.10361200,41.53062000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Montessori Discovery School",'Norwich=' + Norwich.length);
Ledyard[Ledyard.length] = createMarker(new GPoint(-71.99528200,41.40271800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("New Hope Nursery And Kindergarten",'Ledyard=' + Ledyard.length);
North_Stonington[North_Stonington.length] = createMarker(new GPoint(-71.84434200,41.42919900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("No Stonington Christian Academy",'North_Stonington=' + North_Stonington.length);
Groton[Groton.length] = createMarker(new GPoint(-72.05624500,41.34071500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Pfizer Kids (mgd. By Bright Horizons)",'Groton=' + Groton.length);
Stonington[Stonington.length] = createMarker(new GPoint(-71.89402800,41.36673000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Pine Point School",'Stonington=' + Stonington.length);
Taftville[Taftville.length] = createMarker(new GPoint(-72.05512800,41.56765900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sacred Heart School",'Taftville=' + Taftville.length);
Groton[Groton.length] = createMarker(new GPoint(-72.07485300,41.34823700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sacred Heart School",'Groton=' + Groton.length);
Uncasville[Uncasville.length] = createMarker(new GPoint(-72.10283200,41.46822800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Bernard School",'Uncasville=' + Uncasville.length);
Norwich[Norwich.length] = createMarker(new GPoint(-72.06946500,41.52683200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Joseph School",'Norwich=' + Norwich.length);
Pawcatuck[Pawcatuck.length] = createMarker(new GPoint(-71.83743800,41.38043500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Michael School",'Pawcatuck=' + Pawcatuck.length);
Oakdale[Oakdale.length] = createMarker(new GPoint(-72.21384900,41.51450100),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("St. Thomas More School",'Oakdale=' + Oakdale.length);
New_London[New_London.length] = createMarker(new GPoint(-72.10209400,41.32716700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Solomon Schechter Academy",'New_London=' + New_London.length);
Baltic[Baltic.length] = createMarker(new GPoint(-72.08931400,41.61578700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Joseph Elementary School",'Baltic=' + Baltic.length);
New_London[New_London.length] = createMarker(new GPoint(-72.10597600,41.34430200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Joseph School",'New_London=' + New_London.length);
Jewett_City[Jewett_City.length] = createMarker(new GPoint(-71.98077600,41.60876900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Mary Elementary School",'Jewett_City=' + Jewett_City.length);
New_London[New_London.length] = createMarker(new GPoint(-72.09937800,41.35327300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Mary's Star Of The Sea",'New_London=' + New_London.length);
Norwich[Norwich.length] = createMarker(new GPoint(-72.07787200,41.53137400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Patrick Cathedral School",'Norwich=' + Norwich.length);
Groton[Groton.length] = createMarker(new GPoint(-72.04675100,41.34632500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Stedfast Baptist Academy",'Groton=' + Groton.length);
North_Stonington[North_Stonington.length] = createMarker(new GPoint(-71.92594400,41.47329400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Stonington Institute School",'North_Stonington=' + North_Stonington.length);
Norwich[Norwich.length] = createMarker(new GPoint(-72.11240900,41.56088900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Thames Valley Clinical Day Programs",'Norwich=' + Norwich.length);
Quaker_Hill[Quaker_Hill.length] = createMarker(new GPoint(-72.15310600,41.41469500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Waterford Country School",'Quaker_Hill=' + Quaker_Hill.length);
Norwich[Norwich.length] = createMarker(new GPoint(-72.11636500,41.51422600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Wildwood Christian School",'Norwich=' + Norwich.length);
New_London[New_London.length] = createMarker(new GPoint(-72.10314200,41.37646800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Williams School",'New_London=' + New_London.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/////3/' + showArray);
map.removeOverlays(Baltic);
map.removeOverlays(Gales_Ferry);
map.removeOverlays(Groton);
map.removeOverlays(Jewett_City);
map.removeOverlays(Ledyard);
map.removeOverlays(New_London);
map.removeOverlays(North_Stonington);
map.removeOverlays(Norwich);
map.removeOverlays(Oakdale);
map.removeOverlays(Pawcatuck);
map.removeOverlays(Quaker_Hill);
map.removeOverlays(Stonington);
map.removeOverlays(Taftville);
map.removeOverlays(Uncasville);
map.removeOverlays(Waterford);
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(Stonington);map.removeOverlays(Baltic);
map.removeOverlays(Gales_Ferry);
map.removeOverlays(Groton);
map.removeOverlays(Jewett_City);
map.removeOverlays(Ledyard);
map.removeOverlays(New_London);
map.removeOverlays(North_Stonington);
map.removeOverlays(Norwich);
map.removeOverlays(Oakdale);
map.removeOverlays(Pawcatuck);
map.removeOverlays(Quaker_Hill);
map.removeOverlays(Stonington);
map.removeOverlays(Taftville);
map.removeOverlays(Uncasville);
map.removeOverlays(Waterford);
map.addOverlays(Baltic);
centerByArray(Baltic, false, false);
cntMarker += Baltic.length;
map.addOverlays(Gales_Ferry);
centerByArray(Gales_Ferry, false, false);
cntMarker += Gales_Ferry.length;
map.addOverlays(Groton);
centerByArray(Groton, false, false);
cntMarker += Groton.length;
map.addOverlays(Jewett_City);
centerByArray(Jewett_City, false, false);
cntMarker += Jewett_City.length;
map.addOverlays(Ledyard);
centerByArray(Ledyard, false, false);
cntMarker += Ledyard.length;
map.addOverlays(New_London);
centerByArray(New_London, false, false);
cntMarker += New_London.length;
map.addOverlays(North_Stonington);
centerByArray(North_Stonington, false, false);
cntMarker += North_Stonington.length;
map.addOverlays(Norwich);
centerByArray(Norwich, false, false);
cntMarker += Norwich.length;
map.addOverlays(Oakdale);
centerByArray(Oakdale, false, false);
cntMarker += Oakdale.length;
map.addOverlays(Pawcatuck);
centerByArray(Pawcatuck, false, false);
cntMarker += Pawcatuck.length;
map.addOverlays(Quaker_Hill);
centerByArray(Quaker_Hill, false, false);
cntMarker += Quaker_Hill.length;
map.addOverlays(Stonington);
centerByArray(Stonington, false, false);
cntMarker += Stonington.length;
map.addOverlays(Taftville);
centerByArray(Taftville, false, false);
cntMarker += Taftville.length;
map.addOverlays(Uncasville);
centerByArray(Uncasville, false, false);
cntMarker += Uncasville.length;
map.addOverlays(Waterford);
centerByArray(Waterford, false, false);
cntMarker += Waterford.length;
centerByArray(Stonington,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=3&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;
}