function addMarkers()
{
mySelect = document.getElementById('selection');
Madera = [];Madera[Madera.length] = createMarker(new GPoint(-120.08038330,36.95816422),"
",iconRd);
mySelect.options[mySelect.options.length] = new Option("Adams (john) Elementary School",'Madera=' + Madera.length);
Madera[Madera.length] = createMarker(new GPoint(-120.06517029,36.94431686),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Alpha Elementary School",'Madera=' + Madera.length);
Madera[Madera.length] = createMarker(new GPoint(-120.03691101,36.95273590),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Alternative/opportunity High School",'Madera=' + Madera.length);
Madera[Madera.length] = createMarker(new GPoint(-120.05242400,36.98618000),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Apollo Elementary Community Day",'Madera=' + Madera.length);
Madera[Madera.length] = createMarker(new GPoint(-120.05746460,37.02456284),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Berenda Elementary School",'Madera=' + Madera.length);
Madera[Madera.length] = createMarker(new GPoint(-119.87947083,36.98747635),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Bonadelle Community Day",'Madera=' + Madera.length);
Madera[Madera.length] = createMarker(new GPoint(-119.86762238,36.92323685),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Camelot High Continuation School",'Madera=' + Madera.length);
Madera[Madera.length] = createMarker(new GPoint(-120.05242400,36.98618000),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Challenger Elementary Community Day",'Madera=' + Madera.length);
Madera[Madera.length] = createMarker(new GPoint(-120.03691101,36.95273590),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Discovery Secondary",'Madera=' + Madera.length);
Madera[Madera.length] = createMarker(new GPoint(-120.20246887,37.01734543),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Dixieland Elementary School",'Madera=' + Madera.length);
Madera[Madera.length] = createMarker(new GPoint(-120.00923920,36.86593628),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Eastin-arcola Elementary School",'Madera=' + Madera.length);
Madera[Madera.length] = createMarker(new GPoint(-120.05242400,36.98618000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Enterprise Secondary",'Madera=' + Madera.length);
Madera[Madera.length] = createMarker(new GPoint(-120.03691101,36.95273590),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Enterprise Secondary School",'Madera=' + Madera.length);
Madera[Madera.length] = createMarker(new GPoint(-120.06971500,36.98690000),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Ezequiel Tafoya Alvarado Academy",'Madera=' + Madera.length);
Madera[Madera.length] = createMarker(new GPoint(-120.06766510,36.93843842),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Furman (duane E.) High (alter.)",'Madera=' + Madera.length);
Madera[Madera.length] = createMarker(new GPoint(-120.15625763,36.95102310),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Howard Elementary School",'Madera=' + Madera.length);
Madera[Madera.length] = createMarker(new GPoint(-119.86762238,36.92323685),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Independence High School",'Madera=' + Madera.length);
Madera[Madera.length] = createMarker(new GPoint(-120.06722600,36.99267600),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Jack G. Desmond Middle School",'Madera=' + Madera.length);
Madera[Madera.length] = createMarker(new GPoint(-120.07424164,36.96023560),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Jefferson (thomas) Middle School",'Madera=' + Madera.length);
Madera[Madera.length] = createMarker(new GPoint(-120.03441620,36.95273590),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Juvenile Hall (endeavor/voyager Secondary) High School",'Madera=' + Madera.length);
Madera[Madera.length] = createMarker(new GPoint(-120.04451752,36.96268845),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("King (martin Luther Jr.) Middle School",'Madera=' + Madera.length);
Madera[Madera.length] = createMarker(new GPoint(-120.12857056,36.87154007),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("La Vina Elementary School",'Madera=' + Madera.length);
Madera[Madera.length] = createMarker(new GPoint(-119.86762238,36.92323685),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Liberty High School",'Madera=' + Madera.length);
Madera[Madera.length] = createMarker(new GPoint(-120.33402252,36.92358017),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Liberty Middle School",'Madera=' + Madera.length);
Madera[Madera.length] = createMarker(new GPoint(-119.86765700,36.92289500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lincoln Community Day",'Madera=' + Madera.length);
Madera[Madera.length] = createMarker(new GPoint(-120.10366821,36.96149826),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Lincoln Elementary School",'Madera=' + Madera.length);
Madera[Madera.length] = createMarker(new GPoint(-120.02931700,36.95260800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Madera County Alternative/opportunity",'Madera=' + Madera.length);
Madera[Madera.length] = createMarker(new GPoint(-120.06582642,36.95590591),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Madera High School",'Madera=' + Madera.length);
Madera[Madera.length] = createMarker(new GPoint(-120.06491852,36.95255661),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Madison Elementary School",'Madera=' + Madera.length);
Madera[Madera.length] = createMarker(new GPoint(-120.04050446,36.97102356),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Millview Elementary School",'Madera=' + Madera.length);
Madera[Madera.length] = createMarker(new GPoint(-120.05603027,36.98492813),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Monroe (james) Elementary School",'Madera=' + Madera.length);
Madera[Madera.length] = createMarker(new GPoint(-120.03843689,36.97220230),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mountain Vista High (continuation)",'Madera=' + Madera.length);
Madera[Madera.length] = createMarker(new GPoint(-120.06722600,36.99267600),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Nishimoto Elementary School",'Madera=' + Madera.length);
Madera[Madera.length] = createMarker(new GPoint(-120.03691101,36.95273590),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Pioneer Technical Center",'Madera=' + Madera.length);
Madera[Madera.length] = createMarker(new GPoint(-120.07051849,36.85143661),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Ripperdan Elementary School",'Madera=' + Madera.length);
Madera[Madera.length] = createMarker(new GPoint(-120.06399400,36.96205500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Ripperdan High School",'Madera=' + Madera.length);
Madera[Madera.length] = createMarker(new GPoint(-120.10427856,36.95679855),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Sherman Thomas Charter",'Madera=' + Madera.length);
Madera[Madera.length] = createMarker(new GPoint(-119.87947083,36.98747635),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Sierra View Elementary School",'Madera=' + Madera.length);
Madera[Madera.length] = createMarker(new GPoint(-120.04553223,36.95283890),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Sierra Vista Elementary School",'Madera=' + Madera.length);
Madera[Madera.length] = createMarker(new GPoint(-120.03691101,36.95273590),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Special Education",'Madera=' + Madera.length);
Madera[Madera.length] = createMarker(new GPoint(-119.91171600,36.90445000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Valley Teen Ranch Community Day",'Madera=' + Madera.length);
Madera[Madera.length] = createMarker(new GPoint(-120.06175995,36.97053528),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Washington (george) Elementary School",'Madera=' + Madera.length);
Madera[Madera.length] = createMarker(new GPoint(-119.88565826,36.92983627),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Webster Elementary School",'Madera=' + Madera.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(Madera);
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(Madera);map.removeOverlays(Madera);
map.addOverlays(Madera);
centerByArray(Madera, false, false);
cntMarker += Madera.length;
centerByArray(Madera,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');
}
}