function addMarkers(){
mySelect = document.getElementById('selection');
Cape_Elizabeth = [];Steep_Falls = [];North_Yarmouth = [];Portland = [];South_Portland = [];Falmouth = [];Brunswick = [];Freeport = [];Bridgton = [];Raymond = [];Westbrook = [];South_Freeport = [];New_Gloucester = [];West_Baldwin = [];Yarmouth = [];Casco = [];Scarborough = [];Gorham = [];Windham = [];mySelect.options[mySelect.options.length] = new Option("Bridgton schools",'all=Bridgton');
mySelect.options[mySelect.options.length] = new Option("Brunswick schools",'all=Brunswick');
mySelect.options[mySelect.options.length] = new Option("Cape Elizabeth schools",'all=Cape_Elizabeth');
mySelect.options[mySelect.options.length] = new Option("Casco schools",'all=Casco');
mySelect.options[mySelect.options.length] = new Option("Falmouth schools",'all=Falmouth');
mySelect.options[mySelect.options.length] = new Option("Freeport schools",'all=Freeport');
mySelect.options[mySelect.options.length] = new Option("Gorham schools",'all=Gorham');
mySelect.options[mySelect.options.length] = new Option("New Gloucester schools",'all=New_Gloucester');
mySelect.options[mySelect.options.length] = new Option("North Yarmouth schools",'all=North_Yarmouth');
mySelect.options[mySelect.options.length] = new Option("Portland schools",'all=Portland');
mySelect.options[mySelect.options.length] = new Option("Raymond schools",'all=Raymond');
mySelect.options[mySelect.options.length] = new Option("Scarborough schools",'all=Scarborough');
mySelect.options[mySelect.options.length] = new Option("South Freeport schools",'all=South_Freeport');
mySelect.options[mySelect.options.length] = new Option("South Portland schools",'all=South_Portland');
mySelect.options[mySelect.options.length] = new Option("Steep Falls schools",'all=Steep_Falls');
mySelect.options[mySelect.options.length] = new Option("West Baldwin schools",'all=West_Baldwin');
mySelect.options[mySelect.options.length] = new Option("Westbrook schools",'all=Westbrook');
mySelect.options[mySelect.options.length] = new Option("Windham schools",'all=Windham');
mySelect.options[mySelect.options.length] = new Option("Yarmouth schools",'all=Yarmouth');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Cape_Elizabeth[Cape_Elizabeth.length] = createMarker(new GPoint(-70.21868900,43.56971200),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Appletree School",'Cape_Elizabeth=' + Cape_Elizabeth.length);
Cape_Elizabeth[Cape_Elizabeth.length] = createMarker(new GPoint(-70.24662400,43.61886500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Aucocisco School",'Cape_Elizabeth=' + Cape_Elizabeth.length);
Steep_Falls[Steep_Falls.length] = createMarker(new GPoint(-70.63850000,43.76690000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Berean Christian Academy",'Steep_Falls=' + Steep_Falls.length);
North_Yarmouth[North_Yarmouth.length] = createMarker(new GPoint(-70.22042600,43.85500300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Brailsford School",'North_Yarmouth=' + North_Yarmouth.length);
Portland[Portland.length] = createMarker(new GPoint(-70.31355500,43.67273600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Breakwater School",'Portland=' + Portland.length);
South_Portland[South_Portland.length] = createMarker(new GPoint(-70.25038700,43.62699500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Casco Bay Montessori School",'South_Portland=' + South_Portland.length);
Portland[Portland.length] = createMarker(new GPoint(-70.25337500,43.66167500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cathedral School",'Portland=' + Portland.length);
Falmouth[Falmouth.length] = createMarker(new GPoint(-70.29933200,43.75115500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Children's Odyssey",'Falmouth=' + Falmouth.length);
Portland[Portland.length] = createMarker(new GPoint(-70.29362600,43.68315100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Childrens Center",'Portland=' + Portland.length);
Portland[Portland.length] = createMarker(new GPoint(-70.29362600,43.68315100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Childrens Center",'Portland=' + Portland.length);
Brunswick[Brunswick.length] = createMarker(new GPoint(-69.87835700,43.90720400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Childrens School Of Arts &science",'Brunswick=' + Brunswick.length);
Freeport[Freeport.length] = createMarker(new GPoint(-70.11124600,43.85078600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cricket Hunt School",'Freeport=' + Freeport.length);
Bridgton[Bridgton.length] = createMarker(new GPoint(-70.71020000,44.05764000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Dodge House",'Bridgton=' + Bridgton.length);
Portland[Portland.length] = createMarker(new GPoint(-70.25665400,43.65914500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("East School",'Portland=' + Portland.length);
Falmouth[Falmouth.length] = createMarker(new GPoint(-70.23458700,43.68942800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Friends School of Portland",'Falmouth=' + Falmouth.length);
Raymond[Raymond.length] = createMarker(new GPoint(-70.49637700,43.90848700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Future Builder's Inc",'Raymond=' + Raymond.length);
Portland[Portland.length] = createMarker(new GPoint(-70.29615100,43.71826200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Grace Baptist Church School",'Portland=' + Portland.length);
South_Portland[South_Portland.length] = createMarker(new GPoint(-70.28770900,43.62979200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Greater Portland Christian School",'South_Portland=' + South_Portland.length);
Westbrook[Westbrook.length] = createMarker(new GPoint(-70.35600200,43.64640300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Koala Child Kare",'Westbrook=' + Westbrook.length);
South_Freeport[South_Freeport.length] = createMarker(new GPoint(-70.11054000,43.82042900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("L'ecole Francaise Du Maine",'South_Freeport=' + South_Freeport.length);
Cape_Elizabeth[Cape_Elizabeth.length] = createMarker(new GPoint(-70.23355000,43.62517800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Ledgemere Country Day School",'Cape_Elizabeth=' + Cape_Elizabeth.length);
Portland[Portland.length] = createMarker(new GPoint(-70.28340500,43.66575600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Levey Day School",'Portland=' + Portland.length);
South_Portland[South_Portland.length] = createMarker(new GPoint(-70.26538600,43.62324800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lighthouse School",'South_Portland=' + South_Portland.length);
Westbrook[Westbrook.length] = createMarker(new GPoint(-70.34696400,43.65054000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Little Dolphin School",'Westbrook=' + Westbrook.length);
Westbrook[Westbrook.length] = createMarker(new GPoint(-70.34758900,43.65050400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Little Dolphin School Foundation",'Westbrook=' + Westbrook.length);
Freeport[Freeport.length] = createMarker(new GPoint(-70.10320000,43.85630000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Maine Classical School",'Freeport=' + Freeport.length);
Freeport[Freeport.length] = createMarker(new GPoint(-70.14300100,43.85352900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Merriconeag Waldorf School",'Freeport=' + Freeport.length);
New_Gloucester[New_Gloucester.length] = createMarker(new GPoint(-70.25506900,43.90369700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Msemhc-collaborative School",'New_Gloucester=' + New_Gloucester.length);
West_Baldwin[West_Baldwin.length] = createMarker(new GPoint(-70.77780100,43.83214500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("New Country School",'West_Baldwin=' + West_Baldwin.length);
Yarmouth[Yarmouth.length] = createMarker(new GPoint(-70.18481000,43.79966800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("North Yarmouth Academy",'Yarmouth=' + Yarmouth.length);
Falmouth[Falmouth.length] = createMarker(new GPoint(-70.23110400,43.71163000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Pine Grove Child Development Center",'Falmouth=' + Falmouth.length);
Freeport[Freeport.length] = createMarker(new GPoint(-70.11317000,43.86310900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Pine Tree Academy",'Freeport=' + Freeport.length);
North_Yarmouth[North_Yarmouth.length] = createMarker(new GPoint(-70.24708900,43.82504100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Red House Montessori School",'North_Yarmouth=' + North_Yarmouth.length);
Portland[Portland.length] = createMarker(new GPoint(-70.26129000,43.65300200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Elizabeth's Child Development",'Portland=' + Portland.length);
Brunswick[Brunswick.length] = createMarker(new GPoint(-69.96883400,43.91357800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. John's Catholic School",'Brunswick=' + Brunswick.length);
Portland[Portland.length] = createMarker(new GPoint(-70.29375300,43.68224600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Joseph's Parish School",'Portland=' + Portland.length);
Brunswick[Brunswick.length] = createMarker(new GPoint(-70.05861600,43.90058100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Spurwink Brunswick Staff Secure",'Brunswick=' + Brunswick.length);
Portland[Portland.length] = createMarker(new GPoint(-70.31912600,43.70523800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Spurwink School",'Portland=' + Portland.length);
Casco[Casco.length] = createMarker(new GPoint(-70.49907000,43.95080800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Spurwink School--casco",'Casco=' + Casco.length);
Portland[Portland.length] = createMarker(new GPoint(-70.29115400,43.65783500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Patrick S School",'Portland=' + Portland.length);
Scarborough[Scarborough.length] = createMarker(new GPoint(-70.35781800,43.57956700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Toddle Inn Child Care",'Scarborough=' + Scarborough.length);
Gorham[Gorham.length] = createMarker(new GPoint(-70.41637300,43.68264800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Toddle Inn-gorham",'Gorham=' + Gorham.length);
Portland[Portland.length] = createMarker(new GPoint(-70.27096200,43.64639100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Waynflete School",'Portland=' + Portland.length);
Windham[Windham.length] = createMarker(new GPoint(-70.46606200,43.86438500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Windham Christian Academy",'Windham=' + Windham.length);
Falmouth[Falmouth.length] = createMarker(new GPoint(-70.27530900,43.76109600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Winfield Children's House",'Falmouth=' + Falmouth.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(Bridgton);
map.removeOverlays(Brunswick);
map.removeOverlays(Cape_Elizabeth);
map.removeOverlays(Casco);
map.removeOverlays(Falmouth);
map.removeOverlays(Freeport);
map.removeOverlays(Gorham);
map.removeOverlays(New_Gloucester);
map.removeOverlays(North_Yarmouth);
map.removeOverlays(Portland);
map.removeOverlays(Raymond);
map.removeOverlays(Scarborough);
map.removeOverlays(South_Freeport);
map.removeOverlays(South_Portland);
map.removeOverlays(Steep_Falls);
map.removeOverlays(West_Baldwin);
map.removeOverlays(Westbrook);
map.removeOverlays(Windham);
map.removeOverlays(Yarmouth);
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(Cape_Elizabeth);map.removeOverlays(Bridgton);
map.removeOverlays(Brunswick);
map.removeOverlays(Cape_Elizabeth);
map.removeOverlays(Casco);
map.removeOverlays(Falmouth);
map.removeOverlays(Freeport);
map.removeOverlays(Gorham);
map.removeOverlays(New_Gloucester);
map.removeOverlays(North_Yarmouth);
map.removeOverlays(Portland);
map.removeOverlays(Raymond);
map.removeOverlays(Scarborough);
map.removeOverlays(South_Freeport);
map.removeOverlays(South_Portland);
map.removeOverlays(Steep_Falls);
map.removeOverlays(West_Baldwin);
map.removeOverlays(Westbrook);
map.removeOverlays(Windham);
map.removeOverlays(Yarmouth);
map.addOverlays(Bridgton);
centerByArray(Bridgton, false, false);
cntMarker += Bridgton.length;
map.addOverlays(Brunswick);
centerByArray(Brunswick, false, false);
cntMarker += Brunswick.length;
map.addOverlays(Cape_Elizabeth);
centerByArray(Cape_Elizabeth, false, false);
cntMarker += Cape_Elizabeth.length;
map.addOverlays(Casco);
centerByArray(Casco, false, false);
cntMarker += Casco.length;
map.addOverlays(Falmouth);
centerByArray(Falmouth, false, false);
cntMarker += Falmouth.length;
map.addOverlays(Freeport);
centerByArray(Freeport, false, false);
cntMarker += Freeport.length;
map.addOverlays(Gorham);
centerByArray(Gorham, false, false);
cntMarker += Gorham.length;
map.addOverlays(New_Gloucester);
centerByArray(New_Gloucester, false, false);
cntMarker += New_Gloucester.length;
map.addOverlays(North_Yarmouth);
centerByArray(North_Yarmouth, false, false);
cntMarker += North_Yarmouth.length;
map.addOverlays(Portland);
centerByArray(Portland, false, false);
cntMarker += Portland.length;
map.addOverlays(Raymond);
centerByArray(Raymond, false, false);
cntMarker += Raymond.length;
map.addOverlays(Scarborough);
centerByArray(Scarborough, false, false);
cntMarker += Scarborough.length;
map.addOverlays(South_Freeport);
centerByArray(South_Freeport, false, false);
cntMarker += South_Freeport.length;
map.addOverlays(South_Portland);
centerByArray(South_Portland, false, false);
cntMarker += South_Portland.length;
map.addOverlays(Steep_Falls);
centerByArray(Steep_Falls, false, false);
cntMarker += Steep_Falls.length;
map.addOverlays(West_Baldwin);
centerByArray(West_Baldwin, false, false);
cntMarker += West_Baldwin.length;
map.addOverlays(Westbrook);
centerByArray(Westbrook, false, false);
cntMarker += Westbrook.length;
map.addOverlays(Windham);
centerByArray(Windham, false, false);
cntMarker += Windham.length;
map.addOverlays(Yarmouth);
centerByArray(Yarmouth, false, false);
cntMarker += Yarmouth.length;
centerByArray(Cape_Elizabeth,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;
}