function addMarkers()
{
mySelect = document.getElementById('selection');
Ashaway = [];Westerly = [];Block_Island = [];Bradford = [];Wakefield = [];Wood_River_Junction = [];Charlestown = [];Kingston = [];North_Kingstown = [];Hope_Valley = [];Saunderstown = [];Exeter = [];Narragansett = [];Peace_Dale = [];Wyoming = [];West_Kingston = [];mySelect.options[mySelect.options.length] = new Option("Ashaway schools",'all=Ashaway');
mySelect.options[mySelect.options.length] = new Option("Block Island schools",'all=Block_Island');
mySelect.options[mySelect.options.length] = new Option("Bradford schools",'all=Bradford');
mySelect.options[mySelect.options.length] = new Option("Charlestown schools",'all=Charlestown');
mySelect.options[mySelect.options.length] = new Option("Exeter schools",'all=Exeter');
mySelect.options[mySelect.options.length] = new Option("Hope Valley schools",'all=Hope_Valley');
mySelect.options[mySelect.options.length] = new Option("Kingston schools",'all=Kingston');
mySelect.options[mySelect.options.length] = new Option("Narragansett schools",'all=Narragansett');
mySelect.options[mySelect.options.length] = new Option("North Kingstown schools",'all=North_Kingstown');
mySelect.options[mySelect.options.length] = new Option("Peace Dale schools",'all=Peace_Dale');
mySelect.options[mySelect.options.length] = new Option("Saunderstown schools",'all=Saunderstown');
mySelect.options[mySelect.options.length] = new Option("Wakefield schools",'all=Wakefield');
mySelect.options[mySelect.options.length] = new Option("West Kingston schools",'all=West_Kingston');
mySelect.options[mySelect.options.length] = new Option("Westerly schools",'all=Westerly');
mySelect.options[mySelect.options.length] = new Option("Wood River Junction schools",'all=Wood_River_Junction');
mySelect.options[mySelect.options.length] = new Option("Wyoming schools",'all=Wyoming');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Ashaway[Ashaway.length] = createMarker(new GPoint(-71.78977203,41.41983414),"
",iconRd);
mySelect.options[mySelect.options.length] = new Option("Ashaway Elementary School",'Ashaway=' + Ashaway.length);
Westerly[Westerly.length] = createMarker(new GPoint(-71.82247162,41.37660980),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Babcock Middle School",'Westerly=' + Westerly.length);
Block_Island[Block_Island.length] = createMarker(new GPoint(-71.57299805,41.17499924),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Block Island School",'Block_Island=' + Block_Island.length);
Bradford[Bradford.length] = createMarker(new GPoint(-71.73812103,41.39342117),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Bradford Elementary School",'Bradford=' + Bradford.length);
Wakefield[Wakefield.length] = createMarker(new GPoint(-71.48594666,41.45550537),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Broad Rock Middle School",'Wakefield=' + Wakefield.length);
Wood_River_Junction[Wood_River_Junction.length] = createMarker(new GPoint(-71.69497681,41.44878387),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Chariho Career & Technical Center",'Wood_River_Junction=' + Wood_River_Junction.length);
Wood_River_Junction[Wood_River_Junction.length] = createMarker(new GPoint(-71.69918060,41.45978165),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Chariho High School",'Wood_River_Junction=' + Wood_River_Junction.length);
Wood_River_Junction[Wood_River_Junction.length] = createMarker(new GPoint(-71.69918060,41.45978165),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Chariho Regional Middle School",'Wood_River_Junction=' + Wood_River_Junction.length);
Charlestown[Charlestown.length] = createMarker(new GPoint(-71.65592194,41.44867325),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Charlestown Elementary School",'Charlestown=' + Charlestown.length);
Kingston[Kingston.length] = createMarker(new GPoint(-71.44508362,41.59231186),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Compass Charter School",'Kingston=' + Kingston.length);
Wakefield[Wakefield.length] = createMarker(new GPoint(-71.51895142,41.45930099),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Curtis Corner Middle School",'Wakefield=' + Wakefield.length);
North_Kingstown[North_Kingstown.length] = createMarker(new GPoint(-71.46540833,41.62031174),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Davisville Middle School",'North_Kingstown=' + North_Kingstown.length);
North_Kingstown[North_Kingstown.length] = createMarker(new GPoint(-71.46801758,41.61354828),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Davisville School",'North_Kingstown=' + North_Kingstown.length);
Westerly[Westerly.length] = createMarker(new GPoint(-97.24896800,32.86378200),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Dunn's Corners School",'Westerly=' + Westerly.length);
Kingston[Kingston.length] = createMarker(new GPoint(-71.42250061,41.64035416),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Farm School",'Kingston=' + Kingston.length);
North_Kingstown[North_Kingstown.length] = createMarker(new GPoint(-71.44508362,41.59231186),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Fishing Cove El. School",'North_Kingstown=' + North_Kingstown.length);
North_Kingstown[North_Kingstown.length] = createMarker(new GPoint(-71.45344543,41.62103653),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Forest Park El. School",'North_Kingstown=' + North_Kingstown.length);
North_Kingstown[North_Kingstown.length] = createMarker(new GPoint(-71.44040680,41.54818726),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Hamilton School",'North_Kingstown=' + North_Kingstown.length);
Wakefield[Wakefield.length] = createMarker(new GPoint(-71.49485779,41.44484711),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Hazard School",'Wakefield=' + Wakefield.length);
Hope_Valley[Hope_Valley.length] = createMarker(new GPoint(-71.71605682,41.50767899),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Hope Valley Elementary School",'Hope_Valley=' + Hope_Valley.length);
Saunderstown[Saunderstown.length] = createMarker(new GPoint(-71.49877167,41.45092773),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Kingston Hill Academy",'Saunderstown=' + Saunderstown.length);
Wakefield[Wakefield.length] = createMarker(new GPoint(-71.54951477,41.38822174),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Matunuck School",'Wakefield=' + Wakefield.length);
Exeter[Exeter.length] = createMarker(new GPoint(-71.64594269,41.59716415),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Metcalf School",'Exeter=' + Exeter.length);
Narragansett[Narragansett.length] = createMarker(new GPoint(-71.47131348,41.43604660),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Narragansett Elementary School",'Narragansett=' + Narragansett.length);
Narragansett[Narragansett.length] = createMarker(new GPoint(-71.47187042,41.42770767),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Narragansett High School",'Narragansett=' + Narragansett.length);
Narragansett[Narragansett.length] = createMarker(new GPoint(-71.47142029,41.42739868),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Narragansett Pier School",'Narragansett=' + Narragansett.length);
North_Kingstown[North_Kingstown.length] = createMarker(new GPoint(-71.44758606,41.55807877),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("North Kingstown Senior High School",'North_Kingstown=' + North_Kingstown.length);
Peace_Dale[Peace_Dale.length] = createMarker(new GPoint(-71.49964142,41.45303726),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Peace Dale School",'Peace_Dale=' + Peace_Dale.length);
North_Kingstown[North_Kingstown.length] = createMarker(new GPoint(-71.43827820,41.61467361),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Quidnessett School",'North_Kingstown=' + North_Kingstown.length);
Wyoming[Wyoming.length] = createMarker(new GPoint(-71.66290283,41.50028992),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Richmond Elementary School",'Wyoming=' + Wyoming.length);
Wood_River_Junction[Wood_River_Junction.length] = createMarker(new GPoint(-71.71885681,41.44039917),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Ryse (clinical Day)",'Wood_River_Junction=' + Wood_River_Junction.length);
Wakefield[Wakefield.length] = createMarker(new GPoint(-71.49567413,41.44801331),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("South Kingstown High School",'Wakefield=' + Wakefield.length);
Wakefield[Wakefield.length] = createMarker(new GPoint(-71.52644348,41.46216583),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("South Road Elementary School",'Wakefield=' + Wakefield.length);
Westerly[Westerly.length] = createMarker(new GPoint(-71.83417511,41.40161133),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Springbrook Elementary School",'Westerly=' + Westerly.length);
Westerly[Westerly.length] = createMarker(new GPoint(-71.82476044,41.36479950),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("State Street School",'Westerly=' + Westerly.length);
North_Kingstown[North_Kingstown.length] = createMarker(new GPoint(-71.48551178,41.59232330),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Stony Lane El. School",'North_Kingstown=' + North_Kingstown.length);
Westerly[Westerly.length] = createMarker(new GPoint(-71.81451416,41.37933350),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Tower Street School",'Westerly=' + Westerly.length);
Wakefield[Wakefield.length] = createMarker(new GPoint(-71.50215149,41.43939209),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Wakefield School",'Wakefield=' + Wakefield.length);
Exeter[Exeter.length] = createMarker(new GPoint(-71.61433411,41.58094788),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Wawaloam School",'Exeter=' + Exeter.length);
West_Kingston[West_Kingston.length] = createMarker(new GPoint(-71.55236053,41.47818756),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("West Kingston School",'West_Kingston=' + West_Kingston.length);
Westerly[Westerly.length] = createMarker(new GPoint(-71.81981659,41.37549973),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Westerly High School",'Westerly=' + Westerly.length);
North_Kingstown[North_Kingstown.length] = createMarker(new GPoint(-71.46245575,41.56766129),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Wickford Middle School",'North_Kingstown=' + North_Kingstown.length);
North_Kingstown[North_Kingstown.length] = createMarker(new GPoint(-71.45633698,41.56813812),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Wickford School",'North_Kingstown=' + North_Kingstown.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(Ashaway);
map.removeOverlays(Block_Island);
map.removeOverlays(Bradford);
map.removeOverlays(Charlestown);
map.removeOverlays(Exeter);
map.removeOverlays(Hope_Valley);
map.removeOverlays(Kingston);
map.removeOverlays(Narragansett);
map.removeOverlays(North_Kingstown);
map.removeOverlays(Peace_Dale);
map.removeOverlays(Saunderstown);
map.removeOverlays(Wakefield);
map.removeOverlays(West_Kingston);
map.removeOverlays(Westerly);
map.removeOverlays(Wood_River_Junction);
map.removeOverlays(Wyoming);
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(Ashaway);map.removeOverlays(Ashaway);
map.removeOverlays(Block_Island);
map.removeOverlays(Bradford);
map.removeOverlays(Charlestown);
map.removeOverlays(Exeter);
map.removeOverlays(Hope_Valley);
map.removeOverlays(Kingston);
map.removeOverlays(Narragansett);
map.removeOverlays(North_Kingstown);
map.removeOverlays(Peace_Dale);
map.removeOverlays(Saunderstown);
map.removeOverlays(Wakefield);
map.removeOverlays(West_Kingston);
map.removeOverlays(Westerly);
map.removeOverlays(Wood_River_Junction);
map.removeOverlays(Wyoming);
map.addOverlays(Ashaway);
centerByArray(Ashaway, false, false);
cntMarker += Ashaway.length;
map.addOverlays(Block_Island);
centerByArray(Block_Island, false, false);
cntMarker += Block_Island.length;
map.addOverlays(Bradford);
centerByArray(Bradford, false, false);
cntMarker += Bradford.length;
map.addOverlays(Charlestown);
centerByArray(Charlestown, false, false);
cntMarker += Charlestown.length;
map.addOverlays(Exeter);
centerByArray(Exeter, false, false);
cntMarker += Exeter.length;
map.addOverlays(Hope_Valley);
centerByArray(Hope_Valley, false, false);
cntMarker += Hope_Valley.length;
map.addOverlays(Kingston);
centerByArray(Kingston, false, false);
cntMarker += Kingston.length;
map.addOverlays(Narragansett);
centerByArray(Narragansett, false, false);
cntMarker += Narragansett.length;
map.addOverlays(North_Kingstown);
centerByArray(North_Kingstown, false, false);
cntMarker += North_Kingstown.length;
map.addOverlays(Peace_Dale);
centerByArray(Peace_Dale, false, false);
cntMarker += Peace_Dale.length;
map.addOverlays(Saunderstown);
centerByArray(Saunderstown, false, false);
cntMarker += Saunderstown.length;
map.addOverlays(Wakefield);
centerByArray(Wakefield, false, false);
cntMarker += Wakefield.length;
map.addOverlays(West_Kingston);
centerByArray(West_Kingston, false, false);
cntMarker += West_Kingston.length;
map.addOverlays(Westerly);
centerByArray(Westerly, false, false);
cntMarker += Westerly.length;
map.addOverlays(Wood_River_Junction);
centerByArray(Wood_River_Junction, false, false);
cntMarker += Wood_River_Junction.length;
map.addOverlays(Wyoming);
centerByArray(Wyoming, false, false);
cntMarker += Wyoming.length;
centerByArray(Ashaway,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');
}
}