function addMarkers() { mySelect = document.getElementById('selection'); Hartford = [];Bridgeport = [];New_Britain = [];Hamden = [];Groton = [];Ansonia = [];Meriden = [];Danielson = [];Danbury = [];Manchester = [];Stamford = [];Norwich = [];Torrington = [];Milford = [];Middletown = [];Waterbury = [];Willimantic = [];mySelect.options[mySelect.options.length] = new Option("Ansonia vocational schools",'all=Ansonia'); mySelect.options[mySelect.options.length] = new Option("Bridgeport vocational schools",'all=Bridgeport'); mySelect.options[mySelect.options.length] = new Option("Danbury vocational schools",'all=Danbury'); mySelect.options[mySelect.options.length] = new Option("Danielson vocational schools",'all=Danielson'); mySelect.options[mySelect.options.length] = new Option("Groton vocational schools",'all=Groton'); mySelect.options[mySelect.options.length] = new Option("Hamden vocational schools",'all=Hamden'); mySelect.options[mySelect.options.length] = new Option("Hartford vocational schools",'all=Hartford'); mySelect.options[mySelect.options.length] = new Option("Manchester vocational schools",'all=Manchester'); mySelect.options[mySelect.options.length] = new Option("Meriden vocational schools",'all=Meriden'); mySelect.options[mySelect.options.length] = new Option("Middletown vocational schools",'all=Middletown'); mySelect.options[mySelect.options.length] = new Option("Milford vocational schools",'all=Milford'); mySelect.options[mySelect.options.length] = new Option("New Britain vocational schools",'all=New_Britain'); mySelect.options[mySelect.options.length] = new Option("Norwich vocational schools",'all=Norwich'); mySelect.options[mySelect.options.length] = new Option("Stamford vocational schools",'all=Stamford'); mySelect.options[mySelect.options.length] = new Option("Torrington vocational schools",'all=Torrington'); mySelect.options[mySelect.options.length] = new Option("Waterbury vocational schools",'all=Waterbury'); mySelect.options[mySelect.options.length] = new Option("Willimantic vocational schools",'all=Willimantic'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Hartford[Hartford.length] = createMarker(new GPoint(-72.70678711,41.74064636),"
",iconGr); mySelect.options[mySelect.options.length] = new Option("A. I. Prince Vocational School",'Hartford=' + Hartford.length); Bridgeport[Bridgeport.length] = createMarker(new GPoint(-73.16492462,41.20017624),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Bullard-havens Vocational School",'Bridgeport=' + Bridgeport.length); New_Britain[New_Britain.length] = createMarker(new GPoint(-72.80695343,41.68683624),"",iconGr); mySelect.options[mySelect.options.length] = new Option("E. C. Goodwin Vocational School",'New_Britain=' + New_Britain.length); Hamden[Hamden.length] = createMarker(new GPoint(-72.91614532,41.38198471),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Eli Whitney Vocational School",'Hamden=' + Hamden.length); Groton[Groton.length] = createMarker(new GPoint(-72.02203369,41.34695053),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Ella T. Grasso Southeastern High School",'Groton=' + Groton.length); Ansonia[Ansonia.length] = createMarker(new GPoint(-73.07871400,41.34316000),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Emmett O'brien Technical High School",'Ansonia=' + Ansonia.length); Meriden[Meriden.length] = createMarker(new GPoint(-72.83187103,41.52867889),"",iconGr); mySelect.options[mySelect.options.length] = new Option("H. C. Wilcox Vocational School",'Meriden=' + Meriden.length); Danielson[Danielson.length] = createMarker(new GPoint(-71.89277649,41.81919479),"",iconGr); mySelect.options[mySelect.options.length] = new Option("H. H. Ellis Vocational School",'Danielson=' + Danielson.length); Danbury[Danbury.length] = createMarker(new GPoint(-73.45428467,41.41331863),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Henry Abbott Vocational School",'Danbury=' + Danbury.length); Manchester[Manchester.length] = createMarker(new GPoint(-72.56172943,41.78099823),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Howell Cheney Vocational School",'Manchester=' + Manchester.length); Stamford[Stamford.length] = createMarker(new GPoint(-73.53959656,41.04850006),"",iconGr); mySelect.options[mySelect.options.length] = new Option("J. M. Wright Vocational School",'Stamford=' + Stamford.length); Norwich[Norwich.length] = createMarker(new GPoint(-72.10456848,41.50884628),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Norwich Vocational School",'Norwich=' + Norwich.length); Torrington[Torrington.length] = createMarker(new GPoint(-73.11174774,41.81016922),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Oliver Wolcott Vocational School",'Torrington=' + Torrington.length); Milford[Milford.length] = createMarker(new GPoint(-73.04405212,41.25159836),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Platt Vocational School",'Milford=' + Milford.length); Middletown[Middletown.length] = createMarker(new GPoint(-72.67355347,41.52750015),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Vinal Vocational School",'Middletown=' + Middletown.length); Waterbury[Waterbury.length] = createMarker(new GPoint(-73.06486511,41.57481766),"",iconGr); mySelect.options[mySelect.options.length] = new Option("W. F. Kaynor Vocational School",'Waterbury=' + Waterbury.length); Willimantic[Willimantic.length] = createMarker(new GPoint(-72.22061157,41.71839142),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Windham Vocational School",'Willimantic=' + Willimantic.length); maxLng = -71.89277649; maxLat = 41.81919479; minLng = -73.53959656; minLat = 41.04850006; reCenterMap(); map.removeOverlays(Ansonia); map.removeOverlays(Bridgeport); map.removeOverlays(Danbury); map.removeOverlays(Danielson); map.removeOverlays(Groton); map.removeOverlays(Hamden); map.removeOverlays(Hartford); map.removeOverlays(Manchester); map.removeOverlays(Meriden); map.removeOverlays(Middletown); map.removeOverlays(Milford); map.removeOverlays(New_Britain); map.removeOverlays(Norwich); map.removeOverlays(Stamford); map.removeOverlays(Torrington); map.removeOverlays(Waterbury); map.removeOverlays(Willimantic); setTimeout(function(){map.addOverlays(Ansonia)},1000); setTimeout(function(){map.addOverlays(Bridgeport)},1000); setTimeout(function(){map.addOverlays(Danbury)},1000); setTimeout(function(){map.addOverlays(Danielson)},1000); setTimeout(function(){map.addOverlays(Groton)},1000); setTimeout(function(){map.addOverlays(Hamden)},1000); setTimeout(function(){map.addOverlays(Hartford)},1000); setTimeout(function(){map.addOverlays(Manchester)},1000); setTimeout(function(){map.addOverlays(Meriden)},1000); setTimeout(function(){map.addOverlays(Middletown)},1000); setTimeout(function(){map.addOverlays(Milford)},1000); setTimeout(function(){map.addOverlays(New_Britain)},1000); setTimeout(function(){map.addOverlays(Norwich)},1000); setTimeout(function(){map.addOverlays(Stamford)},1000); setTimeout(function(){map.addOverlays(Torrington)},1000); setTimeout(function(){map.addOverlays(Waterbury)},1000); setTimeout(function(){map.addOverlays(Willimantic)},1000); } // 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(Ansonia); map.removeOverlays(Bridgeport); map.removeOverlays(Danbury); map.removeOverlays(Danielson); map.removeOverlays(Groton); map.removeOverlays(Hamden); map.removeOverlays(Hartford); map.removeOverlays(Manchester); map.removeOverlays(Meriden); map.removeOverlays(Middletown); map.removeOverlays(Milford); map.removeOverlays(New_Britain); map.removeOverlays(Norwich); map.removeOverlays(Stamford); map.removeOverlays(Torrington); map.removeOverlays(Waterbury); map.removeOverlays(Willimantic); 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(Hartford);map.removeOverlays(Ansonia); map.removeOverlays(Bridgeport); map.removeOverlays(Danbury); map.removeOverlays(Danielson); map.removeOverlays(Groton); map.removeOverlays(Hamden); map.removeOverlays(Hartford); map.removeOverlays(Manchester); map.removeOverlays(Meriden); map.removeOverlays(Middletown); map.removeOverlays(Milford); map.removeOverlays(New_Britain); map.removeOverlays(Norwich); map.removeOverlays(Stamford); map.removeOverlays(Torrington); map.removeOverlays(Waterbury); map.removeOverlays(Willimantic); map.addOverlays(Ansonia); centerByArray(Ansonia, false, false); cntMarker += Ansonia.length; map.addOverlays(Bridgeport); centerByArray(Bridgeport, false, false); cntMarker += Bridgeport.length; map.addOverlays(Danbury); centerByArray(Danbury, false, false); cntMarker += Danbury.length; map.addOverlays(Danielson); centerByArray(Danielson, false, false); cntMarker += Danielson.length; map.addOverlays(Groton); centerByArray(Groton, false, false); cntMarker += Groton.length; map.addOverlays(Hamden); centerByArray(Hamden, false, false); cntMarker += Hamden.length; map.addOverlays(Hartford); centerByArray(Hartford, false, false); cntMarker += Hartford.length; map.addOverlays(Manchester); centerByArray(Manchester, false, false); cntMarker += Manchester.length; map.addOverlays(Meriden); centerByArray(Meriden, false, false); cntMarker += Meriden.length; map.addOverlays(Middletown); centerByArray(Middletown, false, false); cntMarker += Middletown.length; map.addOverlays(Milford); centerByArray(Milford, false, false); cntMarker += Milford.length; map.addOverlays(New_Britain); centerByArray(New_Britain, false, false); cntMarker += New_Britain.length; map.addOverlays(Norwich); centerByArray(Norwich, false, false); cntMarker += Norwich.length; map.addOverlays(Stamford); centerByArray(Stamford, false, false); cntMarker += Stamford.length; map.addOverlays(Torrington); centerByArray(Torrington, false, false); cntMarker += Torrington.length; map.addOverlays(Waterbury); centerByArray(Waterbury, false, false); cntMarker += Waterbury.length; map.addOverlays(Willimantic); centerByArray(Willimantic, false, false); cntMarker += Willimantic.length; centerByArray(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'); } }