function addMarkers()
{
mySelect = document.getElementById('selection');
Ridgeville = [];Winchester = [];Parker_City = [];Union_City = [];Lynn = [];Modoc = [];mySelect.options[mySelect.options.length] = new Option("Lynn schools",'all=Lynn');
mySelect.options[mySelect.options.length] = new Option("Modoc schools",'all=Modoc');
mySelect.options[mySelect.options.length] = new Option("Parker City schools",'all=Parker_City');
mySelect.options[mySelect.options.length] = new Option("Ridgeville schools",'all=Ridgeville');
mySelect.options[mySelect.options.length] = new Option("Union City schools",'all=Union_City');
mySelect.options[mySelect.options.length] = new Option("Winchester schools",'all=Winchester');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Ridgeville[Ridgeville.length] = createMarker(new GPoint(-85.02912140,40.28913879),"
",iconRd);
mySelect.options[mySelect.options.length] = new Option("Deerfield Elementary School",'Ridgeville=' + Ridgeville.length);
Winchester[Winchester.length] = createMarker(new GPoint(-84.95729828,40.12112045),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Lee L Driver Middle School",'Winchester=' + Winchester.length);
Parker_City[Parker_City.length] = createMarker(new GPoint(-85.20413971,40.18859100),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Monroe Central Elementary School",'Parker_City=' + Parker_City.length);
Parker_City[Parker_City.length] = createMarker(new GPoint(-85.20413971,40.18859100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Monroe Central Junior Senior High School",'Parker_City=' + Parker_City.length);
Union_City[Union_City.length] = createMarker(new GPoint(-84.81402588,40.20649338),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("North Side Elementary School",'Union_City=' + Union_City.length);
Winchester[Winchester.length] = createMarker(new GPoint(-84.97621918,40.16705322),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("O R Baker Elementary School",'Winchester=' + Winchester.length);
Lynn[Lynn.length] = createMarker(new GPoint(-84.93119812,40.04629898),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Randolph Southern Elementary School",'Lynn=' + Lynn.length);
Lynn[Lynn.length] = createMarker(new GPoint(-84.93119812,40.04629898),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Randolph Southern Junior Senior High School",'Lynn=' + Lynn.length);
Union_City[Union_City.length] = createMarker(new GPoint(-84.81457520,40.20408630),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Union City Community High School",'Union_City=' + Union_City.length);
Modoc[Modoc.length] = createMarker(new GPoint(-85.13565063,40.04796219),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Union Elementary School",'Modoc=' + Modoc.length);
Modoc[Modoc.length] = createMarker(new GPoint(-85.13565063,40.04796219),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Union Junior & High School",'Modoc=' + Modoc.length);
Union_City[Union_City.length] = createMarker(new GPoint(-84.81337738,40.19946289),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("West Side Middle School",'Union_City=' + Union_City.length);
Winchester[Winchester.length] = createMarker(new GPoint(-84.98812103,40.17026138),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Willard Elementary School",'Winchester=' + Winchester.length);
Winchester[Winchester.length] = createMarker(new GPoint(-84.97592163,40.17979813),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Winchester Community High School",'Winchester=' + Winchester.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,10);
/*
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////' + showArray);
map.removeOverlays(Lynn);
map.removeOverlays(Modoc);
map.removeOverlays(Parker_City);
map.removeOverlays(Ridgeville);
map.removeOverlays(Union_City);
map.removeOverlays(Winchester);
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(Ridgeville);map.removeOverlays(Lynn);
map.removeOverlays(Modoc);
map.removeOverlays(Parker_City);
map.removeOverlays(Ridgeville);
map.removeOverlays(Union_City);
map.removeOverlays(Winchester);
map.addOverlays(Lynn);
centerByArray(Lynn, false, false);
cntMarker += Lynn.length;
map.addOverlays(Modoc);
centerByArray(Modoc, false, false);
cntMarker += Modoc.length;
map.addOverlays(Parker_City);
centerByArray(Parker_City, false, false);
cntMarker += Parker_City.length;
map.addOverlays(Ridgeville);
centerByArray(Ridgeville, false, false);
cntMarker += Ridgeville.length;
map.addOverlays(Union_City);
centerByArray(Union_City, false, false);
cntMarker += Union_City.length;
map.addOverlays(Winchester);
centerByArray(Winchester, false, false);
cntMarker += Winchester.length;
centerByArray(Ridgeville,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');
}
}