function addMarkers(){
mySelect = document.getElementById('selection');
Canton = [];Louisville = [];Hartville = [];North_Canton = [];Massillon = [];Minerva = [];Alliance = [];Canal_Fulton = [];Navarre = [];Waynesburg = [];mySelect.options[mySelect.options.length] = new Option("Alliance schools",'all=Alliance');
mySelect.options[mySelect.options.length] = new Option("Canal Fulton schools",'all=Canal_Fulton');
mySelect.options[mySelect.options.length] = new Option("Canton schools",'all=Canton');
mySelect.options[mySelect.options.length] = new Option("Hartville schools",'all=Hartville');
mySelect.options[mySelect.options.length] = new Option("Louisville schools",'all=Louisville');
mySelect.options[mySelect.options.length] = new Option("Massillon schools",'all=Massillon');
mySelect.options[mySelect.options.length] = new Option("Minerva schools",'all=Minerva');
mySelect.options[mySelect.options.length] = new Option("Navarre schools",'all=Navarre');
mySelect.options[mySelect.options.length] = new Option("North Canton schools",'all=North_Canton');
mySelect.options[mySelect.options.length] = new Option("Waynesburg schools",'all=Waynesburg');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Canton[Canton.length] = createMarker(new GPoint(-81.42026300,40.84193800),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Academy Early Childhood An",'Canton=' + Canton.length);
Canton[Canton.length] = createMarker(new GPoint(-81.40448700,40.83199900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Canton Country Day School",'Canton=' + Canton.length);
Canton[Canton.length] = createMarker(new GPoint(-81.37171000,40.81393700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Canton Montessori School",'Canton=' + Canton.length);
Louisville[Louisville.length] = createMarker(new GPoint(-81.23034800,40.95130000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Good Shepherd School",'Louisville=' + Louisville.length);
Hartville[Hartville.length] = createMarker(new GPoint(-81.36063200,40.93946200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Hartville Christian School",'Hartville=' + Hartville.length);
Canton[Canton.length] = createMarker(new GPoint(-81.39734600,40.79676700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Heritage Christian School",'Canton=' + Canton.length);
North_Canton[North_Canton.length] = createMarker(new GPoint(-81.36315500,40.89748300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Holy Cross Ps, Kg & Childcare",'North_Canton=' + North_Canton.length);
Hartville[Hartville.length] = createMarker(new GPoint(-81.36843000,40.97592400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lake Center Christian School",'Hartville=' + Hartville.length);
Massillon[Massillon.length] = createMarker(new GPoint(-81.51442500,40.80082500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Little Sprouts Child Development Center",'Massillon=' + Massillon.length);
Canton[Canton.length] = createMarker(new GPoint(-81.37644200,40.82413700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Malone College Weaver Child Development Center",'Canton=' + Canton.length);
Massillon[Massillon.length] = createMarker(new GPoint(-81.53432900,40.78596300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Massillon Christian School",'Massillon=' + Massillon.length);
Minerva[Minerva.length] = createMarker(new GPoint(-81.10578200,40.72998500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Minerva Area Christian School",'Minerva=' + Minerva.length);
Minerva[Minerva.length] = createMarker(new GPoint(-81.09568100,40.79789700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("New Franklin Christian Academy",'Minerva=' + Minerva.length);
Canton[Canton.length] = createMarker(new GPoint(-81.38088500,40.84193700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Our Lady Of Peace School",'Canton=' + Canton.length);
Alliance[Alliance.length] = createMarker(new GPoint(-81.12349400,40.91497000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Regina Coeli/st Joseph School",'Alliance=' + Alliance.length);
Massillon[Massillon.length] = createMarker(new GPoint(-81.48663400,40.87925600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Rivertree Christian School",'Massillon=' + Massillon.length);
Louisville[Louisville.length] = createMarker(new GPoint(-81.25930000,40.85120000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sacred Heart Of Mary School",'Louisville=' + Louisville.length);
Canton[Canton.length] = createMarker(new GPoint(-81.44173300,40.79331500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Joan Of Arc School",'Canton=' + Canton.length);
Massillon[Massillon.length] = createMarker(new GPoint(-81.50509700,40.81857500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. John Lutheran School",'Massillon=' + Massillon.length);
Canton[Canton.length] = createMarker(new GPoint(-81.42140000,40.96360000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Mark's Episcopal Day School",'Canton=' + Canton.length);
North_Canton[North_Canton.length] = createMarker(new GPoint(-81.40186700,40.87470000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Paul School",'North_Canton=' + North_Canton.length);
Canton[Canton.length] = createMarker(new GPoint(-81.37481400,40.80318700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Peter Elementary School",'Canton=' + Canton.length);
Canton[Canton.length] = createMarker(new GPoint(-81.41803900,40.83331900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Small Word Montessori Inc",'Canton=' + Canton.length);
Canal_Fulton[Canal_Fulton.length] = createMarker(new GPoint(-81.59514500,40.88931800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Ss Philip & James School",'Canal_Fulton=' + Canal_Fulton.length);
Massillon[Massillon.length] = createMarker(new GPoint(-81.56054600,40.79576700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Barbara Elementary School",'Massillon=' + Massillon.length);
Navarre[Navarre.length] = createMarker(new GPoint(-81.51811800,40.72448200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Clement Elementary School",'Navarre=' + Navarre.length);
Waynesburg[Waynesburg.length] = createMarker(new GPoint(-81.26729100,40.66581900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St James Elementary School",'Waynesburg=' + Waynesburg.length);
Canton[Canton.length] = createMarker(new GPoint(-81.40248100,40.79942500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Joseph School",'Canton=' + Canton.length);
Louisville[Louisville.length] = createMarker(new GPoint(-81.25939700,40.83841000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Louis Elementary School",'Louisville=' + Louisville.length);
Massillon[Massillon.length] = createMarker(new GPoint(-81.52347500,40.80212500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Mary Elementary School",'Massillon=' + Massillon.length);
Canton[Canton.length] = createMarker(new GPoint(-81.42114100,40.83585300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Michael Elementary School",'Canton=' + Canton.length);
Canton[Canton.length] = createMarker(new GPoint(-81.36647100,40.82632500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Stark County Christian Academy",'Canton=' + Canton.length);
Canton[Canton.length] = createMarker(new GPoint(-81.38965500,40.83736400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Stark Montessori School",'Canton=' + Canton.length);
Canton[Canton.length] = createMarker(new GPoint(-81.37570000,40.79880000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Trinity Lutheran Presch & Kindergarten",'Canton=' + Canton.length);
Canton[Canton.length] = createMarker(new GPoint(-81.37748300,40.79880300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Trinity Lutheran Preschool",'Canton=' + Canton.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(Alliance);
map.removeOverlays(Canal_Fulton);
map.removeOverlays(Canton);
map.removeOverlays(Hartville);
map.removeOverlays(Louisville);
map.removeOverlays(Massillon);
map.removeOverlays(Minerva);
map.removeOverlays(Navarre);
map.removeOverlays(North_Canton);
map.removeOverlays(Waynesburg);
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(Canton);map.removeOverlays(Alliance);
map.removeOverlays(Canal_Fulton);
map.removeOverlays(Canton);
map.removeOverlays(Hartville);
map.removeOverlays(Louisville);
map.removeOverlays(Massillon);
map.removeOverlays(Minerva);
map.removeOverlays(Navarre);
map.removeOverlays(North_Canton);
map.removeOverlays(Waynesburg);
map.addOverlays(Alliance);
centerByArray(Alliance, false, false);
cntMarker += Alliance.length;
map.addOverlays(Canal_Fulton);
centerByArray(Canal_Fulton, false, false);
cntMarker += Canal_Fulton.length;
map.addOverlays(Canton);
centerByArray(Canton, false, false);
cntMarker += Canton.length;
map.addOverlays(Hartville);
centerByArray(Hartville, false, false);
cntMarker += Hartville.length;
map.addOverlays(Louisville);
centerByArray(Louisville, false, false);
cntMarker += Louisville.length;
map.addOverlays(Massillon);
centerByArray(Massillon, false, false);
cntMarker += Massillon.length;
map.addOverlays(Minerva);
centerByArray(Minerva, false, false);
cntMarker += Minerva.length;
map.addOverlays(Navarre);
centerByArray(Navarre, false, false);
cntMarker += Navarre.length;
map.addOverlays(North_Canton);
centerByArray(North_Canton, false, false);
cntMarker += North_Canton.length;
map.addOverlays(Waynesburg);
centerByArray(Waynesburg, false, false);
cntMarker += Waynesburg.length;
centerByArray(Canton,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;
}