function addMarkers(){
mySelect = document.getElementById('selection');
West_Hartford = [];Avon = [];Wethersfield = [];Southington = [];Manchester = [];Tolland = [];Newington = [];Simsbury = [];Hartford = [];Bristol = [];Windsor = [];West_Simsbury = [];Farmington = [];Windsor_Locks = [];East_Hartford = [];Plainville = [];New_Britain = [];Suffield = [];South_Windsor = [];Bloomfield = [];mySelect.options[mySelect.options.length] = new Option("Avon schools",'all=Avon');
mySelect.options[mySelect.options.length] = new Option("Bloomfield schools",'all=Bloomfield');
mySelect.options[mySelect.options.length] = new Option("Bristol schools",'all=Bristol');
mySelect.options[mySelect.options.length] = new Option("East Hartford schools",'all=East_Hartford');
mySelect.options[mySelect.options.length] = new Option("Farmington schools",'all=Farmington');
mySelect.options[mySelect.options.length] = new Option("Hartford schools",'all=Hartford');
mySelect.options[mySelect.options.length] = new Option("Manchester schools",'all=Manchester');
mySelect.options[mySelect.options.length] = new Option("New Britain schools",'all=New_Britain');
mySelect.options[mySelect.options.length] = new Option("Newington schools",'all=Newington');
mySelect.options[mySelect.options.length] = new Option("Plainville schools",'all=Plainville');
mySelect.options[mySelect.options.length] = new Option("Simsbury schools",'all=Simsbury');
mySelect.options[mySelect.options.length] = new Option("South Windsor schools",'all=South_Windsor');
mySelect.options[mySelect.options.length] = new Option("Southington schools",'all=Southington');
mySelect.options[mySelect.options.length] = new Option("Suffield schools",'all=Suffield');
mySelect.options[mySelect.options.length] = new Option("Tolland schools",'all=Tolland');
mySelect.options[mySelect.options.length] = new Option("West Hartford schools",'all=West_Hartford');
mySelect.options[mySelect.options.length] = new Option("West Simsbury schools",'all=West_Simsbury');
mySelect.options[mySelect.options.length] = new Option("Wethersfield schools",'all=Wethersfield');
mySelect.options[mySelect.options.length] = new Option("Windsor schools",'all=Windsor');
mySelect.options[mySelect.options.length] = new Option("Windsor Locks schools",'all=Windsor_Locks');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
West_Hartford[West_Hartford.length] = createMarker(new GPoint(-72.74418200,41.77133100),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("American School For The Deaf",'West_Hartford=' + West_Hartford.length);
Avon[Avon.length] = createMarker(new GPoint(-72.83650200,41.78126100),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Avon Old Farms School",'Avon=' + Avon.length);
West_Hartford[West_Hartford.length] = createMarker(new GPoint(-72.75580000,41.75340000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Ben Bronz Academy",'West_Hartford=' + West_Hartford.length);
Wethersfield[Wethersfield.length] = createMarker(new GPoint(-72.69141000,41.71957900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Ccmc School",'Wethersfield=' + Wethersfield.length);
Southington[Southington.length] = createMarker(new GPoint(-72.89981500,41.62917700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Central Christian Academy",'Southington=' + Southington.length);
Manchester[Manchester.length] = createMarker(new GPoint(-72.52432000,41.78131600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Clinical Day School At Manchester Memorial Hosp",'Manchester=' + Manchester.length);
Manchester[Manchester.length] = createMarker(new GPoint(-72.52391700,41.78578600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Cornerstone Christian School",'Manchester=' + Manchester.length);
Tolland[Tolland.length] = createMarker(new GPoint(-72.41585500,41.84474400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Covenant Academy",'Tolland=' + Tolland.length);
Manchester[Manchester.length] = createMarker(new GPoint(-72.55663300,41.78261200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("East Catholic High School",'Manchester=' + Manchester.length);
Newington[Newington.length] = createMarker(new GPoint(-72.74202700,41.67684300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Emmanuel Christian Academy",'Newington=' + Newington.length);
Simsbury[Simsbury.length] = createMarker(new GPoint(-72.83537300,41.84930200),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Ethel Walker School",'Simsbury=' + Simsbury.length);
Hartford[Hartford.length] = createMarker(new GPoint(-72.68150400,41.75164300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Grace S. Webb School",'Hartford=' + Hartford.length);
Hartford[Hartford.length] = createMarker(new GPoint(-72.68368300,41.77019600),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Gray Lodge School",'Hartford=' + Hartford.length);
Hartford[Hartford.length] = createMarker(new GPoint(-72.69576000,41.78263200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Hartford Area Sda School",'Hartford=' + Hartford.length);
West_Hartford[West_Hartford.length] = createMarker(new GPoint(-72.75580000,41.75340000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Hartford Christian Academy",'West_Hartford=' + West_Hartford.length);
Hartford[Hartford.length] = createMarker(new GPoint(-72.68548600,41.73738000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Hartford Christian School",'Hartford=' + Hartford.length);
West_Hartford[West_Hartford.length] = createMarker(new GPoint(-72.75049100,41.80331200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Hebrew High School Of New England",'West_Hartford=' + West_Hartford.length);
Bristol[Bristol.length] = createMarker(new GPoint(-72.94080300,41.68703400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Heritage Christian School",'Bristol=' + Bristol.length);
West_Hartford[West_Hartford.length] = createMarker(new GPoint(-72.73423800,41.75961600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Kingswood-Oxford School",'West_Hartford=' + West_Hartford.length);
Windsor[Windsor.length] = createMarker(new GPoint(-72.64108700,41.83868400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Loomis Chaffee School",'Windsor=' + Windsor.length);
West_Simsbury[West_Simsbury.length] = createMarker(new GPoint(-72.86282100,41.87716600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Master's School",'West_Simsbury=' + West_Simsbury.length);
Farmington[Farmington.length] = createMarker(new GPoint(-72.82930500,41.72230500),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Miss Porter's School",'Farmington=' + Farmington.length);
Windsor_Locks[Windsor_Locks.length] = createMarker(new GPoint(-72.64883500,41.91386300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("New Life Christian Academy",'Windsor_Locks=' + Windsor_Locks.length);
East_Hartford[East_Hartford.length] = createMarker(new GPoint(-72.65476400,41.76834100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("New Testament Baptist Church School",'East_Hartford=' + East_Hartford.length);
West_Hartford[West_Hartford.length] = createMarker(new GPoint(-72.75223900,41.80009000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Northwest Catholic High School",'West_Hartford=' + West_Hartford.length);
Plainville[Plainville.length] = createMarker(new GPoint(-72.87786200,41.69208400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Nw Village School-wheeler Clinic",'Plainville=' + Plainville.length);
Windsor[Windsor.length] = createMarker(new GPoint(-72.66820000,41.86040000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Praise, Power & Prayer Christian School",'Windsor=' + Windsor.length);
New_Britain[New_Britain.length] = createMarker(new GPoint(-72.78771500,41.65114800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Raymond Hill School",'New_Britain=' + New_Britain.length);
West_Hartford[West_Hartford.length] = createMarker(new GPoint(-72.77817700,41.79048000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Renbrook School",'West_Hartford=' + West_Hartford.length);
Bristol[Bristol.length] = createMarker(new GPoint(-72.91142800,41.70444500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Paul Catholic High School",'Bristol=' + Bristol.length);
Hartford[Hartford.length] = createMarker(new GPoint(-72.71480900,41.77443600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Shiloh Christian Academy",'Hartford=' + Hartford.length);
Suffield[Suffield.length] = createMarker(new GPoint(-72.65005200,41.98544000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Suffield Academy",'Suffield=' + Suffield.length);
Manchester[Manchester.length] = createMarker(new GPoint(-72.52265200,41.76442100),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Summit School/new Hope Manor",'Manchester=' + Manchester.length);
South_Windsor[South_Windsor.length] = createMarker(new GPoint(-72.62201700,41.79899400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Truth Baptist Academy",'South_Windsor=' + South_Windsor.length);
Hartford[Hartford.length] = createMarker(new GPoint(-72.71592300,41.79286600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Watkinson School",'Hartford=' + Hartford.length);
Bloomfield[Bloomfield.length] = createMarker(new GPoint(-72.75047800,41.80041100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Webb School At Bloomfield",'Bloomfield=' + Bloomfield.length);
Simsbury[Simsbury.length] = createMarker(new GPoint(-72.79810800,41.88594400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Westminster School",'Simsbury=' + Simsbury.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/////2/' + showArray);
map.removeOverlays(Avon);
map.removeOverlays(Bloomfield);
map.removeOverlays(Bristol);
map.removeOverlays(East_Hartford);
map.removeOverlays(Farmington);
map.removeOverlays(Hartford);
map.removeOverlays(Manchester);
map.removeOverlays(New_Britain);
map.removeOverlays(Newington);
map.removeOverlays(Plainville);
map.removeOverlays(Simsbury);
map.removeOverlays(South_Windsor);
map.removeOverlays(Southington);
map.removeOverlays(Suffield);
map.removeOverlays(Tolland);
map.removeOverlays(West_Hartford);
map.removeOverlays(West_Simsbury);
map.removeOverlays(Wethersfield);
map.removeOverlays(Windsor);
map.removeOverlays(Windsor_Locks);
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(West_Hartford);map.removeOverlays(Avon);
map.removeOverlays(Bloomfield);
map.removeOverlays(Bristol);
map.removeOverlays(East_Hartford);
map.removeOverlays(Farmington);
map.removeOverlays(Hartford);
map.removeOverlays(Manchester);
map.removeOverlays(New_Britain);
map.removeOverlays(Newington);
map.removeOverlays(Plainville);
map.removeOverlays(Simsbury);
map.removeOverlays(South_Windsor);
map.removeOverlays(Southington);
map.removeOverlays(Suffield);
map.removeOverlays(Tolland);
map.removeOverlays(West_Hartford);
map.removeOverlays(West_Simsbury);
map.removeOverlays(Wethersfield);
map.removeOverlays(Windsor);
map.removeOverlays(Windsor_Locks);
map.addOverlays(Avon);
centerByArray(Avon, false, false);
cntMarker += Avon.length;
map.addOverlays(Bloomfield);
centerByArray(Bloomfield, false, false);
cntMarker += Bloomfield.length;
map.addOverlays(Bristol);
centerByArray(Bristol, false, false);
cntMarker += Bristol.length;
map.addOverlays(East_Hartford);
centerByArray(East_Hartford, false, false);
cntMarker += East_Hartford.length;
map.addOverlays(Farmington);
centerByArray(Farmington, false, false);
cntMarker += Farmington.length;
map.addOverlays(Hartford);
centerByArray(Hartford, false, false);
cntMarker += Hartford.length;
map.addOverlays(Manchester);
centerByArray(Manchester, false, false);
cntMarker += Manchester.length;
map.addOverlays(New_Britain);
centerByArray(New_Britain, false, false);
cntMarker += New_Britain.length;
map.addOverlays(Newington);
centerByArray(Newington, false, false);
cntMarker += Newington.length;
map.addOverlays(Plainville);
centerByArray(Plainville, false, false);
cntMarker += Plainville.length;
map.addOverlays(Simsbury);
centerByArray(Simsbury, false, false);
cntMarker += Simsbury.length;
map.addOverlays(South_Windsor);
centerByArray(South_Windsor, false, false);
cntMarker += South_Windsor.length;
map.addOverlays(Southington);
centerByArray(Southington, false, false);
cntMarker += Southington.length;
map.addOverlays(Suffield);
centerByArray(Suffield, false, false);
cntMarker += Suffield.length;
map.addOverlays(Tolland);
centerByArray(Tolland, false, false);
cntMarker += Tolland.length;
map.addOverlays(West_Hartford);
centerByArray(West_Hartford, false, false);
cntMarker += West_Hartford.length;
map.addOverlays(West_Simsbury);
centerByArray(West_Simsbury, false, false);
cntMarker += West_Simsbury.length;
map.addOverlays(Wethersfield);
centerByArray(Wethersfield, false, false);
cntMarker += Wethersfield.length;
map.addOverlays(Windsor);
centerByArray(Windsor, false, false);
cntMarker += Windsor.length;
map.addOverlays(Windsor_Locks);
centerByArray(Windsor_Locks, false, false);
cntMarker += Windsor_Locks.length;
centerByArray(West_Hartford,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=2&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;
}