function addMarkers()
{
mySelect = document.getElementById('selection');
Bridgeport = [];East_Wenatchee = [];Mansfield = [];_Orondo_School_Road = [];_Palisades_Rd = [];_Rock_Island_Road = [];Waterville = [];mySelect.options[mySelect.options.length] = new Option("Bridgeport schools",'all=Bridgeport');
mySelect.options[mySelect.options.length] = new Option("East Wenatchee schools",'all=East_Wenatchee');
mySelect.options[mySelect.options.length] = new Option("Mansfield schools",'all=Mansfield');
mySelect.options[mySelect.options.length] = new Option("Waterville schools",'all=Waterville');
mySelect.options[mySelect.options.length] = new Option(" Orondo School Road schools",'all=_Orondo_School_Road');
mySelect.options[mySelect.options.length] = new Option(" Palisades Rd schools",'all=_Palisades_Rd');
mySelect.options[mySelect.options.length] = new Option(" Rock Island Road schools",'all=_Rock_Island_Road');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Bridgeport[Bridgeport.length] = createMarker(new GPoint(-119.73789978,47.98099899),"
",iconBl);
mySelect.options[mySelect.options.length] = new Option("Bridegport Middle School",'Bridgeport=' + Bridgeport.length);
Bridgeport[Bridgeport.length] = createMarker(new GPoint(-119.67492676,48.00754166),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bridgeport Aurora High School",'Bridgeport=' + Bridgeport.length);
Bridgeport[Bridgeport.length] = createMarker(new GPoint(-119.67403412,48.00584793),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Bridgeport Elementary School",'Bridgeport=' + Bridgeport.length);
Bridgeport[Bridgeport.length] = createMarker(new GPoint(-119.67425537,48.00597763),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bridgeport High School",'Bridgeport=' + Bridgeport.length);
East_Wenatchee[East_Wenatchee.length] = createMarker(new GPoint(-120.27721405,47.40893173),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Canyon View Group Home",'East_Wenatchee=' + East_Wenatchee.length);
East_Wenatchee[East_Wenatchee.length] = createMarker(new GPoint(-120.29230499,47.44296646),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Cascade Elementary School",'East_Wenatchee=' + East_Wenatchee.length);
East_Wenatchee[East_Wenatchee.length] = createMarker(new GPoint(-120.25675100,47.39855100),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Clovis Point Intermediate School",'East_Wenatchee=' + East_Wenatchee.length);
East_Wenatchee[East_Wenatchee.length] = createMarker(new GPoint(-120.28869629,47.41690445),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Eastmont Junior High School",'East_Wenatchee=' + East_Wenatchee.length);
East_Wenatchee[East_Wenatchee.length] = createMarker(new GPoint(-120.27352905,47.40963745),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Eastmont Senior High School",'East_Wenatchee=' + East_Wenatchee.length);
East_Wenatchee[East_Wenatchee.length] = createMarker(new GPoint(-120.26462555,47.40393066),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Grant Elementary School",'East_Wenatchee=' + East_Wenatchee.length);
East_Wenatchee[East_Wenatchee.length] = createMarker(new GPoint(-120.26527405,47.41403580),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Kenroy Elementary School",'East_Wenatchee=' + East_Wenatchee.length);
Mansfield[Mansfield.length] = createMarker(new GPoint(-119.48459625,47.89490128),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mansfield Elementary High School",'Mansfield=' + Mansfield.length);
_Orondo_School_Road[_Orondo_School_Road.length] = createMarker(new GPoint(-120.15260315,47.76119995),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Orondo Elementary School",'_Orondo_School_Road=' + _Orondo_School_Road.length);
_Palisades_Rd[_Palisades_Rd.length] = createMarker(new GPoint(-119.96254730,47.36500168),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Palisades Elementary School",'_Palisades_Rd=' + _Palisades_Rd.length);
East_Wenatchee[East_Wenatchee.length] = createMarker(new GPoint(-120.29214478,47.42697906),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Robert E Lee Elementary School",'East_Wenatchee=' + East_Wenatchee.length);
_Rock_Island_Road[_Rock_Island_Road.length] = createMarker(new GPoint(-120.15596771,47.37704086),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Rock Island Elementary School",'_Rock_Island_Road=' + _Rock_Island_Road.length);
East_Wenatchee[East_Wenatchee.length] = createMarker(new GPoint(-120.26950073,47.41414261),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Sterling Middle School",'East_Wenatchee=' + East_Wenatchee.length);
Waterville[Waterville.length] = createMarker(new GPoint(-120.06979370,47.64546204),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Waterville Elementary School",'Waterville=' + Waterville.length);
Waterville[Waterville.length] = createMarker(new GPoint(-120.06979370,47.64546204),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Waterville High School",'Waterville=' + Waterville.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(Bridgeport);
map.removeOverlays(East_Wenatchee);
map.removeOverlays(Mansfield);
map.removeOverlays(Waterville);
map.removeOverlays(_Orondo_School_Road);
map.removeOverlays(_Palisades_Rd);
map.removeOverlays(_Rock_Island_Road);
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(Bridgeport);map.removeOverlays(Bridgeport);
map.removeOverlays(East_Wenatchee);
map.removeOverlays(Mansfield);
map.removeOverlays(Waterville);
map.removeOverlays(_Orondo_School_Road);
map.removeOverlays(_Palisades_Rd);
map.removeOverlays(_Rock_Island_Road);
map.addOverlays(Bridgeport);
centerByArray(Bridgeport, false, false);
cntMarker += Bridgeport.length;
map.addOverlays(East_Wenatchee);
centerByArray(East_Wenatchee, false, false);
cntMarker += East_Wenatchee.length;
map.addOverlays(Mansfield);
centerByArray(Mansfield, false, false);
cntMarker += Mansfield.length;
map.addOverlays(Waterville);
centerByArray(Waterville, false, false);
cntMarker += Waterville.length;
map.addOverlays(_Orondo_School_Road);
centerByArray(_Orondo_School_Road, false, false);
cntMarker += _Orondo_School_Road.length;
map.addOverlays(_Palisades_Rd);
centerByArray(_Palisades_Rd, false, false);
cntMarker += _Palisades_Rd.length;
map.addOverlays(_Rock_Island_Road);
centerByArray(_Rock_Island_Road, false, false);
cntMarker += _Rock_Island_Road.length;
centerByArray(Bridgeport,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');
}
}