function addMarkers(){ mySelect = document.getElementById('selection'); Houston = [];Corpus_Christi = [];Fort_Worth = [];Tyler = [];Lewisville = [];The_Woodlands = [];mySelect.options[mySelect.options.length] = new Option("Corpus Christi schools",'all=Corpus_Christi'); 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("Lewisville schools",'all=Lewisville'); mySelect.options[mySelect.options.length] = new Option("The Woodlands schools",'all=The_Woodlands'); mySelect.options[mySelect.options.length] = new Option("Tyler schools",'all=Tyler'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Houston[Houston.length] = createMarker(new GPoint(-95.59574100,29.74756200),"
The Briarwood School
12207 Whittington Drive
Houston, TX 77077
Co-ed school, K-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("The Briarwood School",'Houston=' + Houston.length); Houston[Houston.length] = createMarker(new GPoint(-95.44435700,29.67389700),"
Cliffwood School
10050 Woodwind Drive
Houston, TX 77025
Co-ed school, 4-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Cliffwood School",'Houston=' + Houston.length); Houston[Houston.length] = createMarker(new GPoint(-95.48515700,29.79146300),"
The Monarch School
1231 Wirt Road
Houston, TX 77055
Co-ed school, K-K
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("The Monarch School",'Houston=' + Houston.length); Corpus_Christi[Corpus_Christi.length] = createMarker(new GPoint(-97.39723600,27.78625400),"
St. James' Episcopal School
602 S Carancahua St
Corpus Christi, TX 78401
Co-ed school, PK-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("St. James' Episcopal School",'Corpus_Christi=' + Corpus_Christi.length); Fort_Worth[Fort_Worth.length] = createMarker(new GPoint(-97.36020000,32.71080000),"
Starpoint School
Tcu Box 297410
Fort Worth, TX 76129
Co-ed school, 1-6
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Starpoint School",'Fort_Worth=' + Fort_Worth.length); Tyler[Tyler.length] = createMarker(new GPoint(-95.25940100,32.31141400),"
Stepping Stone School
3105 University Blvd
Tyler, TX 75701
Co-ed school, PK-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Stepping Stone School",'Tyler=' + Tyler.length); Houston[Houston.length] = createMarker(new GPoint(-95.22795800,29.59626000),"
Sunshine Children's World
11410 Hall Road
Houston, TX 77089
Co-ed school, PK-1
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Sunshine Children's World",'Houston=' + Houston.length); Lewisville[Lewisville.length] = createMarker(new GPoint(-97.00504400,33.04653700),"
Windmill Private School
531 W.main
Lewisville, TX 75057
Co-ed school, PK-1
[ View School Profile ]
",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),"
The Woodlands School For Young Scholars
25162 Grogans Park Drive
The Woodlands, TX 77380
Co-ed school, NS-PK
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("The Woodlands School For Young Scholars",'The_Woodlands=' + The_Woodlands.length); map.removeOverlays(Corpus_Christi); map.removeOverlays(Fort_Worth); map.removeOverlays(Houston); map.removeOverlays(Lewisville); map.removeOverlays(The_Woodlands); map.removeOverlays(Tyler); setTimeout(function(){map.addOverlays(Corpus_Christi)},1000); setTimeout(function(){map.addOverlays(Fort_Worth)},1000); setTimeout(function(){map.addOverlays(Houston)},1000); setTimeout(function(){map.addOverlays(Lewisville)},1000); setTimeout(function(){map.addOverlays(The_Woodlands)},1000); setTimeout(function(){map.addOverlays(Tyler)},1000); maxLng = -95.22795800; maxLat = 33.04653700; minLng = -97.39723600; minLat = 27.78625400; 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(Corpus_Christi); map.removeOverlays(Fort_Worth); map.removeOverlays(Houston); map.removeOverlays(Lewisville); map.removeOverlays(The_Woodlands); map.removeOverlays(Tyler); 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(Houston);map.removeOverlays(Corpus_Christi); map.removeOverlays(Fort_Worth); map.removeOverlays(Houston); map.removeOverlays(Lewisville); map.removeOverlays(The_Woodlands); map.removeOverlays(Tyler); map.addOverlays(Corpus_Christi); centerByArray(Corpus_Christi, false, false); cntMarker += Corpus_Christi.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(Lewisville); centerByArray(Lewisville, false, false); cntMarker += Lewisville.length; map.addOverlays(The_Woodlands); centerByArray(The_Woodlands, false, false); cntMarker += The_Woodlands.length; map.addOverlays(Tyler); centerByArray(Tyler, false, false); cntMarker += Tyler.length; centerByArray(Houston,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///27571,26676,27519,27530,27571,26676,27593,34892,27776,27609,35263,/all'); //window.open('/map.php?type=2&schools=27571,26676,27519,27530,27571,26676,27593,34892,27776,27609,35263,&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; }