function addMarkers(){
mySelect = document.getElementById('selection');
Middletown = [];Warwick = [];Providence = [];W_Warwick = [];Newport = [];Cranston = [];Pascoag = [];Coventry = [];Woonsocket = [];Cumberland = [];Warren = [];East_Greenwich = [];Bristol = [];Portsmouth = [];East_Providence = [];Pawtucket = [];Barrington = [];Riverside = [];Westerly = [];Johnston = [];Central_Falls = [];West_Warwick = [];Greenville = [];mySelect.options[mySelect.options.length] = new Option("Barrington schools",'all=Barrington');
mySelect.options[mySelect.options.length] = new Option("Bristol schools",'all=Bristol');
mySelect.options[mySelect.options.length] = new Option("Central Falls schools",'all=Central_Falls');
mySelect.options[mySelect.options.length] = new Option("Coventry schools",'all=Coventry');
mySelect.options[mySelect.options.length] = new Option("Cranston schools",'all=Cranston');
mySelect.options[mySelect.options.length] = new Option("Cumberland schools",'all=Cumberland');
mySelect.options[mySelect.options.length] = new Option("East Greenwich schools",'all=East_Greenwich');
mySelect.options[mySelect.options.length] = new Option("East Providence schools",'all=East_Providence');
mySelect.options[mySelect.options.length] = new Option("Greenville schools",'all=Greenville');
mySelect.options[mySelect.options.length] = new Option("Johnston schools",'all=Johnston');
mySelect.options[mySelect.options.length] = new Option("Middletown schools",'all=Middletown');
mySelect.options[mySelect.options.length] = new Option("Newport schools",'all=Newport');
mySelect.options[mySelect.options.length] = new Option("Pascoag schools",'all=Pascoag');
mySelect.options[mySelect.options.length] = new Option("Pawtucket schools",'all=Pawtucket');
mySelect.options[mySelect.options.length] = new Option("Portsmouth schools",'all=Portsmouth');
mySelect.options[mySelect.options.length] = new Option("Providence schools",'all=Providence');
mySelect.options[mySelect.options.length] = new Option("Riverside schools",'all=Riverside');
mySelect.options[mySelect.options.length] = new Option("W Warwick schools",'all=W_Warwick');
mySelect.options[mySelect.options.length] = new Option("Warren schools",'all=Warren');
mySelect.options[mySelect.options.length] = new Option("Warwick schools",'all=Warwick');
mySelect.options[mySelect.options.length] = new Option("West Warwick schools",'all=West_Warwick');
mySelect.options[mySelect.options.length] = new Option("Westerly schools",'all=Westerly');
mySelect.options[mySelect.options.length] = new Option("Woonsocket schools",'all=Woonsocket');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Middletown[Middletown.length] = createMarker(new GPoint(-71.29633100,41.52719300),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("All Saints Academy",'Middletown=' + Middletown.length);
Warwick[Warwick.length] = createMarker(new GPoint(-71.39634700,41.70683400),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Bishop Hendricken High School",'Warwick=' + Warwick.length);
Providence[Providence.length] = createMarker(new GPoint(-71.41502800,41.80164600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bishop Mcvinney Elementary School",'Providence=' + Providence.length);
Providence[Providence.length] = createMarker(new GPoint(-71.44317200,41.82922200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Blessed Sacrament School",'Providence=' + Providence.length);
W_Warwick[W_Warwick.length] = createMarker(new GPoint(-71.52502100,41.70320900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Christ The Redeemer Academy",'W_Warwick=' + W_Warwick.length);
Newport[Newport.length] = createMarker(new GPoint(-71.33080500,41.46437900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cluny School",'Newport=' + Newport.length);
Cranston[Cranston.length] = createMarker(new GPoint(-71.45586300,41.76165900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cranston Johnston Catholic Regional School",'Cranston=' + Cranston.length);
Pascoag[Pascoag.length] = createMarker(new GPoint(-71.70435100,41.96002200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Fr Holland Catholic Elementary School",'Pascoag=' + Pascoag.length);
Coventry[Coventry.length] = createMarker(new GPoint(-71.57451100,41.68054700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Fr John J Doyle School",'Coventry=' + Coventry.length);
Woonsocket[Woonsocket.length] = createMarker(new GPoint(-71.47988900,42.00368200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Good Shepherd Catholic School",'Woonsocket=' + Woonsocket.length);
Woonsocket[Woonsocket.length] = createMarker(new GPoint(-71.51186200,42.01209500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Greater Woonsocket Catholic Regional School",'Woonsocket=' + Woonsocket.length);
Providence[Providence.length] = createMarker(new GPoint(-71.43313100,41.82328500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Holy Ghost School",'Providence=' + Providence.length);
Providence[Providence.length] = createMarker(new GPoint(-71.44532600,41.84162400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("La Salle Academy",'Providence=' + Providence.length);
Cumberland[Cumberland.length] = createMarker(new GPoint(-71.41518400,42.00870100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mercymount Country Day School",'Cumberland=' + Cumberland.length);
Woonsocket[Woonsocket.length] = createMarker(new GPoint(-71.50097900,41.99465200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mount St Charles Academy",'Woonsocket=' + Woonsocket.length);
Woonsocket[Woonsocket.length] = createMarker(new GPoint(-71.51593400,41.98433700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Msgr Gadoury Primary School",'Woonsocket=' + Woonsocket.length);
Coventry[Coventry.length] = createMarker(new GPoint(-71.54787600,41.69782400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Notre Dame Reg School",'Coventry=' + Coventry.length);
Warren[Warren.length] = createMarker(new GPoint(-71.27308400,41.74592200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Our Lady Of Fatima High School",'Warren=' + Warren.length);
East_Greenwich[East_Greenwich.length] = createMarker(new GPoint(-71.45744700,41.65452100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Our Lady Of Mercy Regional School",'East_Greenwich=' + East_Greenwich.length);
Bristol[Bristol.length] = createMarker(new GPoint(-71.27338600,41.67122100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Our Lady Of Mt. Carmel School",'Bristol=' + Bristol.length);
Portsmouth[Portsmouth.length] = createMarker(new GPoint(-71.27272600,41.60010000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Portsmouth Abbey School",'Portsmouth=' + Portsmouth.length);
East_Providence[East_Providence.length] = createMarker(new GPoint(-71.37785300,41.81856200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sacred Heart School",'East_Providence=' + East_Providence.length);
Providence[Providence.length] = createMarker(new GPoint(-71.45302200,41.80780700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Bartholomew School",'Providence=' + Providence.length);
Pawtucket[Pawtucket.length] = createMarker(new GPoint(-71.35366700,41.88795300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Cecilia School",'Pawtucket=' + Pawtucket.length);
Bristol[Bristol.length] = createMarker(new GPoint(-71.27333000,41.67496500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Elizabeth School",'Bristol=' + Bristol.length);
Warwick[Warwick.length] = createMarker(new GPoint(-71.44189800,41.73129900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Francis Of Assisi School",'Warwick=' + Warwick.length);
Pawtucket[Pawtucket.length] = createMarker(new GPoint(-71.35513000,41.88757100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Leo The Great Elementary School",'Pawtucket=' + Pawtucket.length);
Barrington[Barrington.length] = createMarker(new GPoint(-71.33951500,41.75093100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Luke Elementary School",'Barrington=' + Barrington.length);
East_Providence[East_Providence.length] = createMarker(new GPoint(-71.35071000,41.84459000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Margaret School",'East_Providence=' + East_Providence.length);
Riverside[Riverside.length] = createMarker(new GPoint(-71.36515700,41.79098200),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("St. Mary Academy-bay View",'Riverside=' + Riverside.length);
Cranston[Cranston.length] = createMarker(new GPoint(-71.46501100,41.78932600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Mary Elementary School",'Cranston=' + Cranston.length);
Providence[Providence.length] = createMarker(new GPoint(-71.43665600,41.81737900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Mary Elementary School",'Providence=' + Providence.length);
Cranston[Cranston.length] = createMarker(new GPoint(-71.42209700,41.77546500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Matthew School",'Cranston=' + Cranston.length);
Warwick[Warwick.length] = createMarker(new GPoint(-71.39196200,41.75469000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Peter School",'Warwick=' + Warwick.length);
Westerly[Westerly.length] = createMarker(new GPoint(-71.82871700,41.37326300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Pius X Elementary School",'Westerly=' + Westerly.length);
Pawtucket[Pawtucket.length] = createMarker(new GPoint(-71.37658400,41.87696100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Raphael Academy",'Pawtucket=' + Pawtucket.length);
Johnston[Johnston.length] = createMarker(new GPoint(-71.48392800,41.79697000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Rocco School",'Johnston=' + Johnston.length);
Warwick[Warwick.length] = createMarker(new GPoint(-71.43188200,41.70805500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Rose Of Lima School",'Warwick=' + Warwick.length);
Providence[Providence.length] = createMarker(new GPoint(-71.46792800,41.83676300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Thomas Regional School",'Providence=' + Providence.length);
Providence[Providence.length] = createMarker(new GPoint(-71.45316900,41.84430500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Augustine School",'Providence=' + Providence.length);
Riverside[Riverside.length] = createMarker(new GPoint(-71.35840100,41.77092000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Brendan School",'Riverside=' + Riverside.length);
Central_Falls[Central_Falls.length] = createMarker(new GPoint(-71.40206700,41.88987400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Elizabeth Ann Seton Academy",'Central_Falls=' + Central_Falls.length);
West_Warwick[West_Warwick.length] = createMarker(new GPoint(-71.49320000,41.72530000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Joseph School",'West_Warwick=' + West_Warwick.length);
Warwick[Warwick.length] = createMarker(new GPoint(-71.39160100,41.71264500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Kevin School",'Warwick=' + Warwick.length);
Pawtucket[Pawtucket.length] = createMarker(new GPoint(-71.38801800,41.87097600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Mary School",'Pawtucket=' + Pawtucket.length);
Providence[Providence.length] = createMarker(new GPoint(-71.41944300,41.83263400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Patrick School",'Providence=' + Providence.length);
Cranston[Cranston.length] = createMarker(new GPoint(-71.40004700,41.77686500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Paul School",'Cranston=' + Cranston.length);
Greenville[Greenville.length] = createMarker(new GPoint(-71.55525000,41.87262900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Philip School",'Greenville=' + Greenville.length);
Portsmouth[Portsmouth.length] = createMarker(new GPoint(-71.27393100,41.60020500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Philomena School",'Portsmouth=' + Portsmouth.length);
Providence[Providence.length] = createMarker(new GPoint(-71.43682600,41.84094600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Pius V Elementary School",'Providence=' + Providence.length);
Pawtucket[Pawtucket.length] = createMarker(new GPoint(-71.35601500,41.86715100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Teresa School",'Pawtucket=' + Pawtucket.length);
Pawtucket[Pawtucket.length] = createMarker(new GPoint(-71.40197700,41.87628500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Woodlawn Catholic Regional",'Pawtucket=' + Pawtucket.length);
maxLng = -71.27272600;
maxLat = 42.01209500;
minLng = -71.82871700;
minLat = 41.37326300;
reCenterMap();
} // 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//////' + showArray);
map.removeOverlays(Barrington);
map.removeOverlays(Bristol);
map.removeOverlays(Central_Falls);
map.removeOverlays(Coventry);
map.removeOverlays(Cranston);
map.removeOverlays(Cumberland);
map.removeOverlays(East_Greenwich);
map.removeOverlays(East_Providence);
map.removeOverlays(Greenville);
map.removeOverlays(Johnston);
map.removeOverlays(Middletown);
map.removeOverlays(Newport);
map.removeOverlays(Pascoag);
map.removeOverlays(Pawtucket);
map.removeOverlays(Portsmouth);
map.removeOverlays(Providence);
map.removeOverlays(Riverside);
map.removeOverlays(W_Warwick);
map.removeOverlays(Warren);
map.removeOverlays(Warwick);
map.removeOverlays(West_Warwick);
map.removeOverlays(Westerly);
map.removeOverlays(Woonsocket);
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(Middletown);map.removeOverlays(Barrington);
map.removeOverlays(Bristol);
map.removeOverlays(Central_Falls);
map.removeOverlays(Coventry);
map.removeOverlays(Cranston);
map.removeOverlays(Cumberland);
map.removeOverlays(East_Greenwich);
map.removeOverlays(East_Providence);
map.removeOverlays(Greenville);
map.removeOverlays(Johnston);
map.removeOverlays(Middletown);
map.removeOverlays(Newport);
map.removeOverlays(Pascoag);
map.removeOverlays(Pawtucket);
map.removeOverlays(Portsmouth);
map.removeOverlays(Providence);
map.removeOverlays(Riverside);
map.removeOverlays(W_Warwick);
map.removeOverlays(Warren);
map.removeOverlays(Warwick);
map.removeOverlays(West_Warwick);
map.removeOverlays(Westerly);
map.removeOverlays(Woonsocket);
map.addOverlays(Barrington);
centerByArray(Barrington, false, false);
cntMarker += Barrington.length;
map.addOverlays(Bristol);
centerByArray(Bristol, false, false);
cntMarker += Bristol.length;
map.addOverlays(Central_Falls);
centerByArray(Central_Falls, false, false);
cntMarker += Central_Falls.length;
map.addOverlays(Coventry);
centerByArray(Coventry, false, false);
cntMarker += Coventry.length;
map.addOverlays(Cranston);
centerByArray(Cranston, false, false);
cntMarker += Cranston.length;
map.addOverlays(Cumberland);
centerByArray(Cumberland, false, false);
cntMarker += Cumberland.length;
map.addOverlays(East_Greenwich);
centerByArray(East_Greenwich, false, false);
cntMarker += East_Greenwich.length;
map.addOverlays(East_Providence);
centerByArray(East_Providence, false, false);
cntMarker += East_Providence.length;
map.addOverlays(Greenville);
centerByArray(Greenville, false, false);
cntMarker += Greenville.length;
map.addOverlays(Johnston);
centerByArray(Johnston, false, false);
cntMarker += Johnston.length;
map.addOverlays(Middletown);
centerByArray(Middletown, false, false);
cntMarker += Middletown.length;
map.addOverlays(Newport);
centerByArray(Newport, false, false);
cntMarker += Newport.length;
map.addOverlays(Pascoag);
centerByArray(Pascoag, false, false);
cntMarker += Pascoag.length;
map.addOverlays(Pawtucket);
centerByArray(Pawtucket, false, false);
cntMarker += Pawtucket.length;
map.addOverlays(Portsmouth);
centerByArray(Portsmouth, false, false);
cntMarker += Portsmouth.length;
map.addOverlays(Providence);
centerByArray(Providence, false, false);
cntMarker += Providence.length;
map.addOverlays(Riverside);
centerByArray(Riverside, false, false);
cntMarker += Riverside.length;
map.addOverlays(W_Warwick);
centerByArray(W_Warwick, false, false);
cntMarker += W_Warwick.length;
map.addOverlays(Warren);
centerByArray(Warren, false, false);
cntMarker += Warren.length;
map.addOverlays(Warwick);
centerByArray(Warwick, false, false);
cntMarker += Warwick.length;
map.addOverlays(West_Warwick);
centerByArray(West_Warwick, false, false);
cntMarker += West_Warwick.length;
map.addOverlays(Westerly);
centerByArray(Westerly, false, false);
cntMarker += Westerly.length;
map.addOverlays(Woonsocket);
centerByArray(Woonsocket, false, false);
cntMarker += Woonsocket.length;
centerByArray(Middletown,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///25400,25356,25328,25389,25348,25278,25341,25387,25349,25378,25405,25301,25346,25294,25391,25393,25396,25336,35707,25361,25388,25397,25401,25271,25383,25305,25377,25386,25392,25403,25429,25363,25279,25280,25317,25375,25390,25404,25374,25395,25398,25389,25376,25381,25379,25362,25402,25385,25382,25399,25384,25433,25342,/all');
//window.open('/map.php?type=2&schools=25400,25356,25328,25389,25348,25278,25341,25387,25349,25378,25405,25301,25346,25294,25391,25393,25396,25336,35707,25361,25388,25397,25401,25271,25383,25305,25377,25386,25392,25403,25429,25363,25279,25280,25317,25375,25390,25404,25374,25395,25398,25389,25376,25381,25379,25362,25402,25385,25382,25399,25384,25433,25342,&school_level=&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;
}