function addMarkers(){
mySelect = document.getElementById('selection');
Youngstown = [];Austintown = [];Boardman = [];Poland = [];Campbell = [];Salem = [];Struthers = [];Canfield = [];mySelect.options[mySelect.options.length] = new Option("Austintown schools",'all=Austintown');
mySelect.options[mySelect.options.length] = new Option("Boardman schools",'all=Boardman');
mySelect.options[mySelect.options.length] = new Option("Campbell schools",'all=Campbell');
mySelect.options[mySelect.options.length] = new Option("Canfield schools",'all=Canfield');
mySelect.options[mySelect.options.length] = new Option("Poland schools",'all=Poland');
mySelect.options[mySelect.options.length] = new Option("Salem schools",'all=Salem');
mySelect.options[mySelect.options.length] = new Option("Struthers schools",'all=Struthers');
mySelect.options[mySelect.options.length] = new Option("Youngstown schools",'all=Youngstown');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Youngstown[Youngstown.length] = createMarker(new GPoint(-80.65964100,41.13356300),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Akiva Academy",'Youngstown=' + Youngstown.length);
Youngstown[Youngstown.length] = createMarker(new GPoint(-80.64764800,41.10187100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("All Children Learn Differently",'Youngstown=' + Youngstown.length);
Youngstown[Youngstown.length] = createMarker(new GPoint(-80.61586600,41.04159700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Byzantine Catholic Central",'Youngstown=' + Youngstown.length);
Youngstown[Youngstown.length] = createMarker(new GPoint(-80.65261700,41.07406100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cardinal Mooney High School",'Youngstown=' + Youngstown.length);
Youngstown[Youngstown.length] = createMarker(new GPoint(-80.65111700,41.11820000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Father's Heart Elementary School",'Youngstown=' + Youngstown.length);
Austintown[Austintown.length] = createMarker(new GPoint(-80.73258100,41.07521100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Growing Place",'Austintown=' + Austintown.length);
Boardman[Boardman.length] = createMarker(new GPoint(-80.67688100,40.99265400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Hitchcock Woods School",'Boardman=' + Boardman.length);
Youngstown[Youngstown.length] = createMarker(new GPoint(-80.60068200,41.02356300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Holy Family Elementary School",'Youngstown=' + Youngstown.length);
Youngstown[Youngstown.length] = createMarker(new GPoint(-80.63417300,41.10083700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Immaculate Conception School",'Youngstown=' + Youngstown.length);
Austintown[Austintown.length] = createMarker(new GPoint(-80.73529800,41.10368600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Immaculate Heart Of Mary School",'Austintown=' + Austintown.length);
Boardman[Boardman.length] = createMarker(new GPoint(-80.66076400,40.99543700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lads N Lasses Academy",'Boardman=' + Boardman.length);
Youngstown[Youngstown.length] = createMarker(new GPoint(-80.61804100,41.05215800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Montessori School Of The Mahoning Valley",'Youngstown=' + Youngstown.length);
Poland[Poland.length] = createMarker(new GPoint(-80.60989100,40.98803000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("New Life Christian Preschool &",'Poland=' + Poland.length);
Youngstown[Youngstown.length] = createMarker(new GPoint(-80.58952500,41.12616300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Open Door Christian Academy Elementary School",'Youngstown=' + Youngstown.length);
Youngstown[Youngstown.length] = createMarker(new GPoint(-80.72938100,41.06884100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Anne Ukrainian Catholic",'Youngstown=' + Youngstown.length);
Youngstown[Youngstown.length] = createMarker(new GPoint(-80.70008100,41.10608400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Brendan School",'Youngstown=' + Youngstown.length);
Youngstown[Youngstown.length] = createMarker(new GPoint(-80.64698800,41.12317100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Edward Elementary School",'Youngstown=' + Youngstown.length);
Campbell[Campbell.length] = createMarker(new GPoint(-80.58559900,41.08126300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Joseph The Provider School",'Campbell=' + Campbell.length);
Youngstown[Youngstown.length] = createMarker(new GPoint(-80.63471700,41.04578300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Luke School",'Youngstown=' + Youngstown.length);
Salem[Salem.length] = createMarker(new GPoint(-80.87810700,40.93623000),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Sharon Lynn School For Girls",'Salem=' + Salem.length);
Youngstown[Youngstown.length] = createMarker(new GPoint(-80.66716400,41.02356300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Charles Elementary School",'Youngstown=' + Youngstown.length);
Youngstown[Youngstown.length] = createMarker(new GPoint(-80.69941700,41.06621900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Christine Elementary School",'Youngstown=' + Youngstown.length);
Austintown[Austintown.length] = createMarker(new GPoint(-80.73778700,41.08332900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Joseph School Youngstown",'Austintown=' + Austintown.length);
Youngstown[Youngstown.length] = createMarker(new GPoint(-80.63434100,41.07142700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Matthias School",'Youngstown=' + Youngstown.length);
Struthers[Struthers.length] = createMarker(new GPoint(-80.60331700,41.05028000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Nicholas School",'Struthers=' + Struthers.length);
Youngstown[Youngstown.length] = createMarker(new GPoint(-80.64213300,41.10959800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Ursuline High School",'Youngstown=' + Youngstown.length);
Canfield[Canfield.length] = createMarker(new GPoint(-80.72857200,41.04254700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Ursuline Preschool And Kindergarten",'Canfield=' + Canfield.length);
Youngstown[Youngstown.length] = createMarker(new GPoint(-80.61075400,41.10269000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Watkins Christian Academy",'Youngstown=' + Youngstown.length);
Youngstown[Youngstown.length] = createMarker(new GPoint(-80.67514000,40.98813700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Willow Creek Learning Center",'Youngstown=' + Youngstown.length);
Youngstown[Youngstown.length] = createMarker(new GPoint(-80.65736300,41.05457500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Youngstown Christian School",'Youngstown=' + Youngstown.length);
Youngstown[Youngstown.length] = createMarker(new GPoint(-80.62603500,41.11897200),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Youngstown Youth Academy High School",'Youngstown=' + Youngstown.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/////3/' + showArray);
map.removeOverlays(Austintown);
map.removeOverlays(Boardman);
map.removeOverlays(Campbell);
map.removeOverlays(Canfield);
map.removeOverlays(Poland);
map.removeOverlays(Salem);
map.removeOverlays(Struthers);
map.removeOverlays(Youngstown);
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(Youngstown);map.removeOverlays(Austintown);
map.removeOverlays(Boardman);
map.removeOverlays(Campbell);
map.removeOverlays(Canfield);
map.removeOverlays(Poland);
map.removeOverlays(Salem);
map.removeOverlays(Struthers);
map.removeOverlays(Youngstown);
map.addOverlays(Austintown);
centerByArray(Austintown, false, false);
cntMarker += Austintown.length;
map.addOverlays(Boardman);
centerByArray(Boardman, false, false);
cntMarker += Boardman.length;
map.addOverlays(Campbell);
centerByArray(Campbell, false, false);
cntMarker += Campbell.length;
map.addOverlays(Canfield);
centerByArray(Canfield, false, false);
cntMarker += Canfield.length;
map.addOverlays(Poland);
centerByArray(Poland, false, false);
cntMarker += Poland.length;
map.addOverlays(Salem);
centerByArray(Salem, false, false);
cntMarker += Salem.length;
map.addOverlays(Struthers);
centerByArray(Struthers, false, false);
cntMarker += Struthers.length;
map.addOverlays(Youngstown);
centerByArray(Youngstown, false, false);
cntMarker += Youngstown.length;
centerByArray(Youngstown,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=3&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;
}