function addMarkers()
{
mySelect = document.getElementById('selection');
Susanville = [];Susanville[Susanville.length] = createMarker(new GPoint(-120.58307648,40.37888336),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Alternative/opportunity High School",'Susanville=' + Susanville.length);
Susanville[Susanville.length] = createMarker(new GPoint(-120.66074371,40.41709900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Credence High (cont)",'Susanville=' + Susanville.length);
Susanville[Susanville.length] = createMarker(new GPoint(-120.64972400,40.41566500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Diamond Mountain Charter High School",'Susanville=' + Susanville.length);
Susanville[Susanville.length] = createMarker(new GPoint(-120.65468597,40.37600708),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Diamond View Elementary School",'Susanville=' + Susanville.length);
Susanville[Susanville.length] = createMarker(new GPoint(-120.58941650,40.38350677),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Johnstonville Elementary School",'Susanville=' + Susanville.length);
Susanville[Susanville.length] = createMarker(new GPoint(-120.65168762,40.41616058),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Juvenile Court School",'Susanville=' + Susanville.length);
Susanville[Susanville.length] = createMarker(new GPoint(-120.65646362,40.41717529),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lassen Community Day",'Susanville=' + Susanville.length);
Susanville[Susanville.length] = createMarker(new GPoint(-120.64897919,40.42412949),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lassen County Community High School",'Susanville=' + Susanville.length);
Susanville[Susanville.length] = createMarker(new GPoint(-120.65646362,40.41717529),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lassen High School",'Susanville=' + Susanville.length);
Susanville[Susanville.length] = createMarker(new GPoint(-120.58062800,40.37605000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lassen Rop",'Susanville=' + Susanville.length);
Susanville[Susanville.length] = createMarker(new GPoint(-120.64164734,40.41809082),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Mckinley Elementary School",'Susanville=' + Susanville.length);
Susanville[Susanville.length] = createMarker(new GPoint(-120.64164734,40.41809082),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Meadow View Elementary School",'Susanville=' + Susanville.length);
Susanville[Susanville.length] = createMarker(new GPoint(-120.66117096,40.41995239),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Paiute Creek Community Day",'Susanville=' + Susanville.length);
Susanville[Susanville.length] = createMarker(new GPoint(-120.65167999,40.37328339),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Richmond Elementary School",'Susanville=' + Susanville.length);
Susanville[Susanville.length] = createMarker(new GPoint(-120.58307648,40.37888336),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Special Education",'Susanville=' + Susanville.length);
Susanville[Susanville.length] = createMarker(new GPoint(-120.65699768,40.43510056),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Spring Ridge Community Day School",'Susanville=' + Susanville.length);
Susanville[Susanville.length] = createMarker(new GPoint(-120.66258240,40.41735840),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Susan River Community Day",'Susanville=' + Susanville.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(Susanville);
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(Susanville);map.removeOverlays(Susanville);
map.addOverlays(Susanville);
centerByArray(Susanville, false, false);
cntMarker += Susanville.length;
centerByArray(Susanville,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');
}
}