function addMarkers(){
mySelect = document.getElementById('selection');
Dover = [];Barrington = [];Rochester = [];Durham = [];Lee = [];Milton = [];Gonic = [];Somersworth = [];mySelect.options[mySelect.options.length] = new Option("Barrington schools",'all=Barrington');
mySelect.options[mySelect.options.length] = new Option("Dover schools",'all=Dover');
mySelect.options[mySelect.options.length] = new Option("Durham schools",'all=Durham');
mySelect.options[mySelect.options.length] = new Option("Gonic schools",'all=Gonic');
mySelect.options[mySelect.options.length] = new Option("Lee schools",'all=Lee');
mySelect.options[mySelect.options.length] = new Option("Milton schools",'all=Milton');
mySelect.options[mySelect.options.length] = new Option("Rochester schools",'all=Rochester');
mySelect.options[mySelect.options.length] = new Option("Somersworth schools",'all=Somersworth');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Dover[Dover.length] = createMarker(new GPoint(-70.93805700,43.21909600),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Children In Motion Inc",'Dover=' + Dover.length);
Barrington[Barrington.length] = createMarker(new GPoint(-71.03058800,43.15197700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Childrens Workshop",'Barrington=' + Barrington.length);
Dover[Dover.length] = createMarker(new GPoint(-70.93902200,43.20380100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cross Road Kindergarten And School",'Dover=' + Dover.length);
Dover[Dover.length] = createMarker(new GPoint(-70.87487000,43.17445100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Dover Children's Center",'Dover=' + Dover.length);
Rochester[Rochester.length] = createMarker(new GPoint(-70.97054000,43.31151300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Emmanuel Child Care Center",'Rochester=' + Rochester.length);
Barrington[Barrington.length] = createMarker(new GPoint(-71.03481900,43.21911900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Good Shepherd School & Learning Center",'Barrington=' + Barrington.length);
Durham[Durham.length] = createMarker(new GPoint(-70.92546300,43.13380500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Growing Places",'Durham=' + Durham.length);
Dover[Dover.length] = createMarker(new GPoint(-70.90636500,43.21307700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Happy Helpers Preschool Educ C",'Dover=' + Dover.length);
Rochester[Rochester.length] = createMarker(new GPoint(-70.95121900,43.29863000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Jack And Jill Kindergarten",'Rochester=' + Rochester.length);
Rochester[Rochester.length] = createMarker(new GPoint(-70.97010000,43.30508700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lighthouse Christian Academy",'Rochester=' + Rochester.length);
Lee[Lee.length] = createMarker(new GPoint(-71.00438100,43.15970000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Merri-lee Child Care Center",'Lee=' + Lee.length);
Milton[Milton.length] = createMarker(new GPoint(-71.00080000,43.42740000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Milton Learning Center",'Milton=' + Milton.length);
Rochester[Rochester.length] = createMarker(new GPoint(-70.97390000,43.30860000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Monarch School of New England",'Rochester=' + Rochester.length);
Dover[Dover.length] = createMarker(new GPoint(-70.87551100,43.19109700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("My School",'Dover=' + Dover.length);
Dover[Dover.length] = createMarker(new GPoint(-70.86243700,43.16056100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Portsmouth Christian Academy",'Dover=' + Dover.length);
Rochester[Rochester.length] = createMarker(new GPoint(-70.97458800,43.29646700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Rochester Child Care Center",'Rochester=' + Rochester.length);
Rochester[Rochester.length] = createMarker(new GPoint(-70.97864200,43.30402200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Elizabeth Seton School",'Rochester=' + Rochester.length);
Gonic[Gonic.length] = createMarker(new GPoint(-70.97995700,43.27608300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Leo Catholic Kindercare",'Gonic=' + Gonic.length);
Dover[Dover.length] = createMarker(new GPoint(-70.87359900,43.19123400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Mary Academy",'Dover=' + Dover.length);
Gonic[Gonic.length] = createMarker(new GPoint(-70.97999700,43.27779800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("School On The Hill",'Gonic=' + Gonic.length);
Somersworth[Somersworth.length] = createMarker(new GPoint(-70.87680000,43.25180000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Somersworth Christian Education",'Somersworth=' + Somersworth.length);
Somersworth[Somersworth.length] = createMarker(new GPoint(-70.87631100,43.25063700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Somersworth Early Learning Cen",'Somersworth=' + Somersworth.length);
Somersworth[Somersworth.length] = createMarker(new GPoint(-70.89157300,43.26101500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Tri-city Christian Academy",'Somersworth=' + Somersworth.length);
Dover[Dover.length] = createMarker(new GPoint(-70.87501300,43.21255000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Wdh Early Learning Center",'Dover=' + Dover.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/////1/' + showArray);
map.removeOverlays(Barrington);
map.removeOverlays(Dover);
map.removeOverlays(Durham);
map.removeOverlays(Gonic);
map.removeOverlays(Lee);
map.removeOverlays(Milton);
map.removeOverlays(Rochester);
map.removeOverlays(Somersworth);
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(Dover);map.removeOverlays(Barrington);
map.removeOverlays(Dover);
map.removeOverlays(Durham);
map.removeOverlays(Gonic);
map.removeOverlays(Lee);
map.removeOverlays(Milton);
map.removeOverlays(Rochester);
map.removeOverlays(Somersworth);
map.addOverlays(Barrington);
centerByArray(Barrington, false, false);
cntMarker += Barrington.length;
map.addOverlays(Dover);
centerByArray(Dover, false, false);
cntMarker += Dover.length;
map.addOverlays(Durham);
centerByArray(Durham, false, false);
cntMarker += Durham.length;
map.addOverlays(Gonic);
centerByArray(Gonic, false, false);
cntMarker += Gonic.length;
map.addOverlays(Lee);
centerByArray(Lee, false, false);
cntMarker += Lee.length;
map.addOverlays(Milton);
centerByArray(Milton, false, false);
cntMarker += Milton.length;
map.addOverlays(Rochester);
centerByArray(Rochester, false, false);
cntMarker += Rochester.length;
map.addOverlays(Somersworth);
centerByArray(Somersworth, false, false);
cntMarker += Somersworth.length;
centerByArray(Dover,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=1&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;
}