function addMarkers(){
mySelect = document.getElementById('selection');
Wichita_Falls = [];Fort_Worth = [];Lancaster = [];Houston = [];West_Columbia = [];Mineral_Wells = [];Longview = [];Victoria = [];Katy = [];Pasadena = [];Seguin = [];Conroe = [];Alvin = [];Brownsville = [];San_Antonio = [];Rowlett = [];Austin = [];mySelect.options[mySelect.options.length] = new Option("Alvin schools",'all=Alvin');
mySelect.options[mySelect.options.length] = new Option("Austin schools",'all=Austin');
mySelect.options[mySelect.options.length] = new Option("Brownsville schools",'all=Brownsville');
mySelect.options[mySelect.options.length] = new Option("Conroe schools",'all=Conroe');
mySelect.options[mySelect.options.length] = new Option("Fort Worth schools",'all=Fort_Worth');
mySelect.options[mySelect.options.length] = new Option("Houston schools",'all=Houston');
mySelect.options[mySelect.options.length] = new Option("Katy schools",'all=Katy');
mySelect.options[mySelect.options.length] = new Option("Lancaster schools",'all=Lancaster');
mySelect.options[mySelect.options.length] = new Option("Longview schools",'all=Longview');
mySelect.options[mySelect.options.length] = new Option("Mineral Wells schools",'all=Mineral_Wells');
mySelect.options[mySelect.options.length] = new Option("Pasadena schools",'all=Pasadena');
mySelect.options[mySelect.options.length] = new Option("Rowlett schools",'all=Rowlett');
mySelect.options[mySelect.options.length] = new Option("San Antonio schools",'all=San_Antonio');
mySelect.options[mySelect.options.length] = new Option("Seguin schools",'all=Seguin');
mySelect.options[mySelect.options.length] = new Option("Victoria schools",'all=Victoria');
mySelect.options[mySelect.options.length] = new Option("West Columbia schools",'all=West_Columbia');
mySelect.options[mySelect.options.length] = new Option("Wichita Falls schools",'all=Wichita_Falls');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Wichita_Falls[Wichita_Falls.length] = createMarker(new GPoint(-98.51956200,33.98923900),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Agape Christian School",'Wichita_Falls=' + Wichita_Falls.length);
Fort_Worth[Fort_Worth.length] = createMarker(new GPoint(-97.26336200,32.67831200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Ambassadors Of Christ Chr. Ac.",'Fort_Worth=' + Fort_Worth.length);
Lancaster[Lancaster.length] = createMarker(new GPoint(-96.77813400,32.61909300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cedar Valley Christian Academy",'Lancaster=' + Lancaster.length);
Houston[Houston.length] = createMarker(new GPoint(-95.15327500,29.57989300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Clear Lake Christian School",'Houston=' + Houston.length);
West_Columbia[West_Columbia.length] = createMarker(new GPoint(-95.65265000,29.14563800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Columbia Christian School",'West_Columbia=' + West_Columbia.length);
Mineral_Wells[Mineral_Wells.length] = createMarker(new GPoint(-98.07758100,32.79033900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Community Christian School",'Mineral_Wells=' + Mineral_Wells.length);
Longview[Longview.length] = createMarker(new GPoint(-94.73050000,32.46280000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("East Texas Christian School",'Longview=' + Longview.length);
Victoria[Victoria.length] = createMarker(new GPoint(-96.98440000,28.95110000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Faith Academy",'Victoria=' + Victoria.length);
Katy[Katy.length] = createMarker(new GPoint(-95.79316800,29.80507800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Faith West Academy",'Katy=' + Katy.length);
Pasadena[Pasadena.length] = createMarker(new GPoint(-95.20916900,29.69401500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("International Harvest Christian Academy",'Pasadena=' + Pasadena.length);
Fort_Worth[Fort_Worth.length] = createMarker(new GPoint(-97.42600200,32.88352600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lake Country Christian School",'Fort_Worth=' + Fort_Worth.length);
Seguin[Seguin.length] = createMarker(new GPoint(-97.91459700,29.53115100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lifegate Christian School",'Seguin=' + Seguin.length);
Conroe[Conroe.length] = createMarker(new GPoint(-95.48509400,30.35939300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lifestyle Christian School",'Conroe=' + Conroe.length);
Alvin[Alvin.length] = createMarker(new GPoint(-95.23097100,29.45232200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Living Stones Christian School",'Alvin=' + Alvin.length);
Brownsville[Brownsville.length] = createMarker(new GPoint(-97.49552900,25.89958500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Livingway Christian School",'Brownsville=' + Brownsville.length);
San_Antonio[San_Antonio.length] = createMarker(new GPoint(-98.61859600,29.40382000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("New Life Christian Academy",'San_Antonio=' + San_Antonio.length);
San_Antonio[San_Antonio.length] = createMarker(new GPoint(-98.50664100,29.50770500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("River City Christian School",'San_Antonio=' + San_Antonio.length);
Rowlett[Rowlett.length] = createMarker(new GPoint(-96.51820400,32.91429100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Rockwall Christian Academy",'Rowlett=' + Rowlett.length);
Austin[Austin.length] = createMarker(new GPoint(-97.69488900,30.45832200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Shoreline Christian School",'Austin=' + Austin.length);
San_Antonio[San_Antonio.length] = createMarker(new GPoint(-98.62256600,29.41723500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sunnybrook Christian Academy",'San_Antonio=' + San_Antonio.length);
map.removeOverlays(Alvin);
map.removeOverlays(Austin);
map.removeOverlays(Brownsville);
map.removeOverlays(Conroe);
map.removeOverlays(Fort_Worth);
map.removeOverlays(Houston);
map.removeOverlays(Katy);
map.removeOverlays(Lancaster);
map.removeOverlays(Longview);
map.removeOverlays(Mineral_Wells);
map.removeOverlays(Pasadena);
map.removeOverlays(Rowlett);
map.removeOverlays(San_Antonio);
map.removeOverlays(Seguin);
map.removeOverlays(Victoria);
map.removeOverlays(West_Columbia);
map.removeOverlays(Wichita_Falls);
setTimeout(function(){map.addOverlays(Alvin)},1000);
setTimeout(function(){map.addOverlays(Austin)},1000);
setTimeout(function(){map.addOverlays(Brownsville)},1000);
setTimeout(function(){map.addOverlays(Conroe)},1000);
setTimeout(function(){map.addOverlays(Fort_Worth)},1000);
setTimeout(function(){map.addOverlays(Houston)},1000);
setTimeout(function(){map.addOverlays(Katy)},1000);
setTimeout(function(){map.addOverlays(Lancaster)},1000);
setTimeout(function(){map.addOverlays(Longview)},1000);
setTimeout(function(){map.addOverlays(Mineral_Wells)},1000);
setTimeout(function(){map.addOverlays(Pasadena)},1000);
setTimeout(function(){map.addOverlays(Rowlett)},1000);
setTimeout(function(){map.addOverlays(San_Antonio)},1000);
setTimeout(function(){map.addOverlays(Seguin)},1000);
setTimeout(function(){map.addOverlays(Victoria)},1000);
setTimeout(function(){map.addOverlays(West_Columbia)},1000);
setTimeout(function(){map.addOverlays(Wichita_Falls)},1000);
maxLng = -94.73050000;
maxLat = 33.98923900;
minLng = -98.62256600;
minLat = 25.89958500;
reCenterMap();
} // 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//////' + showArray);
map.removeOverlays(Alvin);
map.removeOverlays(Austin);
map.removeOverlays(Brownsville);
map.removeOverlays(Conroe);
map.removeOverlays(Fort_Worth);
map.removeOverlays(Houston);
map.removeOverlays(Katy);
map.removeOverlays(Lancaster);
map.removeOverlays(Longview);
map.removeOverlays(Mineral_Wells);
map.removeOverlays(Pasadena);
map.removeOverlays(Rowlett);
map.removeOverlays(San_Antonio);
map.removeOverlays(Seguin);
map.removeOverlays(Victoria);
map.removeOverlays(West_Columbia);
map.removeOverlays(Wichita_Falls);
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(Wichita_Falls);map.removeOverlays(Alvin);
map.removeOverlays(Austin);
map.removeOverlays(Brownsville);
map.removeOverlays(Conroe);
map.removeOverlays(Fort_Worth);
map.removeOverlays(Houston);
map.removeOverlays(Katy);
map.removeOverlays(Lancaster);
map.removeOverlays(Longview);
map.removeOverlays(Mineral_Wells);
map.removeOverlays(Pasadena);
map.removeOverlays(Rowlett);
map.removeOverlays(San_Antonio);
map.removeOverlays(Seguin);
map.removeOverlays(Victoria);
map.removeOverlays(West_Columbia);
map.removeOverlays(Wichita_Falls);
map.addOverlays(Alvin);
centerByArray(Alvin, false, false);
cntMarker += Alvin.length;
map.addOverlays(Austin);
centerByArray(Austin, false, false);
cntMarker += Austin.length;
map.addOverlays(Brownsville);
centerByArray(Brownsville, false, false);
cntMarker += Brownsville.length;
map.addOverlays(Conroe);
centerByArray(Conroe, false, false);
cntMarker += Conroe.length;
map.addOverlays(Fort_Worth);
centerByArray(Fort_Worth, false, false);
cntMarker += Fort_Worth.length;
map.addOverlays(Houston);
centerByArray(Houston, false, false);
cntMarker += Houston.length;
map.addOverlays(Katy);
centerByArray(Katy, false, false);
cntMarker += Katy.length;
map.addOverlays(Lancaster);
centerByArray(Lancaster, false, false);
cntMarker += Lancaster.length;
map.addOverlays(Longview);
centerByArray(Longview, false, false);
cntMarker += Longview.length;
map.addOverlays(Mineral_Wells);
centerByArray(Mineral_Wells, false, false);
cntMarker += Mineral_Wells.length;
map.addOverlays(Pasadena);
centerByArray(Pasadena, false, false);
cntMarker += Pasadena.length;
map.addOverlays(Rowlett);
centerByArray(Rowlett, false, false);
cntMarker += Rowlett.length;
map.addOverlays(San_Antonio);
centerByArray(San_Antonio, false, false);
cntMarker += San_Antonio.length;
map.addOverlays(Seguin);
centerByArray(Seguin, false, false);
cntMarker += Seguin.length;
map.addOverlays(Victoria);
centerByArray(Victoria, false, false);
cntMarker += Victoria.length;
map.addOverlays(West_Columbia);
centerByArray(West_Columbia, false, false);
cntMarker += West_Columbia.length;
map.addOverlays(Wichita_Falls);
centerByArray(Wichita_Falls, false, false);
cntMarker += Wichita_Falls.length;
centerByArray(Wichita_Falls,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///27010,27014,27004,26512,26990,26855,26783,26617,26744,34181,27230,27112,27223,27002,26679,26485,27010,36113,27014,27004,26512,26990,26855,26783,26617,26744,26681,34181,27230,27112,27223,34182,27002,26768,26679,26485,/all');
//window.open('/map.php?type=2&schools=27010,27014,27004,26512,26990,26855,26783,26617,26744,34181,27230,27112,27223,27002,26679,26485,27010,36113,27014,27004,26512,26990,26855,26783,26617,26744,26681,34181,27230,27112,27223,34182,27002,26768,26679,26485,&school_level=&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;
}