function addMarkers(){
mySelect = document.getElementById('selection');
Enfield = [];Southington = [];Hartford = [];New_Haven = [];Norwalk = [];Bridgeport = [];Suffield = [];Manchester = [];Middletown = [];New_London = [];Waterbury = [];Winsted = [];Danielson = [];Norwich = [];Farmington = [];mySelect.options[mySelect.options.length] = new Option("Bridgeport Schools",'all=Bridgeport');
mySelect.options[mySelect.options.length] = new Option("Danielson Schools",'all=Danielson');
mySelect.options[mySelect.options.length] = new Option("Enfield Schools",'all=Enfield');
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("Middletown Schools",'all=Middletown');
mySelect.options[mySelect.options.length] = new Option("New Haven Schools",'all=New_Haven');
mySelect.options[mySelect.options.length] = new Option("New London Schools",'all=New_London');
mySelect.options[mySelect.options.length] = new Option("Norwalk Schools",'all=Norwalk');
mySelect.options[mySelect.options.length] = new Option("Norwich Schools",'all=Norwich');
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("Waterbury Schools",'all=Waterbury');
mySelect.options[mySelect.options.length] = new Option("Winsted Schools",'all=Winsted');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
var tmpLatLng=0;
var tmpLen=0;
tmpLatLng=new GLatLng(41.99859200000000214,-72.5755889999999936);
tmpLen=Enfield.length;
Enfield[tmpLen] = createMarker(tmpLatLng,"
",iconGr);
Enfield[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("Asnuntuck Community College",'Enfield=' + Enfield.length);
tmpLatLng=new GLatLng(41.63289999999999935,-72.9208760000000069);
tmpLen=Southington.length;
Southington[tmpLen] = createMarker(tmpLatLng,"",iconRd);
Southington[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("Briarwood College",'Southington=' + Southington.length);
tmpLatLng=new GLatLng(41.76812199999999819,-72.6730720000000047);
tmpLen=Hartford.length;
Hartford[tmpLen] = createMarker(tmpLatLng,"",iconGr);
Hartford[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("Capital Community College",'Hartford=' + Hartford.length);
tmpLatLng=new GLatLng(41.28768699999999825,-72.9255030000000061);
tmpLen=New_Haven.length;
New_Haven[tmpLen] = createMarker(tmpLatLng,"",iconGr);
New_Haven[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("Gateway Community College",'New_Haven=' + New_Haven.length);
tmpLatLng=new GLatLng(41.11169600000000201,-73.4076129999999977);
tmpLen=Norwalk.length;
Norwalk[tmpLen] = createMarker(tmpLatLng,"",iconRd);
Norwalk[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("Gibbs College",'Norwalk=' + Norwalk.length);
tmpLatLng=new GLatLng(41.17500799999999827,-73.1924489999999963);
tmpLen=Bridgeport.length;
Bridgeport[tmpLen] = createMarker(tmpLatLng,"",iconGr);
Bridgeport[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("Housatonic Community College",'Bridgeport=' + Bridgeport.length);
tmpLatLng=new GLatLng(42.03034900000000107,-72.6171410000000037);
tmpLen=Suffield.length;
Suffield[tmpLen] = createMarker(tmpLatLng,"",iconRd);
Suffield[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("International College Of Hospitality Management",'Suffield=' + Suffield.length);
tmpLatLng=new GLatLng(41.76245999999999725,-72.5671999999999997);
tmpLen=Manchester.length;
Manchester[tmpLen] = createMarker(tmpLatLng,"",iconGr);
Manchester[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("Manchester Community College",'Manchester=' + Manchester.length);
tmpLatLng=new GLatLng(41.53803500000000070,-72.6117059999999980);
tmpLen=Middletown.length;
Middletown[tmpLen] = createMarker(tmpLatLng,"",iconGr);
Middletown[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("Middlesex Community College",'Middletown=' + Middletown.length);
tmpLatLng=new GLatLng(41.32819800000000043,-72.0938050000000032);
tmpLen=New_London.length;
New_London[tmpLen] = createMarker(tmpLatLng,"",iconRd);
New_London[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("Mitchell College",'New_London=' + New_London.length);
tmpLatLng=new GLatLng(41.54669599999999718,-73.0730520000000041);
tmpLen=Waterbury.length;
Waterbury[tmpLen] = createMarker(tmpLatLng,"",iconGr);
Waterbury[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("Naugatuck Valley Community College",'Waterbury=' + Waterbury.length);
tmpLatLng=new GLatLng(41.92132000000000147,-73.0603799999999949);
tmpLen=Winsted.length;
Winsted[tmpLen] = createMarker(tmpLatLng,"",iconGr);
Winsted[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("Northwestern Connecticut Community College",'Winsted=' + Winsted.length);
tmpLatLng=new GLatLng(41.10396300000000025,-73.4512310000000070);
tmpLen=Norwalk.length;
Norwalk[tmpLen] = createMarker(tmpLatLng,"",iconGr);
Norwalk[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("Norwalk Community College",'Norwalk=' + Norwalk.length);
tmpLatLng=new GLatLng(41.82529699999999905,-71.8939330000000040);
tmpLen=Danielson.length;
Danielson[tmpLen] = createMarker(tmpLatLng,"",iconGr);
Danielson[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("Quinebaug Valley Community College",'Danielson=' + Danielson.length);
tmpLatLng=new GLatLng(41.20039899999999732,-73.2030249999999966);
tmpLen=Bridgeport.length;
Bridgeport[tmpLen] = createMarker(tmpLatLng,"",iconRd);
Bridgeport[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("St Vincent's College",'Bridgeport=' + Bridgeport.length);
tmpLatLng=new GLatLng(41.55071199999999720,-72.0764350000000035);
tmpLen=Norwich.length;
Norwich[tmpLen] = createMarker(tmpLatLng,"",iconGr);
Norwich[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("Three Rivers Community College",'Norwich=' + Norwich.length);
tmpLatLng=new GLatLng(41.71876100000000064,-72.8329159999999973);
tmpLen=Farmington.length;
Farmington[tmpLen] = createMarker(tmpLatLng,"",iconGr);
Farmington[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("Tunxis Community College",'Farmington=' + Farmington.length);
map.removeOverlays(Bridgeport);
map.removeOverlays(Danielson);
map.removeOverlays(Enfield);
map.removeOverlays(Farmington);
map.removeOverlays(Hartford);
map.removeOverlays(Manchester);
map.removeOverlays(Middletown);
map.removeOverlays(New_Haven);
map.removeOverlays(New_London);
map.removeOverlays(Norwalk);
map.removeOverlays(Norwich);
map.removeOverlays(Southington);
map.removeOverlays(Suffield);
map.removeOverlays(Waterbury);
map.removeOverlays(Winsted);
setTimeout(function(){map.addOverlays(Bridgeport)},1000);
setTimeout(function(){map.addOverlays(Danielson)},1000);
setTimeout(function(){map.addOverlays(Enfield)},1000);
setTimeout(function(){map.addOverlays(Farmington)},1000);
setTimeout(function(){map.addOverlays(Hartford)},1000);
setTimeout(function(){map.addOverlays(Manchester)},1000);
setTimeout(function(){map.addOverlays(Middletown)},1000);
setTimeout(function(){map.addOverlays(New_Haven)},1000);
setTimeout(function(){map.addOverlays(New_London)},1000);
setTimeout(function(){map.addOverlays(Norwalk)},1000);
setTimeout(function(){map.addOverlays(Norwich)},1000);
setTimeout(function(){map.addOverlays(Southington)},1000);
setTimeout(function(){map.addOverlays(Suffield)},1000);
setTimeout(function(){map.addOverlays(Waterbury)},1000);
setTimeout(function(){map.addOverlays(Winsted)},1000);
getPoly("","state","","CT");}
// End addStateMarkers JavaScript Function
//open all when map is defined
function openAll() {
if (map) {
selectChange("all");
} else {
setTimeout("openAll()",200);
}
}
// 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].point.x;
var markLat = myArray[i].point.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].point.x;
maxLat = myArray[0].point.y;
minLng = myArray[0].point.x;
minLat = myArray[0].point.y;
}
// Recenter map based on global max/mins
function reCenterMap(){
//alert('#' + minLat + '#' + minLng + '#' + maxLat + '#' + maxLng);
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) {
if (selection.options) {
var _openNewWindow=true;
var myVal = selection.options[selection.selectedIndex].value;
} else {
var _openNewWindow=false;
var myVal=selection;
}
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('schools-by-distance') == -1)
window.open(location.href + '/map/all');
else
window.open('/search////all');
map.removeOverlays(Bridgeport);
map.removeOverlays(Danielson);
map.removeOverlays(Enfield);
map.removeOverlays(Farmington);
map.removeOverlays(Hartford);
map.removeOverlays(Manchester);
map.removeOverlays(Middletown);
map.removeOverlays(New_Haven);
map.removeOverlays(New_London);
map.removeOverlays(Norwalk);
map.removeOverlays(Norwich);
map.removeOverlays(Southington);
map.removeOverlays(Suffield);
map.removeOverlays(Waterbury);
map.removeOverlays(Winsted);
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(Enfield);map.removeOverlays(Bridgeport);
map.removeOverlays(Danielson);
map.removeOverlays(Enfield);
map.removeOverlays(Farmington);
map.removeOverlays(Hartford);
map.removeOverlays(Manchester);
map.removeOverlays(Middletown);
map.removeOverlays(New_Haven);
map.removeOverlays(New_London);
map.removeOverlays(Norwalk);
map.removeOverlays(Norwich);
map.removeOverlays(Southington);
map.removeOverlays(Suffield);
map.removeOverlays(Waterbury);
map.removeOverlays(Winsted);
map.addOverlays(Bridgeport);
centerByArray(Bridgeport, false, false);
cntMarker += Bridgeport.length;
map.addOverlays(Danielson);
centerByArray(Danielson, false, false);
cntMarker += Danielson.length;
map.addOverlays(Enfield);
centerByArray(Enfield, false, false);
cntMarker += Enfield.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(Middletown);
centerByArray(Middletown, false, false);
cntMarker += Middletown.length;
map.addOverlays(New_Haven);
centerByArray(New_Haven, false, false);
cntMarker += New_Haven.length;
map.addOverlays(New_London);
centerByArray(New_London, false, false);
cntMarker += New_London.length;
map.addOverlays(Norwalk);
centerByArray(Norwalk, false, false);
cntMarker += Norwalk.length;
map.addOverlays(Norwich);
centerByArray(Norwich, false, false);
cntMarker += Norwich.length;
map.addOverlays(Southington);
centerByArray(Southington, false, false);
cntMarker += Southington.length;
map.addOverlays(Suffield);
centerByArray(Suffield, false, false);
cntMarker += Suffield.length;
map.addOverlays(Waterbury);
centerByArray(Waterbury, false, false);
cntMarker += Waterbury.length;
map.addOverlays(Winsted);
centerByArray(Winsted, false, false);
cntMarker += Winsted.length;
reCenterMap();
//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');
}
}
function createMarker(point, label, icon){
var marker = new GMarker(point, icon);
var html = label;
GEvent.addListener(marker, "click", function() { marker.openInfoWindowHtml(html); });
return marker;
}