function addMarkers(){
mySelect = document.getElementById('selection');
Mission = [];Mcallen = [];Edinburg = [];Palmhurst = [];Pharr = [];Mercedes = [];Weslaco = [];Alamo = [];mySelect.options[mySelect.options.length] = new Option("Alamo schools",'all=Alamo');
mySelect.options[mySelect.options.length] = new Option("Edinburg schools",'all=Edinburg');
mySelect.options[mySelect.options.length] = new Option("Mcallen schools",'all=Mcallen');
mySelect.options[mySelect.options.length] = new Option("Mercedes schools",'all=Mercedes');
mySelect.options[mySelect.options.length] = new Option("Mission schools",'all=Mission');
mySelect.options[mySelect.options.length] = new Option("Palmhurst schools",'all=Palmhurst');
mySelect.options[mySelect.options.length] = new Option("Pharr schools",'all=Pharr');
mySelect.options[mySelect.options.length] = new Option("Weslaco schools",'all=Weslaco');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Mission[Mission.length] = createMarker(new GPoint(-98.29605000,26.22810400),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Agape Christian School",'Mission=' + Mission.length);
Mcallen[Mcallen.length] = createMarker(new GPoint(-98.23381100,26.24084100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Central Christian School",'Mcallen=' + Mcallen.length);
Mcallen[Mcallen.length] = createMarker(new GPoint(-98.25525000,26.24517400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Covenant Christian Academy",'Mcallen=' + Mcallen.length);
Edinburg[Edinburg.length] = createMarker(new GPoint(-98.18921300,26.25695800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Discovery School",'Edinburg=' + Edinburg.length);
Edinburg[Edinburg.length] = createMarker(new GPoint(-98.16296100,26.29623500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Edinburg Christian Learning Center",'Edinburg=' + Edinburg.length);
Palmhurst[Palmhurst.length] = createMarker(new GPoint(-98.28028400,26.24435500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Faith Christian Academy",'Palmhurst=' + Palmhurst.length);
Pharr[Pharr.length] = createMarker(new GPoint(-98.19549300,26.19780800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Grace Christian School",'Pharr=' + Pharr.length);
Mercedes[Mercedes.length] = createMarker(new GPoint(-97.92068000,26.14866300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Immanuel Lutheran School",'Mercedes=' + Mercedes.length);
Weslaco[Weslaco.length] = createMarker(new GPoint(-98.00685200,26.15805900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mid Valley Christian School",'Weslaco=' + Weslaco.length);
Pharr[Pharr.length] = createMarker(new GPoint(-98.20470500,26.17573600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Oratory Schools",'Pharr=' + Pharr.length);
Mcallen[Mcallen.length] = createMarker(new GPoint(-98.23029900,26.21006100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Our Lady Of Sorrows School",'Mcallen=' + Mcallen.length);
Mcallen[Mcallen.length] = createMarker(new GPoint(-98.22128000,26.20184900),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Regional Bible Institute Christian Academy",'Mcallen=' + Mcallen.length);
Edinburg[Edinburg.length] = createMarker(new GPoint(-98.16504800,26.27884500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Matthew's Episcopal School",'Edinburg=' + Edinburg.length);
Mcallen[Mcallen.length] = createMarker(new GPoint(-98.22096900,26.21691000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Paul Lutheran School-McAllen",'Mcallen=' + Mcallen.length);
Weslaco[Weslaco.length] = createMarker(new GPoint(-97.99095200,26.16836800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("San Martin De Porres Catholic School",'Weslaco=' + Weslaco.length);
Mcallen[Mcallen.length] = createMarker(new GPoint(-98.26287000,26.18761000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("South Texas Christian Academy",'Mcallen=' + Mcallen.length);
Mcallen[Mcallen.length] = createMarker(new GPoint(-98.22607800,26.22583300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Johns Episcopal Day School",'Mcallen=' + Mcallen.length);
Edinburg[Edinburg.length] = createMarker(new GPoint(-98.16339400,26.29759100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Joseph Catholic School",'Edinburg=' + Edinburg.length);
Mcallen[Mcallen.length] = createMarker(new GPoint(-98.24258900,26.19563200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Taylor Christian School",'Mcallen=' + Mcallen.length);
Alamo[Alamo.length] = createMarker(new GPoint(-98.12132400,26.19387100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Valley Christian Heritage School",'Alamo=' + Alamo.length);
Weslaco[Weslaco.length] = createMarker(new GPoint(-97.98254200,26.14807000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Valley Grande Adventist Academy",'Weslaco=' + Weslaco.length);
Weslaco[Weslaco.length] = createMarker(new GPoint(-97.99050000,26.15910000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Valley Grande Elementary School",'Weslaco=' + Weslaco.length);
Mission[Mission.length] = createMarker(new GPoint(-98.35442300,26.23407100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("World Center Leadership Academy",'Mission=' + Mission.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,11);
/*
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/////1/' + showArray);
map.removeOverlays(Alamo);
map.removeOverlays(Edinburg);
map.removeOverlays(Mcallen);
map.removeOverlays(Mercedes);
map.removeOverlays(Mission);
map.removeOverlays(Palmhurst);
map.removeOverlays(Pharr);
map.removeOverlays(Weslaco);
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(Mission);map.removeOverlays(Alamo);
map.removeOverlays(Edinburg);
map.removeOverlays(Mcallen);
map.removeOverlays(Mercedes);
map.removeOverlays(Mission);
map.removeOverlays(Palmhurst);
map.removeOverlays(Pharr);
map.removeOverlays(Weslaco);
map.addOverlays(Alamo);
centerByArray(Alamo, false, false);
cntMarker += Alamo.length;
map.addOverlays(Edinburg);
centerByArray(Edinburg, false, false);
cntMarker += Edinburg.length;
map.addOverlays(Mcallen);
centerByArray(Mcallen, false, false);
cntMarker += Mcallen.length;
map.addOverlays(Mercedes);
centerByArray(Mercedes, false, false);
cntMarker += Mercedes.length;
map.addOverlays(Mission);
centerByArray(Mission, false, false);
cntMarker += Mission.length;
map.addOverlays(Palmhurst);
centerByArray(Palmhurst, false, false);
cntMarker += Palmhurst.length;
map.addOverlays(Pharr);
centerByArray(Pharr, false, false);
cntMarker += Pharr.length;
map.addOverlays(Weslaco);
centerByArray(Weslaco, false, false);
cntMarker += Weslaco.length;
centerByArray(Mission,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');
//window.open('/map.php?type=1&schools=&school_level=1&radius=&zipcode=&school_type_search=&school_type_code=');
}
}
function createMarker(point, label, icon)
{
var marker = new GMarker(point, icon);
var html = label;
GEvent.addListener(marker, "click", function() {
marker.openInfoWindowHtml(html);
});
return marker;
}