function addMarkers()
{
mySelect = document.getElementById('selection');
Bath = [];Biddeford = [];Augusta = [];Caribou = [];Machias = [];Brunswick = [];Ellsworth = [];Farmington = [];Naples = [];Lewiston = [];Rockland = [];Waterville = [];Lincoln = [];Norway = [];Portland = [];Presque_Isle = [];Houlton = [];Sanford = [];Mexico = [];Skowhegan = [];Calais = [];Frenchville = [];Dexter = [];Bangor = [];Van_Buren = [];Waldo = [];Westbrook = [];mySelect.options[mySelect.options.length] = new Option("Augusta vocational schools",'all=Augusta');
mySelect.options[mySelect.options.length] = new Option("Bangor vocational schools",'all=Bangor');
mySelect.options[mySelect.options.length] = new Option("Bath vocational schools",'all=Bath');
mySelect.options[mySelect.options.length] = new Option("Biddeford vocational schools",'all=Biddeford');
mySelect.options[mySelect.options.length] = new Option("Brunswick vocational schools",'all=Brunswick');
mySelect.options[mySelect.options.length] = new Option("Calais vocational schools",'all=Calais');
mySelect.options[mySelect.options.length] = new Option("Caribou vocational schools",'all=Caribou');
mySelect.options[mySelect.options.length] = new Option("Dexter vocational schools",'all=Dexter');
mySelect.options[mySelect.options.length] = new Option("Ellsworth vocational schools",'all=Ellsworth');
mySelect.options[mySelect.options.length] = new Option("Farmington vocational schools",'all=Farmington');
mySelect.options[mySelect.options.length] = new Option("Frenchville vocational schools",'all=Frenchville');
mySelect.options[mySelect.options.length] = new Option("Houlton vocational schools",'all=Houlton');
mySelect.options[mySelect.options.length] = new Option("Lewiston vocational schools",'all=Lewiston');
mySelect.options[mySelect.options.length] = new Option("Lincoln vocational schools",'all=Lincoln');
mySelect.options[mySelect.options.length] = new Option("Machias vocational schools",'all=Machias');
mySelect.options[mySelect.options.length] = new Option("Mexico vocational schools",'all=Mexico');
mySelect.options[mySelect.options.length] = new Option("Naples vocational schools",'all=Naples');
mySelect.options[mySelect.options.length] = new Option("Norway vocational schools",'all=Norway');
mySelect.options[mySelect.options.length] = new Option("Portland vocational schools",'all=Portland');
mySelect.options[mySelect.options.length] = new Option("Presque Isle vocational schools",'all=Presque_Isle');
mySelect.options[mySelect.options.length] = new Option("Rockland vocational schools",'all=Rockland');
mySelect.options[mySelect.options.length] = new Option("Sanford vocational schools",'all=Sanford');
mySelect.options[mySelect.options.length] = new Option("Skowhegan vocational schools",'all=Skowhegan');
mySelect.options[mySelect.options.length] = new Option("Van Buren vocational schools",'all=Van_Buren');
mySelect.options[mySelect.options.length] = new Option("Waldo vocational schools",'all=Waldo');
mySelect.options[mySelect.options.length] = new Option("Waterville vocational schools",'all=Waterville');
mySelect.options[mySelect.options.length] = new Option("Westbrook vocational schools",'all=Westbrook');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Bath[Bath.length] = createMarker(new GPoint(-69.81974030,43.91338730),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bath Regional Technology Center",'Bath=' + Bath.length);
Biddeford[Biddeford.length] = createMarker(new GPoint(-70.46982574,43.49680710),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Biddeford Regional Center Of Technical",'Biddeford=' + Biddeford.length);
Augusta[Augusta.length] = createMarker(new GPoint(-69.77976227,44.31053162),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Capital Area Technology Center",'Augusta=' + Augusta.length);
Caribou[Caribou.length] = createMarker(new GPoint(-68.03065491,46.86336517),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Caribou Regional Applied Technical Center",'Caribou=' + Caribou.length);
Machias[Machias.length] = createMarker(new GPoint(-67.46330261,44.70579910),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Coastal Wash City Institutional Of Technical High School",'Machias=' + Machias.length);
Brunswick[Brunswick.length] = createMarker(new GPoint(-69.99186707,43.90766907),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("E Cumblnd-sag City Tech-reg 10 High School",'Brunswick=' + Brunswick.length);
Ellsworth[Ellsworth.length] = createMarker(new GPoint(-68.45839691,44.57621765),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Hancock County Technical Center",'Ellsworth=' + Ellsworth.length);
Farmington[Farmington.length] = createMarker(new GPoint(-70.13012695,44.63761902),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Ken Foster Regional Applied Technical Center",'Farmington=' + Farmington.length);
Naples[Naples.length] = createMarker(new GPoint(-70.65819550,43.99736786),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lake Region Technology Center",'Naples=' + Naples.length);
Lewiston[Lewiston.length] = createMarker(new GPoint(-70.19943237,44.09474182),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lewiston Regional Technology Center",'Lewiston=' + Lewiston.length);
Rockland[Rockland.length] = createMarker(new GPoint(-69.10990143,44.09000015),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mid-coast School Of Tech-region 8",'Rockland=' + Rockland.length);
Waterville[Waterville.length] = createMarker(new GPoint(-69.64225769,44.55096054),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mid-maine Technical Center",'Waterville=' + Waterville.length);
Lincoln[Lincoln.length] = createMarker(new GPoint(-68.50738525,45.36313629),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("No Penobscot Tech-region 3 High School",'Lincoln=' + Lincoln.length);
Norway[Norway.length] = createMarker(new GPoint(-70.57530212,44.22019958),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Oxford Hills Technical - Region 11 High School",'Norway=' + Norway.length);
Portland[Portland.length] = createMarker(new GPoint(-70.29191589,43.69521713),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Portland Arts & Technology High School",'Portland=' + Portland.length);
Presque_Isle[Presque_Isle.length] = createMarker(new GPoint(-68.00600433,46.68453598),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Presque Isle Regional Technical Center",'Presque_Isle=' + Presque_Isle.length);
Houlton[Houlton.length] = createMarker(new GPoint(-67.82707977,46.12707901),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Region Two School Of Applied Technical",'Houlton=' + Houlton.length);
Sanford[Sanford.length] = createMarker(new GPoint(-70.78659058,43.45346069),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sanford Regional Vocational Center",'Sanford=' + Sanford.length);
Mexico[Mexico.length] = createMarker(new GPoint(-70.50602722,44.53468704),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("School Of Applied Tech-region 9",'Mexico=' + Mexico.length);
Skowhegan[Skowhegan.length] = createMarker(new GPoint(-69.72988129,44.74951935),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Skowhegan Regional Technical Center",'Skowhegan=' + Skowhegan.length);
Calais[Calais.length] = createMarker(new GPoint(-67.26560211,45.17010117),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Croix Regional Technology Center",'Calais=' + Calais.length);
Frenchville[Frenchville.length] = createMarker(new GPoint(-68.39080048,47.28590012),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St John Valley Technology Center",'Frenchville=' + Frenchville.length);
Dexter[Dexter.length] = createMarker(new GPoint(-69.29780579,45.02507401),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Tri-county Regional Technical Center",'Dexter=' + Dexter.length);
Bangor[Bangor.length] = createMarker(new GPoint(-68.73918152,44.82003403),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("United Technologies Ctr-region 4 High School",'Bangor=' + Bangor.length);
Van_Buren[Van_Buren.length] = createMarker(new GPoint(-67.94058228,47.16141510),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Van Buren Regional Technology Center",'Van_Buren=' + Van_Buren.length);
Waldo[Waldo.length] = createMarker(new GPoint(-69.06112671,44.44498444),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Waldo County Technical Ctr-region 7 High School",'Waldo=' + Waldo.length);
Westbrook[Westbrook.length] = createMarker(new GPoint(-70.35586548,43.67455673),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Westbrook Regional Technology Center",'Westbrook=' + Westbrook.length);
maxLng = -67.26560211;
maxLat = 47.28590012;
minLng = -70.78659058;
minLat = 43.45346069;
reCenterMap();
map.removeOverlays(Augusta);
map.removeOverlays(Bangor);
map.removeOverlays(Bath);
map.removeOverlays(Biddeford);
map.removeOverlays(Brunswick);
map.removeOverlays(Calais);
map.removeOverlays(Caribou);
map.removeOverlays(Dexter);
map.removeOverlays(Ellsworth);
map.removeOverlays(Farmington);
map.removeOverlays(Frenchville);
map.removeOverlays(Houlton);
map.removeOverlays(Lewiston);
map.removeOverlays(Lincoln);
map.removeOverlays(Machias);
map.removeOverlays(Mexico);
map.removeOverlays(Naples);
map.removeOverlays(Norway);
map.removeOverlays(Portland);
map.removeOverlays(Presque_Isle);
map.removeOverlays(Rockland);
map.removeOverlays(Sanford);
map.removeOverlays(Skowhegan);
map.removeOverlays(Van_Buren);
map.removeOverlays(Waldo);
map.removeOverlays(Waterville);
map.removeOverlays(Westbrook);
setTimeout(function(){map.addOverlays(Augusta)},1000);
setTimeout(function(){map.addOverlays(Bangor)},1000);
setTimeout(function(){map.addOverlays(Bath)},1000);
setTimeout(function(){map.addOverlays(Biddeford)},1000);
setTimeout(function(){map.addOverlays(Brunswick)},1000);
setTimeout(function(){map.addOverlays(Calais)},1000);
setTimeout(function(){map.addOverlays(Caribou)},1000);
setTimeout(function(){map.addOverlays(Dexter)},1000);
setTimeout(function(){map.addOverlays(Ellsworth)},1000);
setTimeout(function(){map.addOverlays(Farmington)},1000);
setTimeout(function(){map.addOverlays(Frenchville)},1000);
setTimeout(function(){map.addOverlays(Houlton)},1000);
setTimeout(function(){map.addOverlays(Lewiston)},1000);
setTimeout(function(){map.addOverlays(Lincoln)},1000);
setTimeout(function(){map.addOverlays(Machias)},1000);
setTimeout(function(){map.addOverlays(Mexico)},1000);
setTimeout(function(){map.addOverlays(Naples)},1000);
setTimeout(function(){map.addOverlays(Norway)},1000);
setTimeout(function(){map.addOverlays(Portland)},1000);
setTimeout(function(){map.addOverlays(Presque_Isle)},1000);
setTimeout(function(){map.addOverlays(Rockland)},1000);
setTimeout(function(){map.addOverlays(Sanford)},1000);
setTimeout(function(){map.addOverlays(Skowhegan)},1000);
setTimeout(function(){map.addOverlays(Van_Buren)},1000);
setTimeout(function(){map.addOverlays(Waldo)},1000);
setTimeout(function(){map.addOverlays(Waterville)},1000);
setTimeout(function(){map.addOverlays(Westbrook)},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(Augusta);
map.removeOverlays(Bangor);
map.removeOverlays(Bath);
map.removeOverlays(Biddeford);
map.removeOverlays(Brunswick);
map.removeOverlays(Calais);
map.removeOverlays(Caribou);
map.removeOverlays(Dexter);
map.removeOverlays(Ellsworth);
map.removeOverlays(Farmington);
map.removeOverlays(Frenchville);
map.removeOverlays(Houlton);
map.removeOverlays(Lewiston);
map.removeOverlays(Lincoln);
map.removeOverlays(Machias);
map.removeOverlays(Mexico);
map.removeOverlays(Naples);
map.removeOverlays(Norway);
map.removeOverlays(Portland);
map.removeOverlays(Presque_Isle);
map.removeOverlays(Rockland);
map.removeOverlays(Sanford);
map.removeOverlays(Skowhegan);
map.removeOverlays(Van_Buren);
map.removeOverlays(Waldo);
map.removeOverlays(Waterville);
map.removeOverlays(Westbrook);
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(Bath);map.removeOverlays(Augusta);
map.removeOverlays(Bangor);
map.removeOverlays(Bath);
map.removeOverlays(Biddeford);
map.removeOverlays(Brunswick);
map.removeOverlays(Calais);
map.removeOverlays(Caribou);
map.removeOverlays(Dexter);
map.removeOverlays(Ellsworth);
map.removeOverlays(Farmington);
map.removeOverlays(Frenchville);
map.removeOverlays(Houlton);
map.removeOverlays(Lewiston);
map.removeOverlays(Lincoln);
map.removeOverlays(Machias);
map.removeOverlays(Mexico);
map.removeOverlays(Naples);
map.removeOverlays(Norway);
map.removeOverlays(Portland);
map.removeOverlays(Presque_Isle);
map.removeOverlays(Rockland);
map.removeOverlays(Sanford);
map.removeOverlays(Skowhegan);
map.removeOverlays(Van_Buren);
map.removeOverlays(Waldo);
map.removeOverlays(Waterville);
map.removeOverlays(Westbrook);
map.addOverlays(Augusta);
centerByArray(Augusta, false, false);
cntMarker += Augusta.length;
map.addOverlays(Bangor);
centerByArray(Bangor, false, false);
cntMarker += Bangor.length;
map.addOverlays(Bath);
centerByArray(Bath, false, false);
cntMarker += Bath.length;
map.addOverlays(Biddeford);
centerByArray(Biddeford, false, false);
cntMarker += Biddeford.length;
map.addOverlays(Brunswick);
centerByArray(Brunswick, false, false);
cntMarker += Brunswick.length;
map.addOverlays(Calais);
centerByArray(Calais, false, false);
cntMarker += Calais.length;
map.addOverlays(Caribou);
centerByArray(Caribou, false, false);
cntMarker += Caribou.length;
map.addOverlays(Dexter);
centerByArray(Dexter, false, false);
cntMarker += Dexter.length;
map.addOverlays(Ellsworth);
centerByArray(Ellsworth, false, false);
cntMarker += Ellsworth.length;
map.addOverlays(Farmington);
centerByArray(Farmington, false, false);
cntMarker += Farmington.length;
map.addOverlays(Frenchville);
centerByArray(Frenchville, false, false);
cntMarker += Frenchville.length;
map.addOverlays(Houlton);
centerByArray(Houlton, false, false);
cntMarker += Houlton.length;
map.addOverlays(Lewiston);
centerByArray(Lewiston, false, false);
cntMarker += Lewiston.length;
map.addOverlays(Lincoln);
centerByArray(Lincoln, false, false);
cntMarker += Lincoln.length;
map.addOverlays(Machias);
centerByArray(Machias, false, false);
cntMarker += Machias.length;
map.addOverlays(Mexico);
centerByArray(Mexico, false, false);
cntMarker += Mexico.length;
map.addOverlays(Naples);
centerByArray(Naples, false, false);
cntMarker += Naples.length;
map.addOverlays(Norway);
centerByArray(Norway, false, false);
cntMarker += Norway.length;
map.addOverlays(Portland);
centerByArray(Portland, false, false);
cntMarker += Portland.length;
map.addOverlays(Presque_Isle);
centerByArray(Presque_Isle, false, false);
cntMarker += Presque_Isle.length;
map.addOverlays(Rockland);
centerByArray(Rockland, false, false);
cntMarker += Rockland.length;
map.addOverlays(Sanford);
centerByArray(Sanford, false, false);
cntMarker += Sanford.length;
map.addOverlays(Skowhegan);
centerByArray(Skowhegan, false, false);
cntMarker += Skowhegan.length;
map.addOverlays(Van_Buren);
centerByArray(Van_Buren, false, false);
cntMarker += Van_Buren.length;
map.addOverlays(Waldo);
centerByArray(Waldo, false, false);
cntMarker += Waldo.length;
map.addOverlays(Waterville);
centerByArray(Waterville, false, false);
cntMarker += Waterville.length;
map.addOverlays(Westbrook);
centerByArray(Westbrook, false, false);
cntMarker += Westbrook.length;
centerByArray(Bath,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');
}
}