function addMarkers(){
mySelect = document.getElementById('selection');
Sugar_Land = [];Stafford = [];Richmond = [];Katy = [];Missouri_City = [];Houston = [];Rosenberg = [];Fresno = [];Simonton = [];mySelect.options[mySelect.options.length] = new Option("Fresno schools",'all=Fresno');
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("Missouri City schools",'all=Missouri_City');
mySelect.options[mySelect.options.length] = new Option("Richmond schools",'all=Richmond');
mySelect.options[mySelect.options.length] = new Option("Rosenberg schools",'all=Rosenberg');
mySelect.options[mySelect.options.length] = new Option("Simonton schools",'all=Simonton');
mySelect.options[mySelect.options.length] = new Option("Stafford schools",'all=Stafford');
mySelect.options[mySelect.options.length] = new Option("Sugar Land schools",'all=Sugar_Land');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Sugar_Land[Sugar_Land.length] = createMarker(new GPoint(-95.61885700,29.62845200),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("1st United Methd Ch School Little",'Sugar_Land=' + Sugar_Land.length);
Stafford[Stafford.length] = createMarker(new GPoint(-95.56543900,29.64592000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Baker's Preparatory School",'Stafford=' + Stafford.length);
Stafford[Stafford.length] = createMarker(new GPoint(-95.52728900,29.60864500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bearrington Academy for Success and Excellence",'Stafford=' + Stafford.length);
Richmond[Richmond.length] = createMarker(new GPoint(-95.76617700,29.57590100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Calvary Episcopal School, Inc.",'Richmond=' + Richmond.length);
Sugar_Land[Sugar_Land.length] = createMarker(new GPoint(-95.66221400,29.60744200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cambridge Montessori School",'Sugar_Land=' + Sugar_Land.length);
Katy[Katy.length] = createMarker(new GPoint(-95.76765600,29.73466300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Children's Lighthouse",'Katy=' + Katy.length);
Sugar_Land[Sugar_Land.length] = createMarker(new GPoint(-95.60371500,29.57350500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Christ Church School",'Sugar_Land=' + Sugar_Land.length);
Missouri_City[Missouri_City.length] = createMarker(new GPoint(-95.52032900,29.57996000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Christian Bible Academy",'Missouri_City=' + Missouri_City.length);
Katy[Katy.length] = createMarker(new GPoint(-95.76846300,29.74639900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cinco Ranch Montessori",'Katy=' + Katy.length);
Sugar_Land[Sugar_Land.length] = createMarker(new GPoint(-95.63715900,29.59648000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cornerstone Christian Academy",'Sugar_Land=' + Sugar_Land.length);
Sugar_Land[Sugar_Land.length] = createMarker(new GPoint(-95.61796600,29.66478300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Dar Ul Arqam School",'Sugar_Land=' + Sugar_Land.length);
Missouri_City[Missouri_City.length] = createMarker(new GPoint(-95.56439900,29.60537000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("East Wind Christian Academy",'Missouri_City=' + Missouri_City.length);
Missouri_City[Missouri_City.length] = createMarker(new GPoint(-95.54180000,29.54820000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Excel Adventist Academy",'Missouri_City=' + Missouri_City.length);
Sugar_Land[Sugar_Land.length] = createMarker(new GPoint(-95.63500900,29.61107200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Faith Lutheran School",'Sugar_Land=' + Sugar_Land.length);
Sugar_Land[Sugar_Land.length] = createMarker(new GPoint(-95.59371800,29.59344800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("First Colony Montessori",'Sugar_Land=' + Sugar_Land.length);
Sugar_Land[Sugar_Land.length] = createMarker(new GPoint(-95.60496100,29.59135200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("First Colony Montessori South",'Sugar_Land=' + Sugar_Land.length);
Sugar_Land[Sugar_Land.length] = createMarker(new GPoint(-95.61597200,29.63081700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Fort Bend Baptist Academy",'Sugar_Land=' + Sugar_Land.length);
Houston[Houston.length] = createMarker(new GPoint(-95.60144500,29.66105200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Fort Bend Montessori School",'Houston=' + Houston.length);
Sugar_Land[Sugar_Land.length] = createMarker(new GPoint(-95.61471200,29.65157400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("God's Rainbow Christian Academy",'Sugar_Land=' + Sugar_Land.length);
Missouri_City[Missouri_City.length] = createMarker(new GPoint(-95.52682400,29.60653800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Good News Christian Academy",'Missouri_City=' + Missouri_City.length);
Richmond[Richmond.length] = createMarker(new GPoint(-95.65594100,29.68434700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Grand Parkway Christian Academy",'Richmond=' + Richmond.length);
Rosenberg[Rosenberg.length] = createMarker(new GPoint(-95.81765700,29.55376100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Holy Rosary Catholic School",'Rosenberg=' + Rosenberg.length);
Sugar_Land[Sugar_Land.length] = createMarker(new GPoint(-95.62906700,29.57578900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Honor Roll School Ii",'Sugar_Land=' + Sugar_Land.length);
Stafford[Stafford.length] = createMarker(new GPoint(-95.56942900,29.63601500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Houston Learning Academy",'Stafford=' + Stafford.length);
Sugar_Land[Sugar_Land.length] = createMarker(new GPoint(-95.62443100,29.63130900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Kent Academy Inc",'Sugar_Land=' + Sugar_Land.length);
Fresno[Fresno.length] = createMarker(new GPoint(-95.47914700,29.51655500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Kidacious Academy",'Fresno=' + Fresno.length);
Katy[Katy.length] = createMarker(new GPoint(-95.75596600,29.73373400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Learning Center The",'Katy=' + Katy.length);
Stafford[Stafford.length] = createMarker(new GPoint(-95.58233600,29.63305700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Learning Stages",'Stafford=' + Stafford.length);
Missouri_City[Missouri_City.length] = createMarker(new GPoint(-95.53588500,29.61661700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lil' Harvard First Step Private Learning Center",'Missouri_City=' + Missouri_City.length);
Missouri_City[Missouri_City.length] = createMarker(new GPoint(-95.58098800,29.60080500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Little Wonders Learning Center",'Missouri_City=' + Missouri_City.length);
Rosenberg[Rosenberg.length] = createMarker(new GPoint(-95.77685000,29.54276000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Living Water College Preparatory",'Rosenberg=' + Rosenberg.length);
Missouri_City[Missouri_City.length] = createMarker(new GPoint(-95.56452100,29.60199400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Methodist Day School",'Missouri_City=' + Missouri_City.length);
Sugar_Land[Sugar_Land.length] = createMarker(new GPoint(-95.68545000,29.56071800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Montessori-greatwood",'Sugar_Land=' + Sugar_Land.length);
Stafford[Stafford.length] = createMarker(new GPoint(-95.56548400,29.64425900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("New Beginnings Academy",'Stafford=' + Stafford.length);
Missouri_City[Missouri_City.length] = createMarker(new GPoint(-95.56439900,29.60537000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("New Millennium Montessori School",'Missouri_City=' + Missouri_City.length);
Sugar_Land[Sugar_Land.length] = createMarker(new GPoint(-95.60708100,29.65307500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("New Southwest Montessori Center",'Sugar_Land=' + Sugar_Land.length);
Missouri_City[Missouri_City.length] = createMarker(new GPoint(-95.55244100,29.58310000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Oak Point Academy Montessori",'Missouri_City=' + Missouri_City.length);
Sugar_Land[Sugar_Land.length] = createMarker(new GPoint(-95.64342900,29.67325000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Park Point Montessori",'Sugar_Land=' + Sugar_Land.length);
Sugar_Land[Sugar_Land.length] = createMarker(new GPoint(-95.58476800,29.57813600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Primrose School First Colony",'Sugar_Land=' + Sugar_Land.length);
Sugar_Land[Sugar_Land.length] = createMarker(new GPoint(-95.68635500,29.56150200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Primrose School Of Greatwood",'Sugar_Land=' + Sugar_Land.length);
Sugar_Land[Sugar_Land.length] = createMarker(new GPoint(-95.63127300,29.57548100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Riverbend Montessori School",'Sugar_Land=' + Sugar_Land.length);
Sugar_Land[Sugar_Land.length] = createMarker(new GPoint(-95.61034100,29.57929500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Laurence Catholic School",'Sugar_Land=' + Sugar_Land.length);
Richmond[Richmond.length] = createMarker(new GPoint(-95.76128400,29.57950800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Shady Oak Christian School",'Richmond=' + Richmond.length);
Simonton[Simonton.length] = createMarker(new GPoint(-95.97698400,29.67549800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Simonton Christian Academy",'Simonton=' + Simonton.length);
Missouri_City[Missouri_City.length] = createMarker(new GPoint(-95.57104700,29.58263700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Southminster School",'Missouri_City=' + Missouri_City.length);
Richmond[Richmond.length] = createMarker(new GPoint(-95.76154900,29.58215900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St John's Methodist School For Little Children",'Richmond=' + Richmond.length);
Stafford[Stafford.length] = createMarker(new GPoint(-95.58243900,29.61872500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sugar Creek Montessori School",'Stafford=' + Stafford.length);
Stafford[Stafford.length] = createMarker(new GPoint(-95.57975800,29.64719000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sugar Grove Christian School",'Stafford=' + Stafford.length);
Sugar_Land[Sugar_Land.length] = createMarker(new GPoint(-95.63743800,29.63305400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sugar Mill Montessori School",'Sugar_Land=' + Sugar_Land.length);
Missouri_City[Missouri_City.length] = createMarker(new GPoint(-95.54675900,29.54271000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Tree Of Life Christian Academy",'Missouri_City=' + Missouri_City.length);
Sugar_Land[Sugar_Land.length] = createMarker(new GPoint(-95.61579700,29.59404600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Trent InternationalE School",'Sugar_Land=' + Sugar_Land.length);
Stafford[Stafford.length] = createMarker(new GPoint(-95.55733400,29.61480200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Willowridge Day Care & Learning Center",'Stafford=' + Stafford.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(Fresno);
map.removeOverlays(Houston);
map.removeOverlays(Katy);
map.removeOverlays(Missouri_City);
map.removeOverlays(Richmond);
map.removeOverlays(Rosenberg);
map.removeOverlays(Simonton);
map.removeOverlays(Stafford);
map.removeOverlays(Sugar_Land);
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(Sugar_Land);map.removeOverlays(Fresno);
map.removeOverlays(Houston);
map.removeOverlays(Katy);
map.removeOverlays(Missouri_City);
map.removeOverlays(Richmond);
map.removeOverlays(Rosenberg);
map.removeOverlays(Simonton);
map.removeOverlays(Stafford);
map.removeOverlays(Sugar_Land);
map.addOverlays(Fresno);
centerByArray(Fresno, false, false);
cntMarker += Fresno.length;
map.addOverlays(Houston);
centerByArray(Houston, false, false);
cntMarker += Houston.length;
map.addOverlays(Katy);
centerByArray(Katy, false, false);
cntMarker += Katy.length;
map.addOverlays(Missouri_City);
centerByArray(Missouri_City, false, false);
cntMarker += Missouri_City.length;
map.addOverlays(Richmond);
centerByArray(Richmond, false, false);
cntMarker += Richmond.length;
map.addOverlays(Rosenberg);
centerByArray(Rosenberg, false, false);
cntMarker += Rosenberg.length;
map.addOverlays(Simonton);
centerByArray(Simonton, false, false);
cntMarker += Simonton.length;
map.addOverlays(Stafford);
centerByArray(Stafford, false, false);
cntMarker += Stafford.length;
map.addOverlays(Sugar_Land);
centerByArray(Sugar_Land, false, false);
cntMarker += Sugar_Land.length;
centerByArray(Sugar_Land,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;
}