function addMarkers(){ mySelect = document.getElementById('selection'); San_Antonio = [];Grapevine = [];Houston = [];Farmers_Branch = [];Victoria = [];Tyler = [];Fort_Worth = [];Plano = [];Dallas = [];Corpus_Christi = [];mySelect.options[mySelect.options.length] = new Option("Corpus Christi schools",'all=Corpus_Christi'); mySelect.options[mySelect.options.length] = new Option("Dallas schools",'all=Dallas'); mySelect.options[mySelect.options.length] = new Option("Farmers Branch schools",'all=Farmers_Branch'); mySelect.options[mySelect.options.length] = new Option("Fort Worth schools",'all=Fort_Worth'); mySelect.options[mySelect.options.length] = new Option("Grapevine schools",'all=Grapevine'); mySelect.options[mySelect.options.length] = new Option("Houston schools",'all=Houston'); mySelect.options[mySelect.options.length] = new Option("Plano schools",'all=Plano'); mySelect.options[mySelect.options.length] = new Option("San Antonio schools",'all=San_Antonio'); mySelect.options[mySelect.options.length] = new Option("Tyler schools",'all=Tyler'); mySelect.options[mySelect.options.length] = new Option("Victoria schools",'all=Victoria'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); San_Antonio[San_Antonio.length] = createMarker(new GPoint(-98.52605700,29.52222300),"
Antonian College Prep
6425 West Avenue
San Antonio, TX 78213
Co-ed school, 9-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Antonian College Prep",'San_Antonio=' + San_Antonio.length); Grapevine[Grapevine.length] = createMarker(new GPoint(-97.09994300,32.89647600),"
Holy Trinity Catholic School
3750 William D Tate Avenue
Grapevine, TX 76051
Co-ed school, PK-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Holy Trinity Catholic School",'Grapevine=' + Grapevine.length); Houston[Houston.length] = createMarker(new GPoint(-95.63359200,29.76185700),"
John Paul II Catholic School
1400 Parkway Plaza Drive
Houston, TX 77077
Co-ed school, PK-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("John Paul II Catholic School",'Houston=' + Houston.length); Farmers_Branch[Farmers_Branch.length] = createMarker(new GPoint(-96.88506100,32.93660700),"
Mary Immaculate Elementary School
14032 Dennis Lane
Farmers Branch, TX 75234
Co-ed school, K-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Mary Immaculate Elementary School",'Farmers_Branch=' + Farmers_Branch.length); Victoria[Victoria.length] = createMarker(new GPoint(-96.99215300,28.82467400),"
Our Lady Of Victory School
1311 E Mesquite Lane
Victoria, TX 77901
Co-ed school, PK-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Our Lady Of Victory School",'Victoria=' + Victoria.length); Tyler[Tyler.length] = createMarker(new GPoint(-95.30193700,32.34496300),"
St. Gregory School
500 S College Avenue
Tyler, TX 75702
Co-ed school, PK-5
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("St. Gregory School",'Tyler=' + Tyler.length); Fort_Worth[Fort_Worth.length] = createMarker(new GPoint(-97.21895300,32.82393700),"
St. John The Apostle Catholic
7421 Glenview Drive
Fort Worth, TX 76180
Co-ed school, PK-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("St. John The Apostle Catholic",'Fort_Worth=' + Fort_Worth.length); Plano[Plano.length] = createMarker(new GPoint(-96.71667300,33.01712800),"
St. Mark Catholic School
1201 Alma Drive
Plano, TX 75075
Co-ed school, K-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("St. Mark Catholic School",'Plano=' + Plano.length); Dallas[Dallas.length] = createMarker(new GPoint(-96.84051100,32.88013800),"
St. Monica Catholic School
4140 Walnut Hill Lane
Dallas, TX 75229
Co-ed school, PK-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("St. Monica Catholic School",'Dallas=' + Dallas.length); Corpus_Christi[Corpus_Christi.length] = createMarker(new GPoint(-97.36422200,27.71908600),"
St. Pius X School
737 Saint Pius Drive
Corpus Christi, TX 78412
Co-ed school, PK-6
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("St. Pius X School",'Corpus_Christi=' + Corpus_Christi.length); map.removeOverlays(Corpus_Christi); map.removeOverlays(Dallas); map.removeOverlays(Farmers_Branch); map.removeOverlays(Fort_Worth); map.removeOverlays(Grapevine); map.removeOverlays(Houston); map.removeOverlays(Plano); map.removeOverlays(San_Antonio); map.removeOverlays(Tyler); map.removeOverlays(Victoria); setTimeout(function(){map.addOverlays(Corpus_Christi)},1000); setTimeout(function(){map.addOverlays(Dallas)},1000); setTimeout(function(){map.addOverlays(Farmers_Branch)},1000); setTimeout(function(){map.addOverlays(Fort_Worth)},1000); setTimeout(function(){map.addOverlays(Grapevine)},1000); setTimeout(function(){map.addOverlays(Houston)},1000); setTimeout(function(){map.addOverlays(Plano)},1000); setTimeout(function(){map.addOverlays(San_Antonio)},1000); setTimeout(function(){map.addOverlays(Tyler)},1000); setTimeout(function(){map.addOverlays(Victoria)},1000); maxLng = -95.30193700; maxLat = 33.01712800; minLng = -98.52605700; minLat = 27.71908600; 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(Dallas); map.removeOverlays(Farmers_Branch); map.removeOverlays(Fort_Worth); map.removeOverlays(Grapevine); map.removeOverlays(Houston); map.removeOverlays(Plano); map.removeOverlays(San_Antonio); map.removeOverlays(Tyler); map.removeOverlays(Victoria); 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(San_Antonio);map.removeOverlays(Corpus_Christi); map.removeOverlays(Dallas); map.removeOverlays(Farmers_Branch); map.removeOverlays(Fort_Worth); map.removeOverlays(Grapevine); map.removeOverlays(Houston); map.removeOverlays(Plano); map.removeOverlays(San_Antonio); map.removeOverlays(Tyler); map.removeOverlays(Victoria); map.addOverlays(Corpus_Christi); centerByArray(Corpus_Christi, false, false); cntMarker += Corpus_Christi.length; map.addOverlays(Dallas); centerByArray(Dallas, false, false); cntMarker += Dallas.length; map.addOverlays(Farmers_Branch); centerByArray(Farmers_Branch, false, false); cntMarker += Farmers_Branch.length; map.addOverlays(Fort_Worth); centerByArray(Fort_Worth, false, false); cntMarker += Fort_Worth.length; map.addOverlays(Grapevine); centerByArray(Grapevine, false, false); cntMarker += Grapevine.length; map.addOverlays(Houston); centerByArray(Houston, false, false); cntMarker += Houston.length; map.addOverlays(Plano); centerByArray(Plano, false, false); cntMarker += Plano.length; map.addOverlays(San_Antonio); centerByArray(San_Antonio, false, false); cntMarker += San_Antonio.length; map.addOverlays(Tyler); centerByArray(Tyler, false, false); cntMarker += Tyler.length; map.addOverlays(Victoria); centerByArray(Victoria, false, false); cntMarker += Victoria.length; centerByArray(San_Antonio,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///26525,27410,27448,27034,26966,27482,27363,27520,26920,27158,/all'); //window.open('/map.php?type=2&schools=26525,27410,27448,27034,26966,27482,27363,27520,26920,27158,&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; }