function addMarkers(){
mySelect = document.getElementById('selection');
Peru = [];Mendota = [];Oglesby = [];Ottawa = [];La_Salle = [];Streator = [];Sheridan = [];mySelect.options[mySelect.options.length] = new Option("La Salle schools",'all=La_Salle');
mySelect.options[mySelect.options.length] = new Option("Mendota schools",'all=Mendota');
mySelect.options[mySelect.options.length] = new Option("Oglesby schools",'all=Oglesby');
mySelect.options[mySelect.options.length] = new Option("Ottawa schools",'all=Ottawa');
mySelect.options[mySelect.options.length] = new Option("Peru schools",'all=Peru');
mySelect.options[mySelect.options.length] = new Option("Sheridan schools",'all=Sheridan');
mySelect.options[mySelect.options.length] = new Option("Streator schools",'all=Streator');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Peru[Peru.length] = createMarker(new GPoint(-89.11691600,41.34307300),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Childrens Montessori School",'Peru=' + Peru.length);
Mendota[Mendota.length] = createMarker(new GPoint(-89.12268300,41.54933700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Holy Cross Elementary School",'Mendota=' + Mendota.length);
Oglesby[Oglesby.length] = createMarker(new GPoint(-89.06005900,41.29946900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Holy Family Elementary School",'Oglesby=' + Oglesby.length);
Ottawa[Ottawa.length] = createMarker(new GPoint(-88.84678200,41.32771100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lasalle County Easter",'Ottawa=' + Ottawa.length);
La_Salle[La_Salle.length] = createMarker(new GPoint(-89.09290500,41.33408000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lighted Way Association Inc",'La_Salle=' + La_Salle.length);
Ottawa[Ottawa.length] = createMarker(new GPoint(-88.83961600,41.35013700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Marquette High School",'Ottawa=' + Ottawa.length);
La_Salle[La_Salle.length] = createMarker(new GPoint(-89.09497600,41.37025900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Midwest Center Christian Academy",'La_Salle=' + La_Salle.length);
Peru[Peru.length] = createMarker(new GPoint(-89.13197500,41.32859800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Peru Catholic School",'Peru=' + Peru.length);
Streator[Streator.length] = createMarker(new GPoint(-88.83573600,41.17047600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Rhema Christian Academy",'Streator=' + Streator.length);
Streator[Streator.length] = createMarker(new GPoint(-88.83428100,41.11610000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Anthony School",'Streator=' + Streator.length);
Streator[Streator.length] = createMarker(new GPoint(-88.83541700,41.12424700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Marys School",'Streator=' + Streator.length);
Ottawa[Ottawa.length] = createMarker(new GPoint(-88.85189400,41.34766300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Patrick School",'Ottawa=' + Ottawa.length);
Streator[Streator.length] = createMarker(new GPoint(-88.82565100,41.11526300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Stephen School",'Streator=' + Streator.length);
Sheridan[Sheridan.length] = createMarker(new GPoint(-88.67458000,41.50091400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Seventh Day Adventist School",'Sheridan=' + Sheridan.length);
Peru[Peru.length] = createMarker(new GPoint(-89.12940000,41.33450000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Bede Academy",'Peru=' + Peru.length);
Ottawa[Ottawa.length] = createMarker(new GPoint(-88.84251600,41.35122200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Columba School",'Ottawa=' + Ottawa.length);
La_Salle[La_Salle.length] = createMarker(new GPoint(-89.09141900,41.33419000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Trinity Catholic Academy",'La_Salle=' + La_Salle.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(La_Salle);
map.removeOverlays(Mendota);
map.removeOverlays(Oglesby);
map.removeOverlays(Ottawa);
map.removeOverlays(Peru);
map.removeOverlays(Sheridan);
map.removeOverlays(Streator);
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(Peru);map.removeOverlays(La_Salle);
map.removeOverlays(Mendota);
map.removeOverlays(Oglesby);
map.removeOverlays(Ottawa);
map.removeOverlays(Peru);
map.removeOverlays(Sheridan);
map.removeOverlays(Streator);
map.addOverlays(La_Salle);
centerByArray(La_Salle, false, false);
cntMarker += La_Salle.length;
map.addOverlays(Mendota);
centerByArray(Mendota, false, false);
cntMarker += Mendota.length;
map.addOverlays(Oglesby);
centerByArray(Oglesby, false, false);
cntMarker += Oglesby.length;
map.addOverlays(Ottawa);
centerByArray(Ottawa, false, false);
cntMarker += Ottawa.length;
map.addOverlays(Peru);
centerByArray(Peru, false, false);
cntMarker += Peru.length;
map.addOverlays(Sheridan);
centerByArray(Sheridan, false, false);
cntMarker += Sheridan.length;
map.addOverlays(Streator);
centerByArray(Streator, false, false);
cntMarker += Streator.length;
centerByArray(Peru,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;
}