function addMarkers()
{
mySelect = document.getElementById('selection');
Apple_Valley = [];Apple_Valley[Apple_Valley.length] = createMarker(new GPoint(-93.21757900,44.74275000),"
",iconBl);
mySelect.options[mySelect.options.length] = new Option("917 Mcquire Jr High School",'Apple_Valley=' + Apple_Valley.length);
Apple_Valley[Apple_Valley.length] = createMarker(new GPoint(-93.03949738,44.84349823),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("917 Pine Bend Elementary School",'Apple_Valley=' + Apple_Valley.length);
Apple_Valley[Apple_Valley.length] = createMarker(new GPoint(-93.23280334,44.73941803),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Apple Valley Senior High School",'Apple_Valley=' + Apple_Valley.length);
Apple_Valley[Apple_Valley.length] = createMarker(new GPoint(-93.21939850,44.72637177),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Cedar Park Elementary School",'Apple_Valley=' + Apple_Valley.length);
Apple_Valley[Apple_Valley.length] = createMarker(new GPoint(-93.15761566,44.74082184),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Dakota Ridge School",'Apple_Valley=' + Apple_Valley.length);
Apple_Valley[Apple_Valley.length] = createMarker(new GPoint(-93.15631866,44.74003601),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Diamond Path Elementary School",'Apple_Valley=' + Apple_Valley.length);
Apple_Valley[Apple_Valley.length] = createMarker(new GPoint(-93.18431854,44.73276520),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Early Childhood Learning Center",'Apple_Valley=' + Apple_Valley.length);
Apple_Valley[Apple_Valley.length] = createMarker(new GPoint(-93.19136047,44.74636459),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Eastview Senior High School",'Apple_Valley=' + Apple_Valley.length);
Apple_Valley[Apple_Valley.length] = createMarker(new GPoint(-93.18669891,44.76266861),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Falcon Ridge Middle School",'Apple_Valley=' + Apple_Valley.length);
Apple_Valley[Apple_Valley.length] = createMarker(new GPoint(-93.20745087,44.75528717),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Greenleaf Elementary School",'Apple_Valley=' + Apple_Valley.length);
Apple_Valley[Apple_Valley.length] = createMarker(new GPoint(-93.17709351,44.74636459),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Highland Elementary School",'Apple_Valley=' + Apple_Valley.length);
Apple_Valley[Apple_Valley.length] = createMarker(new GPoint(-93.20369720,44.74440002),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Idea/apple Valley Campus High School",'Apple_Valley=' + Apple_Valley.length);
Apple_Valley[Apple_Valley.length] = createMarker(new GPoint(-93.21179600,44.73477300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Paideia Academy Charter School",'Apple_Valley=' + Apple_Valley.length);
Apple_Valley[Apple_Valley.length] = createMarker(new GPoint(-93.21398163,44.73270416),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Rosemount Alc High School",'Apple_Valley=' + Apple_Valley.length);
Apple_Valley[Apple_Valley.length] = createMarker(new GPoint(-93.21757900,44.74275000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Rosemount Area Learning Cntr.",'Apple_Valley=' + Apple_Valley.length);
Apple_Valley[Apple_Valley.length] = createMarker(new GPoint(-93.20359802,44.74449921),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("School Of Environmental Studies",'Apple_Valley=' + Apple_Valley.length);
Apple_Valley[Apple_Valley.length] = createMarker(new GPoint(-93.17709351,44.74475861),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Scott Highlands Middle School",'Apple_Valley=' + Apple_Valley.length);
Apple_Valley[Apple_Valley.length] = createMarker(new GPoint(-93.24022675,44.72527695),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Southview Elementary School",'Apple_Valley=' + Apple_Valley.length);
Apple_Valley[Apple_Valley.length] = createMarker(new GPoint(-93.21398163,44.73270416),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Transition Plus High School",'Apple_Valley=' + Apple_Valley.length);
Apple_Valley[Apple_Valley.length] = createMarker(new GPoint(-93.23839569,44.72698975),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Valley Middle School",'Apple_Valley=' + Apple_Valley.length);
Apple_Valley[Apple_Valley.length] = createMarker(new GPoint(-93.23861694,44.73873520),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Westview Elementary School",'Apple_Valley=' + Apple_Valley.length);
Apple_Valley[Apple_Valley.length] = createMarker(new GPoint(-93.20887756,44.81993866),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Youth Transition Program (ytp)",'Apple_Valley=' + Apple_Valley.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(Apple_Valley);
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(Apple_Valley);map.removeOverlays(Apple_Valley);
map.addOverlays(Apple_Valley);
centerByArray(Apple_Valley, false, false);
cntMarker += Apple_Valley.length;
centerByArray(Apple_Valley,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');
}
}