function addMarkers(){
mySelect = document.getElementById('selection');
Hampstead = [];Auburn = [];Bedford = [];Rumney = [];Hampton = [];Littleton = [];Rye = [];Milford = [];Stratham = [];Amherst = [];Derry = [];Pembroke = [];Keene = [];North_Conway = [];Claremont = [];Bow = [];Salem = [];Hooksett = [];Hanover = [];Concord = [];West_Lebanon = [];Sanbornton = [];Exeter = [];Plymouth = [];Intervale = [];Epsom = [];Londonderry = [];Lancaster = [];mySelect.options[mySelect.options.length] = new Option("Amherst schools",'all=Amherst');
mySelect.options[mySelect.options.length] = new Option("Auburn schools",'all=Auburn');
mySelect.options[mySelect.options.length] = new Option("Bedford schools",'all=Bedford');
mySelect.options[mySelect.options.length] = new Option("Bow schools",'all=Bow');
mySelect.options[mySelect.options.length] = new Option("Claremont schools",'all=Claremont');
mySelect.options[mySelect.options.length] = new Option("Concord schools",'all=Concord');
mySelect.options[mySelect.options.length] = new Option("Derry schools",'all=Derry');
mySelect.options[mySelect.options.length] = new Option("Epsom schools",'all=Epsom');
mySelect.options[mySelect.options.length] = new Option("Exeter schools",'all=Exeter');
mySelect.options[mySelect.options.length] = new Option("Hampstead schools",'all=Hampstead');
mySelect.options[mySelect.options.length] = new Option("Hampton schools",'all=Hampton');
mySelect.options[mySelect.options.length] = new Option("Hanover schools",'all=Hanover');
mySelect.options[mySelect.options.length] = new Option("Hooksett schools",'all=Hooksett');
mySelect.options[mySelect.options.length] = new Option("Intervale schools",'all=Intervale');
mySelect.options[mySelect.options.length] = new Option("Keene schools",'all=Keene');
mySelect.options[mySelect.options.length] = new Option("Lancaster schools",'all=Lancaster');
mySelect.options[mySelect.options.length] = new Option("Littleton schools",'all=Littleton');
mySelect.options[mySelect.options.length] = new Option("Londonderry schools",'all=Londonderry');
mySelect.options[mySelect.options.length] = new Option("Milford schools",'all=Milford');
mySelect.options[mySelect.options.length] = new Option("North Conway schools",'all=North_Conway');
mySelect.options[mySelect.options.length] = new Option("Pembroke schools",'all=Pembroke');
mySelect.options[mySelect.options.length] = new Option("Plymouth schools",'all=Plymouth');
mySelect.options[mySelect.options.length] = new Option("Rumney schools",'all=Rumney');
mySelect.options[mySelect.options.length] = new Option("Rye schools",'all=Rye');
mySelect.options[mySelect.options.length] = new Option("Salem schools",'all=Salem');
mySelect.options[mySelect.options.length] = new Option("Sanbornton schools",'all=Sanbornton');
mySelect.options[mySelect.options.length] = new Option("Stratham schools",'all=Stratham');
mySelect.options[mySelect.options.length] = new Option("West Lebanon schools",'all=West_Lebanon');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Hampstead[Hampstead.length] = createMarker(new GPoint(-71.15925500,42.87055000),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("All Our Childrens House A Montessori School",'Hampstead=' + Hampstead.length);
Auburn[Auburn.length] = createMarker(new GPoint(-71.37519000,43.02007000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Auburn Children's House, A Montessori School",'Auburn=' + Auburn.length);
Bedford[Bedford.length] = createMarker(new GPoint(-71.51684200,42.97501200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bedford Montessori School Inc.",'Bedford=' + Bedford.length);
Rumney[Rumney.length] = createMarker(new GPoint(-71.70650000,43.76030000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bodhi Tree Montessori School",'Rumney=' + Rumney.length);
Hampton[Hampton.length] = createMarker(new GPoint(-70.83647700,42.94149500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cecily Larson's Montessori School",'Hampton=' + Hampton.length);
Littleton[Littleton.length] = createMarker(new GPoint(-71.79120000,44.31330000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Children S House",'Littleton=' + Littleton.length);
Rye[Rye.length] = createMarker(new GPoint(-70.74664700,43.04434000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Childrens House Montessori School",'Rye=' + Rye.length);
Milford[Milford.length] = createMarker(new GPoint(-71.64981500,42.83755200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Colonel Shepard Montessori School",'Milford=' + Milford.length);
Stratham[Stratham.length] = createMarker(new GPoint(-70.86245600,43.02342600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cornerstone School",'Stratham=' + Stratham.length);
Amherst[Amherst.length] = createMarker(new GPoint(-71.60778500,42.82270800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Country Village Montessori School",'Amherst=' + Amherst.length);
Derry[Derry.length] = createMarker(new GPoint(-71.32234800,42.88270900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Derry Montessori School",'Derry=' + Derry.length);
Pembroke[Pembroke.length] = createMarker(new GPoint(-71.46777300,43.15766300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Green Valley School",'Pembroke=' + Pembroke.length);
Keene[Keene.length] = createMarker(new GPoint(-72.27412000,42.93225900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Keene Montessori School",'Keene=' + Keene.length);
North_Conway[North_Conway.length] = createMarker(new GPoint(-71.12370600,44.05569400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Lilliputian School",'North_Conway=' + North_Conway.length);
Claremont[Claremont.length] = createMarker(new GPoint(-72.34286600,43.38358700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Little Red School House-montessori",'Claremont=' + Claremont.length);
Bow[Bow.length] = createMarker(new GPoint(-71.53718500,43.16359000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Meeting Health Montessori",'Bow=' + Bow.length);
Salem[Salem.length] = createMarker(new GPoint(-71.25413600,42.76160400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Merrimack Vly Montessori School",'Salem=' + Salem.length);
Hooksett[Hooksett.length] = createMarker(new GPoint(-71.45031300,43.07074900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mont Blanc Academy",'Hooksett=' + Hooksett.length);
Keene[Keene.length] = createMarker(new GPoint(-72.27726100,42.93611600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mont Schoolhouse-cheshire County",'Keene=' + Keene.length);
Hanover[Hanover.length] = createMarker(new GPoint(-72.25810000,43.70980000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Montessori Children's School",'Hanover=' + Hanover.length);
Concord[Concord.length] = createMarker(new GPoint(-71.54733900,43.29005200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Montessori Childrens Center Of Concord",'Concord=' + Concord.length);
West_Lebanon[West_Lebanon.length] = createMarker(new GPoint(-72.30720000,43.64770000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Montessori Discovery School",'West_Lebanon=' + West_Lebanon.length);
Sanbornton[Sanbornton.length] = createMarker(new GPoint(-71.62479000,43.49799800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Montessori House Of Children",'Sanbornton=' + Sanbornton.length);
Exeter[Exeter.length] = createMarker(new GPoint(-70.94952500,42.98970500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Montessori School For The Arts & Sciences",'Exeter=' + Exeter.length);
Plymouth[Plymouth.length] = createMarker(new GPoint(-71.70660000,43.76040000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Montessori School Of Plymouth",'Plymouth=' + Plymouth.length);
Intervale[Intervale.length] = createMarker(new GPoint(-71.06450000,44.11550000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mountain View Montessori School",'Intervale=' + Intervale.length);
Epsom[Epsom.length] = createMarker(new GPoint(-71.36215900,43.23067200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Pathfinder Academy",'Epsom=' + Epsom.length);
Londonderry[Londonderry.length] = createMarker(new GPoint(-71.34951700,42.86774800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Southern NH Montessori Academy",'Londonderry=' + Londonderry.length);
Lancaster[Lancaster.length] = createMarker(new GPoint(-71.57000000,44.49145500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sunny Brook Montessori School",'Lancaster=' + Lancaster.length);
map.removeOverlays(Amherst);
map.removeOverlays(Auburn);
map.removeOverlays(Bedford);
map.removeOverlays(Bow);
map.removeOverlays(Claremont);
map.removeOverlays(Concord);
map.removeOverlays(Derry);
map.removeOverlays(Epsom);
map.removeOverlays(Exeter);
map.removeOverlays(Hampstead);
map.removeOverlays(Hampton);
map.removeOverlays(Hanover);
map.removeOverlays(Hooksett);
map.removeOverlays(Intervale);
map.removeOverlays(Keene);
map.removeOverlays(Lancaster);
map.removeOverlays(Littleton);
map.removeOverlays(Londonderry);
map.removeOverlays(Milford);
map.removeOverlays(North_Conway);
map.removeOverlays(Pembroke);
map.removeOverlays(Plymouth);
map.removeOverlays(Rumney);
map.removeOverlays(Rye);
map.removeOverlays(Salem);
map.removeOverlays(Sanbornton);
map.removeOverlays(Stratham);
map.removeOverlays(West_Lebanon);
setTimeout(function(){map.addOverlays(Amherst)},1000);
setTimeout(function(){map.addOverlays(Auburn)},1000);
setTimeout(function(){map.addOverlays(Bedford)},1000);
setTimeout(function(){map.addOverlays(Bow)},1000);
setTimeout(function(){map.addOverlays(Claremont)},1000);
setTimeout(function(){map.addOverlays(Concord)},1000);
setTimeout(function(){map.addOverlays(Derry)},1000);
setTimeout(function(){map.addOverlays(Epsom)},1000);
setTimeout(function(){map.addOverlays(Exeter)},1000);
setTimeout(function(){map.addOverlays(Hampstead)},1000);
setTimeout(function(){map.addOverlays(Hampton)},1000);
setTimeout(function(){map.addOverlays(Hanover)},1000);
setTimeout(function(){map.addOverlays(Hooksett)},1000);
setTimeout(function(){map.addOverlays(Intervale)},1000);
setTimeout(function(){map.addOverlays(Keene)},1000);
setTimeout(function(){map.addOverlays(Lancaster)},1000);
setTimeout(function(){map.addOverlays(Littleton)},1000);
setTimeout(function(){map.addOverlays(Londonderry)},1000);
setTimeout(function(){map.addOverlays(Milford)},1000);
setTimeout(function(){map.addOverlays(North_Conway)},1000);
setTimeout(function(){map.addOverlays(Pembroke)},1000);
setTimeout(function(){map.addOverlays(Plymouth)},1000);
setTimeout(function(){map.addOverlays(Rumney)},1000);
setTimeout(function(){map.addOverlays(Rye)},1000);
setTimeout(function(){map.addOverlays(Salem)},1000);
setTimeout(function(){map.addOverlays(Sanbornton)},1000);
setTimeout(function(){map.addOverlays(Stratham)},1000);
setTimeout(function(){map.addOverlays(West_Lebanon)},1000);
maxLng = -70.74664700;
maxLat = 44.49145500;
minLng = -72.34286600;
minLat = 42.76160400;
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(Amherst);
map.removeOverlays(Auburn);
map.removeOverlays(Bedford);
map.removeOverlays(Bow);
map.removeOverlays(Claremont);
map.removeOverlays(Concord);
map.removeOverlays(Derry);
map.removeOverlays(Epsom);
map.removeOverlays(Exeter);
map.removeOverlays(Hampstead);
map.removeOverlays(Hampton);
map.removeOverlays(Hanover);
map.removeOverlays(Hooksett);
map.removeOverlays(Intervale);
map.removeOverlays(Keene);
map.removeOverlays(Lancaster);
map.removeOverlays(Littleton);
map.removeOverlays(Londonderry);
map.removeOverlays(Milford);
map.removeOverlays(North_Conway);
map.removeOverlays(Pembroke);
map.removeOverlays(Plymouth);
map.removeOverlays(Rumney);
map.removeOverlays(Rye);
map.removeOverlays(Salem);
map.removeOverlays(Sanbornton);
map.removeOverlays(Stratham);
map.removeOverlays(West_Lebanon);
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(Hampstead);map.removeOverlays(Amherst);
map.removeOverlays(Auburn);
map.removeOverlays(Bedford);
map.removeOverlays(Bow);
map.removeOverlays(Claremont);
map.removeOverlays(Concord);
map.removeOverlays(Derry);
map.removeOverlays(Epsom);
map.removeOverlays(Exeter);
map.removeOverlays(Hampstead);
map.removeOverlays(Hampton);
map.removeOverlays(Hanover);
map.removeOverlays(Hooksett);
map.removeOverlays(Intervale);
map.removeOverlays(Keene);
map.removeOverlays(Lancaster);
map.removeOverlays(Littleton);
map.removeOverlays(Londonderry);
map.removeOverlays(Milford);
map.removeOverlays(North_Conway);
map.removeOverlays(Pembroke);
map.removeOverlays(Plymouth);
map.removeOverlays(Rumney);
map.removeOverlays(Rye);
map.removeOverlays(Salem);
map.removeOverlays(Sanbornton);
map.removeOverlays(Stratham);
map.removeOverlays(West_Lebanon);
map.addOverlays(Amherst);
centerByArray(Amherst, false, false);
cntMarker += Amherst.length;
map.addOverlays(Auburn);
centerByArray(Auburn, false, false);
cntMarker += Auburn.length;
map.addOverlays(Bedford);
centerByArray(Bedford, false, false);
cntMarker += Bedford.length;
map.addOverlays(Bow);
centerByArray(Bow, false, false);
cntMarker += Bow.length;
map.addOverlays(Claremont);
centerByArray(Claremont, false, false);
cntMarker += Claremont.length;
map.addOverlays(Concord);
centerByArray(Concord, false, false);
cntMarker += Concord.length;
map.addOverlays(Derry);
centerByArray(Derry, false, false);
cntMarker += Derry.length;
map.addOverlays(Epsom);
centerByArray(Epsom, false, false);
cntMarker += Epsom.length;
map.addOverlays(Exeter);
centerByArray(Exeter, false, false);
cntMarker += Exeter.length;
map.addOverlays(Hampstead);
centerByArray(Hampstead, false, false);
cntMarker += Hampstead.length;
map.addOverlays(Hampton);
centerByArray(Hampton, false, false);
cntMarker += Hampton.length;
map.addOverlays(Hanover);
centerByArray(Hanover, false, false);
cntMarker += Hanover.length;
map.addOverlays(Hooksett);
centerByArray(Hooksett, false, false);
cntMarker += Hooksett.length;
map.addOverlays(Intervale);
centerByArray(Intervale, false, false);
cntMarker += Intervale.length;
map.addOverlays(Keene);
centerByArray(Keene, false, false);
cntMarker += Keene.length;
map.addOverlays(Lancaster);
centerByArray(Lancaster, false, false);
cntMarker += Lancaster.length;
map.addOverlays(Littleton);
centerByArray(Littleton, false, false);
cntMarker += Littleton.length;
map.addOverlays(Londonderry);
centerByArray(Londonderry, false, false);
cntMarker += Londonderry.length;
map.addOverlays(Milford);
centerByArray(Milford, false, false);
cntMarker += Milford.length;
map.addOverlays(North_Conway);
centerByArray(North_Conway, false, false);
cntMarker += North_Conway.length;
map.addOverlays(Pembroke);
centerByArray(Pembroke, false, false);
cntMarker += Pembroke.length;
map.addOverlays(Plymouth);
centerByArray(Plymouth, false, false);
cntMarker += Plymouth.length;
map.addOverlays(Rumney);
centerByArray(Rumney, false, false);
cntMarker += Rumney.length;
map.addOverlays(Rye);
centerByArray(Rye, false, false);
cntMarker += Rye.length;
map.addOverlays(Salem);
centerByArray(Salem, false, false);
cntMarker += Salem.length;
map.addOverlays(Sanbornton);
centerByArray(Sanbornton, false, false);
cntMarker += Sanbornton.length;
map.addOverlays(Stratham);
centerByArray(Stratham, false, false);
cntMarker += Stratham.length;
map.addOverlays(West_Lebanon);
centerByArray(West_Lebanon, false, false);
cntMarker += West_Lebanon.length;
centerByArray(Hampstead,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///34779,16673,16675,34595,34596,16940,16705,34780,16747,34670,16846,16939,16744,16946,16729,16745,16808,16811,36270,16996,17002,16746,16943,16679,16691,16741,16942,16701,16941,/all');
//window.open('/map.php?type=2&schools=34779,16673,16675,34595,34596,16940,16705,34780,16747,34670,16846,16939,16744,16946,16729,16745,16808,16811,36270,16996,17002,16746,16943,16679,16691,16741,16942,16701,16941,&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;
}