function addMarkers()
{
mySelect = document.getElementById('selection');
Andover = [];Mansfield_Cent = [];Storrs = [];Tolland = [];Bolton = [];Stafford_Sprin = [];Coventry = [];Somers = [];Vernon = [];Ellington = [];West_Willingto = [];Hebron = [];Columbia = [];Rockville = [];Staffordville = [];Union = [];mySelect.options[mySelect.options.length] = new Option("Andover schools",'all=Andover');
mySelect.options[mySelect.options.length] = new Option("Bolton schools",'all=Bolton');
mySelect.options[mySelect.options.length] = new Option("Columbia schools",'all=Columbia');
mySelect.options[mySelect.options.length] = new Option("Coventry schools",'all=Coventry');
mySelect.options[mySelect.options.length] = new Option("Ellington schools",'all=Ellington');
mySelect.options[mySelect.options.length] = new Option("Hebron schools",'all=Hebron');
mySelect.options[mySelect.options.length] = new Option("Mansfield Cent schools",'all=Mansfield_Cent');
mySelect.options[mySelect.options.length] = new Option("Rockville schools",'all=Rockville');
mySelect.options[mySelect.options.length] = new Option("Somers schools",'all=Somers');
mySelect.options[mySelect.options.length] = new Option("Stafford Sprin schools",'all=Stafford_Sprin');
mySelect.options[mySelect.options.length] = new Option("Staffordville schools",'all=Staffordville');
mySelect.options[mySelect.options.length] = new Option("Storrs schools",'all=Storrs');
mySelect.options[mySelect.options.length] = new Option("Tolland schools",'all=Tolland');
mySelect.options[mySelect.options.length] = new Option("Union schools",'all=Union');
mySelect.options[mySelect.options.length] = new Option("Vernon schools",'all=Vernon');
mySelect.options[mySelect.options.length] = new Option("West Willingto schools",'all=West_Willingto');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Andover[Andover.length] = createMarker(new GPoint(-72.36891174,41.72769165),"
",iconRd);
mySelect.options[mySelect.options.length] = new Option("Andover Elementary School",'Andover=' + Andover.length);
Mansfield_Cent[Mansfield_Cent.length] = createMarker(new GPoint(-72.26058960,41.75123596),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Annie E. Vinton School",'Mansfield_Cent=' + Mansfield_Cent.length);
Storrs[Storrs.length] = createMarker(new GPoint(-72.29473877,41.81383514),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bergin Correctional Institute High School",'Storrs=' + Storrs.length);
Tolland[Tolland.length] = createMarker(new GPoint(-72.33277893,41.85942078),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Birch Grove Primary School",'Tolland=' + Tolland.length);
Bolton[Bolton.length] = createMarker(new GPoint(-72.44311523,41.77575684),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Bolton Center School",'Bolton=' + Bolton.length);
Bolton[Bolton.length] = createMarker(new GPoint(-72.42290497,41.76201248),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bolton High School",'Bolton=' + Bolton.length);
Stafford_Sprin[Stafford_Sprin.length] = createMarker(new GPoint(-72.30711365,41.95617676),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Borough Elementary School",'Stafford_Sprin=' + Stafford_Sprin.length);
Coventry[Coventry.length] = createMarker(new GPoint(-72.31410217,41.78084946),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Capt. Nathan Hale School",'Coventry=' + Coventry.length);
Somers[Somers.length] = createMarker(new GPoint(-72.49874878,42.03273392),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cci/somers - Osborne High School",'Somers=' + Somers.length);
Vernon[Vernon.length] = createMarker(new GPoint(-72.46672821,41.83893967),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Center Road School",'Vernon=' + Vernon.length);
Ellington[Ellington.length] = createMarker(new GPoint(-72.46685028,41.90319443),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Center School",'Ellington=' + Ellington.length);
West_Willingto[West_Willingto.length] = createMarker(new GPoint(-72.26214600,41.87359238),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Center School",'West_Willingto=' + West_Willingto.length);
Coventry[Coventry.length] = createMarker(new GPoint(-72.30025200,41.76799000),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Coventry Early Education Development (ceed)",'Coventry=' + Coventry.length);
Coventry[Coventry.length] = createMarker(new GPoint(-72.36619568,41.79552841),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Coventry Grammar School",'Coventry=' + Coventry.length);
Coventry[Coventry.length] = createMarker(new GPoint(-72.31333923,41.78261948),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Coventry High School",'Coventry=' + Coventry.length);
Ellington[Ellington.length] = createMarker(new GPoint(-72.37872314,41.93190765),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Crystal Lake School",'Ellington=' + Ellington.length);
Storrs[Storrs.length] = createMarker(new GPoint(-72.28267670,41.81798553),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Dorothy C. Goodwin Elementary School",'Storrs=' + Storrs.length);
Storrs[Storrs.length] = createMarker(new GPoint(-72.24376678,41.80469131),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("E. O. Smith High School",'Storrs=' + Storrs.length);
Ellington[Ellington.length] = createMarker(new GPoint(-72.46056366,41.90788269),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Ellington High School",'Ellington=' + Ellington.length);
Ellington[Ellington.length] = createMarker(new GPoint(-72.46034241,41.87836838),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Ellington Middle School",'Ellington=' + Ellington.length);
Coventry[Coventry.length] = createMarker(new GPoint(-72.31230927,41.75963211),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("George Hersey Robertson School",'Coventry=' + Coventry.length);
Hebron[Hebron.length] = createMarker(new GPoint(-72.40384674,41.67425537),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Gilead Hill School",'Hebron=' + Hebron.length);
West_Willingto[West_Willingto.length] = createMarker(new GPoint(-72.30163574,41.85106277),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Hall Memorial School",'West_Willingto=' + West_Willingto.length);
Hebron[Hebron.length] = createMarker(new GPoint(-72.36078644,41.65123749),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Hebron Elementary School",'Hebron=' + Hebron.length);
Coventry[Coventry.length] = createMarker(new GPoint(-72.32849884,41.77799988),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Homebound Elementary School",'Coventry=' + Coventry.length);
Somers[Somers.length] = createMarker(new GPoint(-72.45349884,41.99679947),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Homebound Elementary School",'Somers=' + Somers.length);
Storrs[Storrs.length] = createMarker(new GPoint(-72.24407196,41.80458069),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Homebound High School",'Storrs=' + Storrs.length);
Columbia[Columbia.length] = createMarker(new GPoint(-72.30329895,41.70370102),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Horace W. Porter School",'Columbia=' + Columbia.length);
Vernon[Vernon.length] = createMarker(new GPoint(-72.46949005,41.80998611),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Lake Street School",'Vernon=' + Vernon.length);
Somers[Somers.length] = createMarker(new GPoint(-72.44721222,41.98560715),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Mabelle B. Avery Middle School",'Somers=' + Somers.length);
Storrs[Storrs.length] = createMarker(new GPoint(-72.22898102,41.77540588),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Mansfield Middle School",'Storrs=' + Storrs.length);
Rockville[Rockville.length] = createMarker(new GPoint(-72.46232605,41.86929703),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Maple Street School",'Rockville=' + Rockville.length);
Rockville[Rockville.length] = createMarker(new GPoint(-72.43177032,41.86135101),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Northeast School",'Rockville=' + Rockville.length);
Somers[Somers.length] = createMarker(new GPoint(-72.49874878,42.03273392),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Northern Correctional Institute High School",'Somers=' + Somers.length);
Tolland[Tolland.length] = createMarker(new GPoint(-72.37262726,41.86921692),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Parker Memorial School",'Tolland=' + Tolland.length);
Hebron[Hebron.length] = createMarker(new GPoint(-72.36773682,41.66193771),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Rham High School",'Hebron=' + Hebron.length);
Hebron[Hebron.length] = createMarker(new GPoint(-72.36486816,41.66159439),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Rham Middle School",'Hebron=' + Hebron.length);
Rockville[Rockville.length] = createMarker(new GPoint(-72.44867400,41.86745500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Rockville High School",'Rockville=' + Rockville.length);
Vernon[Vernon.length] = createMarker(new GPoint(-72.49287415,41.85576248),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Skinner Road School",'Vernon=' + Vernon.length);
Somers[Somers.length] = createMarker(new GPoint(-72.44721222,41.98560715),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Somers Elementary School",'Somers=' + Somers.length);
Somers[Somers.length] = createMarker(new GPoint(-72.44721222,41.98560715),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Somers High School",'Somers=' + Somers.length);
Mansfield_Cent[Mansfield_Cent.length] = createMarker(new GPoint(-72.19288635,41.77365494),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Southeast Elementary School",'Mansfield_Cent=' + Mansfield_Cent.length);
Stafford_Sprin[Stafford_Sprin.length] = createMarker(new GPoint(-72.28320312,41.97800064),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Stafford High School",'Stafford_Sprin=' + Stafford_Sprin.length);
Stafford_Sprin[Stafford_Sprin.length] = createMarker(new GPoint(-72.28320312,41.97800064),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Stafford Middle School",'Stafford_Sprin=' + Stafford_Sprin.length);
Staffordville[Staffordville.length] = createMarker(new GPoint(-72.28320312,41.97800064),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Staffordville School",'Staffordville=' + Staffordville.length);
Tolland[Tolland.length] = createMarker(new GPoint(-72.34839630,41.87363434),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Tolland High School",'Tolland=' + Tolland.length);
Tolland[Tolland.length] = createMarker(new GPoint(-72.37182617,41.86929321),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Tolland Middle School",'Tolland=' + Tolland.length);
Columbia[Columbia.length] = createMarker(new GPoint(-72.17148590,41.74429703),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Transitional Educational Alt Middle/high School",'Columbia=' + Columbia.length);
Union[Union.length] = createMarker(new GPoint(-72.15808105,41.98492813),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Union Elementary School",'Union=' + Union.length);
Vernon[Vernon.length] = createMarker(new GPoint(-72.46177673,41.84094620),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Vernon Center Middle School",'Vernon=' + Vernon.length);
Stafford_Sprin[Stafford_Sprin.length] = createMarker(new GPoint(-72.34635925,41.96889496),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("West Stafford School",'Stafford_Sprin=' + Stafford_Sprin.length);
Ellington[Ellington.length] = createMarker(new GPoint(-72.49883270,41.86959839),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Windermere School",'Ellington=' + Ellington.length);
Columbia[Columbia.length] = createMarker(new GPoint(-72.24700928,41.71715927),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Windham Early Childhood Center",'Columbia=' + Columbia.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,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(Andover);
map.removeOverlays(Bolton);
map.removeOverlays(Columbia);
map.removeOverlays(Coventry);
map.removeOverlays(Ellington);
map.removeOverlays(Hebron);
map.removeOverlays(Mansfield_Cent);
map.removeOverlays(Rockville);
map.removeOverlays(Somers);
map.removeOverlays(Stafford_Sprin);
map.removeOverlays(Staffordville);
map.removeOverlays(Storrs);
map.removeOverlays(Tolland);
map.removeOverlays(Union);
map.removeOverlays(Vernon);
map.removeOverlays(West_Willingto);
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(Andover);map.removeOverlays(Andover);
map.removeOverlays(Bolton);
map.removeOverlays(Columbia);
map.removeOverlays(Coventry);
map.removeOverlays(Ellington);
map.removeOverlays(Hebron);
map.removeOverlays(Mansfield_Cent);
map.removeOverlays(Rockville);
map.removeOverlays(Somers);
map.removeOverlays(Stafford_Sprin);
map.removeOverlays(Staffordville);
map.removeOverlays(Storrs);
map.removeOverlays(Tolland);
map.removeOverlays(Union);
map.removeOverlays(Vernon);
map.removeOverlays(West_Willingto);
map.addOverlays(Andover);
centerByArray(Andover, false, false);
cntMarker += Andover.length;
map.addOverlays(Bolton);
centerByArray(Bolton, false, false);
cntMarker += Bolton.length;
map.addOverlays(Columbia);
centerByArray(Columbia, false, false);
cntMarker += Columbia.length;
map.addOverlays(Coventry);
centerByArray(Coventry, false, false);
cntMarker += Coventry.length;
map.addOverlays(Ellington);
centerByArray(Ellington, false, false);
cntMarker += Ellington.length;
map.addOverlays(Hebron);
centerByArray(Hebron, false, false);
cntMarker += Hebron.length;
map.addOverlays(Mansfield_Cent);
centerByArray(Mansfield_Cent, false, false);
cntMarker += Mansfield_Cent.length;
map.addOverlays(Rockville);
centerByArray(Rockville, false, false);
cntMarker += Rockville.length;
map.addOverlays(Somers);
centerByArray(Somers, false, false);
cntMarker += Somers.length;
map.addOverlays(Stafford_Sprin);
centerByArray(Stafford_Sprin, false, false);
cntMarker += Stafford_Sprin.length;
map.addOverlays(Staffordville);
centerByArray(Staffordville, false, false);
cntMarker += Staffordville.length;
map.addOverlays(Storrs);
centerByArray(Storrs, false, false);
cntMarker += Storrs.length;
map.addOverlays(Tolland);
centerByArray(Tolland, false, false);
cntMarker += Tolland.length;
map.addOverlays(Union);
centerByArray(Union, false, false);
cntMarker += Union.length;
map.addOverlays(Vernon);
centerByArray(Vernon, false, false);
cntMarker += Vernon.length;
map.addOverlays(West_Willingto);
centerByArray(West_Willingto, false, false);
cntMarker += West_Willingto.length;
centerByArray(Andover,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');
}
}