function addMarkers(){
mySelect = document.getElementById('selection');
Pasadena = [];El_Paso = [];Houston = [];Webster = [];Abilene = [];Katy = [];Big_Spring = [];Marble_Falls = [];Spring = [];Ft_Worth = [];Lewisville = [];The_Woodlands = [];mySelect.options[mySelect.options.length] = new Option("Abilene schools",'all=Abilene');
mySelect.options[mySelect.options.length] = new Option("Big Spring schools",'all=Big_Spring');
mySelect.options[mySelect.options.length] = new Option("El Paso schools",'all=El_Paso');
mySelect.options[mySelect.options.length] = new Option("Ft Worth schools",'all=Ft_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("Lewisville schools",'all=Lewisville');
mySelect.options[mySelect.options.length] = new Option("Marble Falls schools",'all=Marble_Falls');
mySelect.options[mySelect.options.length] = new Option("Pasadena schools",'all=Pasadena');
mySelect.options[mySelect.options.length] = new Option("Spring schools",'all=Spring');
mySelect.options[mySelect.options.length] = new Option("The Woodlands schools",'all=The_Woodlands');
mySelect.options[mySelect.options.length] = new Option("Webster schools",'all=Webster');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Pasadena[Pasadena.length] = createMarker(new GPoint(-95.21059900,29.68993700),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Agape Christian Academy",'Pasadena=' + Pasadena.length);
El_Paso[El_Paso.length] = createMarker(new GPoint(-106.53842300,31.85917000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Ascension Lutheran Day School",'El_Paso=' + El_Paso.length);
Houston[Houston.length] = createMarker(new GPoint(-95.41739900,29.70594600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Beresford School",'Houston=' + Houston.length);
Webster[Webster.length] = createMarker(new GPoint(-95.12251200,29.53659400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Bruk Academy Of Developmen",'Webster=' + Webster.length);
Houston[Houston.length] = createMarker(new GPoint(-95.41012500,29.70526200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Children's Hour Montessori",'Houston=' + Houston.length);
Houston[Houston.length] = createMarker(new GPoint(-95.36643400,29.74883600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Crayon Club",'Houston=' + Houston.length);
Houston[Houston.length] = createMarker(new GPoint(-95.64590000,29.69190000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("God's Rainbow Christian Academy",'Houston=' + Houston.length);
Abilene[Abilene.length] = createMarker(new GPoint(-99.74783600,32.42558500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Happy Days School",'Abilene=' + Abilene.length);
Houston[Houston.length] = createMarker(new GPoint(-95.29103100,29.88323700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Helon's Academy",'Houston=' + Houston.length);
Houston[Houston.length] = createMarker(new GPoint(-95.38905900,29.73051200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Joy School",'Houston=' + Houston.length);
Houston[Houston.length] = createMarker(new GPoint(-95.51659700,29.70199400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Kids Arena Montessori School",'Houston=' + Houston.length);
Houston[Houston.length] = createMarker(new GPoint(-95.21188600,29.80570200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Kingdom Kids",'Houston=' + Houston.length);
Houston[Houston.length] = createMarker(new GPoint(-95.60583100,29.74599000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Memorial School Of The Oaks",'Houston=' + Houston.length);
Houston[Houston.length] = createMarker(new GPoint(-95.32719900,29.77126300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Neighborhood Educational Cen",'Houston=' + Houston.length);
Katy[Katy.length] = createMarker(new GPoint(-95.75164000,29.78944800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("New Hope Child Dev Center",'Katy=' + Katy.length);
Houston[Houston.length] = createMarker(new GPoint(-95.42984100,29.74325700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. John's Upper",'Houston=' + Houston.length);
Big_Spring[Big_Spring.length] = createMarker(new GPoint(-101.48070900,32.23667700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Mary's Episcopal School",'Big_Spring=' + Big_Spring.length);
Houston[Houston.length] = createMarker(new GPoint(-95.38887500,29.72640100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Paul School",'Houston=' + Houston.length);
Marble_Falls[Marble_Falls.length] = createMarker(new GPoint(-98.34676800,30.60157500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Peters Lutheran Presch & Kindergarten",'Marble_Falls=' + Marble_Falls.length);
Spring[Spring.length] = createMarker(new GPoint(-95.43855600,30.03928100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("School In The Pines",'Spring=' + Spring.length);
Ft_Worth[Ft_Worth.length] = createMarker(new GPoint(-97.37025800,32.74692800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Trinity Lutheran Childrens Center",'Ft_Worth=' + Ft_Worth.length);
Lewisville[Lewisville.length] = createMarker(new GPoint(-97.00504400,33.04653700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Windmill Private School",'Lewisville=' + Lewisville.length);
The_Woodlands[The_Woodlands.length] = createMarker(new GPoint(-95.46590000,30.14170000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Woodlands School For Young Scholars",'The_Woodlands=' + The_Woodlands.length);
map.removeOverlays(Abilene);
map.removeOverlays(Big_Spring);
map.removeOverlays(El_Paso);
map.removeOverlays(Ft_Worth);
map.removeOverlays(Houston);
map.removeOverlays(Katy);
map.removeOverlays(Lewisville);
map.removeOverlays(Marble_Falls);
map.removeOverlays(Pasadena);
map.removeOverlays(Spring);
map.removeOverlays(The_Woodlands);
map.removeOverlays(Webster);
setTimeout(function(){map.addOverlays(Abilene)},1000);
setTimeout(function(){map.addOverlays(Big_Spring)},1000);
setTimeout(function(){map.addOverlays(El_Paso)},1000);
setTimeout(function(){map.addOverlays(Ft_Worth)},1000);
setTimeout(function(){map.addOverlays(Houston)},1000);
setTimeout(function(){map.addOverlays(Katy)},1000);
setTimeout(function(){map.addOverlays(Lewisville)},1000);
setTimeout(function(){map.addOverlays(Marble_Falls)},1000);
setTimeout(function(){map.addOverlays(Pasadena)},1000);
setTimeout(function(){map.addOverlays(Spring)},1000);
setTimeout(function(){map.addOverlays(The_Woodlands)},1000);
setTimeout(function(){map.addOverlays(Webster)},1000);
maxLng = -95.12251200;
maxLat = 33.04653700;
minLng = -106.53842300;
minLat = 29.53659400;
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(Abilene);
map.removeOverlays(Big_Spring);
map.removeOverlays(El_Paso);
map.removeOverlays(Ft_Worth);
map.removeOverlays(Houston);
map.removeOverlays(Katy);
map.removeOverlays(Lewisville);
map.removeOverlays(Marble_Falls);
map.removeOverlays(Pasadena);
map.removeOverlays(Spring);
map.removeOverlays(The_Woodlands);
map.removeOverlays(Webster);
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(Pasadena);map.removeOverlays(Abilene);
map.removeOverlays(Big_Spring);
map.removeOverlays(El_Paso);
map.removeOverlays(Ft_Worth);
map.removeOverlays(Houston);
map.removeOverlays(Katy);
map.removeOverlays(Lewisville);
map.removeOverlays(Marble_Falls);
map.removeOverlays(Pasadena);
map.removeOverlays(Spring);
map.removeOverlays(The_Woodlands);
map.removeOverlays(Webster);
map.addOverlays(Abilene);
centerByArray(Abilene, false, false);
cntMarker += Abilene.length;
map.addOverlays(Big_Spring);
centerByArray(Big_Spring, false, false);
cntMarker += Big_Spring.length;
map.addOverlays(El_Paso);
centerByArray(El_Paso, false, false);
cntMarker += El_Paso.length;
map.addOverlays(Ft_Worth);
centerByArray(Ft_Worth, false, false);
cntMarker += Ft_Worth.length;
map.addOverlays(Houston);
centerByArray(Houston, false, false);
cntMarker += Houston.length;
map.addOverlays(Katy);
centerByArray(Katy, false, false);
cntMarker += Katy.length;
map.addOverlays(Lewisville);
centerByArray(Lewisville, false, false);
cntMarker += Lewisville.length;
map.addOverlays(Marble_Falls);
centerByArray(Marble_Falls, false, false);
cntMarker += Marble_Falls.length;
map.addOverlays(Pasadena);
centerByArray(Pasadena, false, false);
cntMarker += Pasadena.length;
map.addOverlays(Spring);
centerByArray(Spring, false, false);
cntMarker += Spring.length;
map.addOverlays(The_Woodlands);
centerByArray(The_Woodlands, false, false);
cntMarker += The_Woodlands.length;
map.addOverlays(Webster);
centerByArray(Webster, false, false);
cntMarker += Webster.length;
centerByArray(Pasadena,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///34915,27382,26483,27745,27427,26534,27633,34915,26636,26714,26840,26403,27591,26980,26422,27047,27106,27382,27463,27110,27776,27471,26483,27276,27609,27719,/all');
//window.open('/map.php?type=2&schools=34915,27382,26483,27745,27427,26534,27633,34915,26636,26714,26840,26403,27591,26980,26422,27047,27106,27382,27463,27110,27776,27471,26483,27276,27609,27719,&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;
}