function addMarkers(){
mySelect = document.getElementById('selection');
Fitchburg = [];Leicester = [];Worcester = [];Mendon = [];South_Lancaster = [];Baldwinville = [];Ashburnham = [];Rutland = [];Hardwick = [];Milford = [];Southborough = [];Lancaster = [];Still_River = [];Whitinsville = [];Gardner = [];Millbury = [];Athol = [];Shrewsbury = [];Devens = [];Southbridge = [];Barre = [];Lunenburg = [];Winchendon = [];mySelect.options[mySelect.options.length] = new Option("Ashburnham schools",'all=Ashburnham');
mySelect.options[mySelect.options.length] = new Option("Athol schools",'all=Athol');
mySelect.options[mySelect.options.length] = new Option("Baldwinville schools",'all=Baldwinville');
mySelect.options[mySelect.options.length] = new Option("Barre schools",'all=Barre');
mySelect.options[mySelect.options.length] = new Option("Devens schools",'all=Devens');
mySelect.options[mySelect.options.length] = new Option("Fitchburg schools",'all=Fitchburg');
mySelect.options[mySelect.options.length] = new Option("Gardner schools",'all=Gardner');
mySelect.options[mySelect.options.length] = new Option("Hardwick schools",'all=Hardwick');
mySelect.options[mySelect.options.length] = new Option("Lancaster schools",'all=Lancaster');
mySelect.options[mySelect.options.length] = new Option("Leicester schools",'all=Leicester');
mySelect.options[mySelect.options.length] = new Option("Lunenburg schools",'all=Lunenburg');
mySelect.options[mySelect.options.length] = new Option("Mendon schools",'all=Mendon');
mySelect.options[mySelect.options.length] = new Option("Milford schools",'all=Milford');
mySelect.options[mySelect.options.length] = new Option("Millbury schools",'all=Millbury');
mySelect.options[mySelect.options.length] = new Option("Rutland schools",'all=Rutland');
mySelect.options[mySelect.options.length] = new Option("Shrewsbury schools",'all=Shrewsbury');
mySelect.options[mySelect.options.length] = new Option("South Lancaster schools",'all=South_Lancaster');
mySelect.options[mySelect.options.length] = new Option("Southborough schools",'all=Southborough');
mySelect.options[mySelect.options.length] = new Option("Southbridge schools",'all=Southbridge');
mySelect.options[mySelect.options.length] = new Option("Still River schools",'all=Still_River');
mySelect.options[mySelect.options.length] = new Option("Whitinsville schools",'all=Whitinsville');
mySelect.options[mySelect.options.length] = new Option("Winchendon schools",'all=Winchendon');
mySelect.options[mySelect.options.length] = new Option("Worcester schools",'all=Worcester');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Fitchburg[Fitchburg.length] = createMarker(new GPoint(-71.80739900,42.59178400),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Applewild School",'Fitchburg=' + Fitchburg.length);
Leicester[Leicester.length] = createMarker(new GPoint(-71.88896000,42.25963800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Archway, Inc.",'Leicester=' + Leicester.length);
Worcester[Worcester.length] = createMarker(new GPoint(-71.81533800,42.30444700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bancroft School",'Worcester=' + Worcester.length);
Mendon[Mendon.length] = createMarker(new GPoint(-71.50339500,42.10005200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bethany Christian Academy",'Mendon=' + Mendon.length);
South_Lancaster[South_Lancaster.length] = createMarker(new GPoint(-71.68926800,42.44345200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Browning Elementary & South Lancaster Academy",'South_Lancaster=' + South_Lancaster.length);
Baldwinville[Baldwinville.length] = createMarker(new GPoint(-72.07468800,42.60744900),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Cottage Hill Academy",'Baldwinville=' + Baldwinville.length);
Ashburnham[Ashburnham.length] = createMarker(new GPoint(-71.90835400,42.63580000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cushing Academy",'Ashburnham=' + Ashburnham.length);
Rutland[Rutland.length] = createMarker(new GPoint(-71.95820000,42.37460000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Devereux School",'Rutland=' + Rutland.length);
Hardwick[Hardwick.length] = createMarker(new GPoint(-72.19140000,42.37090000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Eagle Hill School",'Hardwick=' + Hardwick.length);
Milford[Milford.length] = createMarker(new GPoint(-71.49525200,42.15812400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Evergreen Center",'Milford=' + Milford.length);
Southborough[Southborough.length] = createMarker(new GPoint(-71.53288800,42.30531500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Fay School",'Southborough=' + Southborough.length);
Worcester[Worcester.length] = createMarker(new GPoint(-71.77086700,42.29509900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("First Assembly Christian Academy",'Worcester=' + Worcester.length);
Lancaster[Lancaster.length] = createMarker(new GPoint(-71.67380400,42.46186700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Franklin Perkins School",'Lancaster=' + Lancaster.length);
Worcester[Worcester.length] = createMarker(new GPoint(-71.80142700,42.26560300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("G Stanley Hall School",'Worcester=' + Worcester.length);
Worcester[Worcester.length] = createMarker(new GPoint(-71.78363600,42.24289000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Holy Name Central Catholic Jr/sr High School",'Worcester=' + Worcester.length);
Still_River[Still_River.length] = createMarker(new GPoint(-71.61300000,42.48590000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Immaculate Heart Of Mary",'Still_River=' + Still_River.length);
Whitinsville[Whitinsville.length] = createMarker(new GPoint(-71.66856300,42.11564400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Integritas Academy",'Whitinsville=' + Whitinsville.length);
Worcester[Worcester.length] = createMarker(new GPoint(-71.77320000,42.25450000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Kathleen Burns Preparatory School",'Worcester=' + Worcester.length);
Gardner[Gardner.length] = createMarker(new GPoint(-71.98517400,42.58356300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Master's Christian Academy",'Gardner=' + Gardner.length);
Millbury[Millbury.length] = createMarker(new GPoint(-71.76408500,42.18939400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mcgrath Ed Center",'Millbury=' + Millbury.length);
Mendon[Mendon.length] = createMarker(new GPoint(-71.49981800,42.09192800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mendon Mennonite School",'Mendon=' + Mendon.length);
Worcester[Worcester.length] = createMarker(new GPoint(-71.82577000,42.30206300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mercy Centre",'Worcester=' + Worcester.length);
Athol[Athol.length] = createMarker(new GPoint(-72.24270700,42.59035700),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Miller's River Academy",'Athol=' + Athol.length);
Southborough[Southborough.length] = createMarker(new GPoint(-71.49922300,42.29600300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The New England Center For Children",'Southborough=' + Southborough.length);
Lancaster[Lancaster.length] = createMarker(new GPoint(-71.67700700,42.51806700),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("New River Academy",'Lancaster=' + Lancaster.length);
Worcester[Worcester.length] = createMarker(new GPoint(-71.82602400,42.28521400),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Notre Dame Academy",'Worcester=' + Worcester.length);
Fitchburg[Fitchburg.length] = createMarker(new GPoint(-71.79934200,42.57618900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Notre Dame Preparatory School",'Fitchburg=' + Fitchburg.length);
Lancaster[Lancaster.length] = createMarker(new GPoint(-71.68560000,42.47320000),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Rfk Lancaster School",'Lancaster=' + Lancaster.length);
Fitchburg[Fitchburg.length] = createMarker(new GPoint(-71.78448700,42.57707800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Bernard Central High School",'Fitchburg=' + Fitchburg.length);
Shrewsbury[Shrewsbury.length] = createMarker(new GPoint(-71.72938800,42.29323900),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("St. John's High School",'Shrewsbury=' + Shrewsbury.length);
Southborough[Southborough.length] = createMarker(new GPoint(-71.53089200,42.30958100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Mark's School",'Southborough=' + Southborough.length);
Worcester[Worcester.length] = createMarker(new GPoint(-71.79674900,42.25116300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Mary S Jr/sr High School",'Worcester=' + Worcester.length);
Worcester[Worcester.length] = createMarker(new GPoint(-71.82243400,42.30670700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Peter Marian Central Cathol",'Worcester=' + Worcester.length);
Devens[Devens.length] = createMarker(new GPoint(-71.62375600,42.53964300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Seven Hills Academy",'Devens=' + Devens.length);
South_Lancaster[South_Lancaster.length] = createMarker(new GPoint(-71.68926800,42.44345200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("South Lancaster Academy & Browning Elementary School",'South_Lancaster=' + South_Lancaster.length);
Southbridge[Southbridge.length] = createMarker(new GPoint(-72.00100000,42.09057500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Southbridge Christian Academy",'Southbridge=' + Southbridge.length);
Barre[Barre.length] = createMarker(new GPoint(-72.10811700,42.42318900),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Stetson School Inc.",'Barre=' + Barre.length);
Lancaster[Lancaster.length] = createMarker(new GPoint(-71.68773700,42.46432600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Trivium School",'Lancaster=' + Lancaster.length);
Lunenburg[Lunenburg.length] = createMarker(new GPoint(-71.75268400,42.58570600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Twin City Christian School",'Lunenburg=' + Lunenburg.length);
Whitinsville[Whitinsville.length] = createMarker(new GPoint(-71.65454600,42.10618000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Whitinsville Christian School",'Whitinsville=' + Whitinsville.length);
Winchendon[Winchendon.length] = createMarker(new GPoint(-72.03667400,42.67520400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Winchendon School",'Winchendon=' + Winchendon.length);
Worcester[Worcester.length] = createMarker(new GPoint(-71.79243700,42.25264100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Worcester Academy",'Worcester=' + Worcester.length);
Worcester[Worcester.length] = createMarker(new GPoint(-71.81574700,42.24778300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Worcester Kingdom Academy",'Worcester=' + Worcester.length);
Worcester[Worcester.length] = createMarker(new GPoint(-71.82447800,42.27132800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Yeshiva Achei Tmimim Academy",'Worcester=' + Worcester.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,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/////2/' + showArray);
map.removeOverlays(Ashburnham);
map.removeOverlays(Athol);
map.removeOverlays(Baldwinville);
map.removeOverlays(Barre);
map.removeOverlays(Devens);
map.removeOverlays(Fitchburg);
map.removeOverlays(Gardner);
map.removeOverlays(Hardwick);
map.removeOverlays(Lancaster);
map.removeOverlays(Leicester);
map.removeOverlays(Lunenburg);
map.removeOverlays(Mendon);
map.removeOverlays(Milford);
map.removeOverlays(Millbury);
map.removeOverlays(Rutland);
map.removeOverlays(Shrewsbury);
map.removeOverlays(South_Lancaster);
map.removeOverlays(Southborough);
map.removeOverlays(Southbridge);
map.removeOverlays(Still_River);
map.removeOverlays(Whitinsville);
map.removeOverlays(Winchendon);
map.removeOverlays(Worcester);
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(Fitchburg);map.removeOverlays(Ashburnham);
map.removeOverlays(Athol);
map.removeOverlays(Baldwinville);
map.removeOverlays(Barre);
map.removeOverlays(Devens);
map.removeOverlays(Fitchburg);
map.removeOverlays(Gardner);
map.removeOverlays(Hardwick);
map.removeOverlays(Lancaster);
map.removeOverlays(Leicester);
map.removeOverlays(Lunenburg);
map.removeOverlays(Mendon);
map.removeOverlays(Milford);
map.removeOverlays(Millbury);
map.removeOverlays(Rutland);
map.removeOverlays(Shrewsbury);
map.removeOverlays(South_Lancaster);
map.removeOverlays(Southborough);
map.removeOverlays(Southbridge);
map.removeOverlays(Still_River);
map.removeOverlays(Whitinsville);
map.removeOverlays(Winchendon);
map.removeOverlays(Worcester);
map.addOverlays(Ashburnham);
centerByArray(Ashburnham, false, false);
cntMarker += Ashburnham.length;
map.addOverlays(Athol);
centerByArray(Athol, false, false);
cntMarker += Athol.length;
map.addOverlays(Baldwinville);
centerByArray(Baldwinville, false, false);
cntMarker += Baldwinville.length;
map.addOverlays(Barre);
centerByArray(Barre, false, false);
cntMarker += Barre.length;
map.addOverlays(Devens);
centerByArray(Devens, false, false);
cntMarker += Devens.length;
map.addOverlays(Fitchburg);
centerByArray(Fitchburg, false, false);
cntMarker += Fitchburg.length;
map.addOverlays(Gardner);
centerByArray(Gardner, false, false);
cntMarker += Gardner.length;
map.addOverlays(Hardwick);
centerByArray(Hardwick, false, false);
cntMarker += Hardwick.length;
map.addOverlays(Lancaster);
centerByArray(Lancaster, false, false);
cntMarker += Lancaster.length;
map.addOverlays(Leicester);
centerByArray(Leicester, false, false);
cntMarker += Leicester.length;
map.addOverlays(Lunenburg);
centerByArray(Lunenburg, false, false);
cntMarker += Lunenburg.length;
map.addOverlays(Mendon);
centerByArray(Mendon, false, false);
cntMarker += Mendon.length;
map.addOverlays(Milford);
centerByArray(Milford, false, false);
cntMarker += Milford.length;
map.addOverlays(Millbury);
centerByArray(Millbury, false, false);
cntMarker += Millbury.length;
map.addOverlays(Rutland);
centerByArray(Rutland, false, false);
cntMarker += Rutland.length;
map.addOverlays(Shrewsbury);
centerByArray(Shrewsbury, false, false);
cntMarker += Shrewsbury.length;
map.addOverlays(South_Lancaster);
centerByArray(South_Lancaster, false, false);
cntMarker += South_Lancaster.length;
map.addOverlays(Southborough);
centerByArray(Southborough, false, false);
cntMarker += Southborough.length;
map.addOverlays(Southbridge);
centerByArray(Southbridge, false, false);
cntMarker += Southbridge.length;
map.addOverlays(Still_River);
centerByArray(Still_River, false, false);
cntMarker += Still_River.length;
map.addOverlays(Whitinsville);
centerByArray(Whitinsville, false, false);
cntMarker += Whitinsville.length;
map.addOverlays(Winchendon);
centerByArray(Winchendon, false, false);
cntMarker += Winchendon.length;
map.addOverlays(Worcester);
centerByArray(Worcester, false, false);
cntMarker += Worcester.length;
centerByArray(Fitchburg,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');
//window.open('/map.php?type=1&schools=&school_level=2&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;
}