function addMarkers(){ mySelect = document.getElementById('selection'); Hot_Springs = [];Freeman = [];Ipswich = [];Mitchell = [];Rapid_City = [];Sioux_Falls = [];Pine_Ridge = [];Dell_Rapids = [];Madison = [];Iroquois = [];mySelect.options[mySelect.options.length] = new Option("Dell Rapids schools",'all=Dell_Rapids'); mySelect.options[mySelect.options.length] = new Option("Freeman schools",'all=Freeman'); mySelect.options[mySelect.options.length] = new Option("Hot Springs schools",'all=Hot_Springs'); mySelect.options[mySelect.options.length] = new Option("Ipswich schools",'all=Ipswich'); mySelect.options[mySelect.options.length] = new Option("Iroquois schools",'all=Iroquois'); mySelect.options[mySelect.options.length] = new Option("Madison schools",'all=Madison'); mySelect.options[mySelect.options.length] = new Option("Mitchell schools",'all=Mitchell'); mySelect.options[mySelect.options.length] = new Option("Pine Ridge schools",'all=Pine_Ridge'); mySelect.options[mySelect.options.length] = new Option("Rapid City schools",'all=Rapid_City'); mySelect.options[mySelect.options.length] = new Option("Sioux Falls schools",'all=Sioux_Falls'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Hot_Springs[Hot_Springs.length] = createMarker(new GPoint(-103.47960700,43.42756300),"
Bethesda Lutheran School
1537 Baltimore Ave
Hot Springs, SD 57747
Co-ed school, K-5
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Bethesda Lutheran School",'Hot_Springs=' + Hot_Springs.length); Freeman[Freeman.length] = createMarker(new GPoint(-97.46850000,43.34460000),"
Freeman Academy
Po Box 1000
Freeman, SD 57029
Co-ed school, 5-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Freeman Academy",'Freeman=' + Freeman.length); Ipswich[Ipswich.length] = createMarker(new GPoint(-98.94590000,45.43200000),"
Holy Cross Elementary School
Po Box 324
Ipswich, SD 57451
Co-ed school, PK-6
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Holy Cross Elementary School",'Ipswich=' + Ipswich.length); Mitchell[Mitchell.length] = createMarker(new GPoint(-98.04610800,43.70343700),"
John Paul Ii Elementary School
1510 West Elm Street
Mitchell, SD 57301
Co-ed school, PK-6
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("John Paul Ii Elementary School",'Mitchell=' + Mitchell.length); Rapid_City[Rapid_City.length] = createMarker(new GPoint(-103.21460000,44.07980000),"
Life Tree Montessori School
Po Box 7534
Rapid City, SD 57709
Co-ed school, PK-KG
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Life Tree Montessori School",'Rapid_City=' + Rapid_City.length); Sioux_Falls[Sioux_Falls.length] = createMarker(new GPoint(-96.76115200,43.51661600),"
O'Gorman High School
3201 S Kiwanis Avenue
Sioux Falls, SD 57105
Co-ed school, 9-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("O'Gorman High School",'Sioux_Falls=' + Sioux_Falls.length); Pine_Ridge[Pine_Ridge.length] = createMarker(new GPoint(-102.69170000,43.25320000),"
Red Cloud Elementary School
100 Mission Drive
Pine Ridge, SD 57770
Co-ed school, PK-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Red Cloud Elementary School",'Pine_Ridge=' + Pine_Ridge.length); Pine_Ridge[Pine_Ridge.length] = createMarker(new GPoint(-102.69170000,43.25320000),"
Red Cloud High School
100 Mission Drive
Pine Ridge, SD 57770
Co-ed school, 9-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Red Cloud High School",'Pine_Ridge=' + Pine_Ridge.length); Sioux_Falls[Sioux_Falls.length] = createMarker(new GPoint(-96.67129700,43.53826700),"
Sioux Falls Christian Schools
6120 S Charger Avenue
Sioux Falls, SD 57108
Co-ed school, PK-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Sioux Falls Christian Schools",'Sioux_Falls=' + Sioux_Falls.length); Sioux_Falls[Sioux_Falls.length] = createMarker(new GPoint(-96.72905500,43.51863700),"
Sioux Falls Lutheran School
308 W 37th Street
Sioux Falls, SD 57105
Co-ed school, PK-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Sioux Falls Lutheran School",'Sioux_Falls=' + Sioux_Falls.length); Sioux_Falls[Sioux_Falls.length] = createMarker(new GPoint(-96.68124200,43.53829600),"
St Lambert Elementary School
1000 S Bahnson Avenue
Sioux Falls, SD 57103
Co-ed school, PK-6
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("St Lambert Elementary School",'Sioux_Falls=' + Sioux_Falls.length); Dell_Rapids[Dell_Rapids.length] = createMarker(new GPoint(-96.70818200,43.82740400),"
St Mary Catholic School
812 State Avenue
Dell Rapids, SD 57022
Co-ed school, PK-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("St Mary Catholic School",'Dell_Rapids=' + Dell_Rapids.length); Madison[Madison.length] = createMarker(new GPoint(-97.11559000,44.00834600),"
St Thomas School
401 N Van Eps Avenue
Madison, SD 57042
Co-ed school, PK-5
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("St Thomas School",'Madison=' + Madison.length); Iroquois[Iroquois.length] = createMarker(new GPoint(-97.83853400,44.46726500),"
Sunny Plains Christian School
403 School Street
Iroquois, SD 57353
Co-ed school, 1-7
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Sunny Plains Christian School",'Iroquois=' + Iroquois.length); Rapid_City[Rapid_City.length] = createMarker(new GPoint(-103.24595300,44.03908300),"
Zion Lutheran School
4550 S Highway 16
Rapid City, SD 57701
Co-ed school, PK-5
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Zion Lutheran School",'Rapid_City=' + Rapid_City.length); map.removeOverlays(Dell_Rapids); map.removeOverlays(Freeman); map.removeOverlays(Hot_Springs); map.removeOverlays(Ipswich); map.removeOverlays(Iroquois); map.removeOverlays(Madison); map.removeOverlays(Mitchell); map.removeOverlays(Pine_Ridge); map.removeOverlays(Rapid_City); map.removeOverlays(Sioux_Falls); setTimeout(function(){map.addOverlays(Dell_Rapids)},1000); setTimeout(function(){map.addOverlays(Freeman)},1000); setTimeout(function(){map.addOverlays(Hot_Springs)},1000); setTimeout(function(){map.addOverlays(Ipswich)},1000); setTimeout(function(){map.addOverlays(Iroquois)},1000); setTimeout(function(){map.addOverlays(Madison)},1000); setTimeout(function(){map.addOverlays(Mitchell)},1000); setTimeout(function(){map.addOverlays(Pine_Ridge)},1000); setTimeout(function(){map.addOverlays(Rapid_City)},1000); setTimeout(function(){map.addOverlays(Sioux_Falls)},1000); maxLng = -96.67129700; maxLat = 45.43200000; minLng = -103.47960700; minLat = 43.25320000; 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(Dell_Rapids); map.removeOverlays(Freeman); map.removeOverlays(Hot_Springs); map.removeOverlays(Ipswich); map.removeOverlays(Iroquois); map.removeOverlays(Madison); map.removeOverlays(Mitchell); map.removeOverlays(Pine_Ridge); map.removeOverlays(Rapid_City); map.removeOverlays(Sioux_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(Hot_Springs);map.removeOverlays(Dell_Rapids); map.removeOverlays(Freeman); map.removeOverlays(Hot_Springs); map.removeOverlays(Ipswich); map.removeOverlays(Iroquois); map.removeOverlays(Madison); map.removeOverlays(Mitchell); map.removeOverlays(Pine_Ridge); map.removeOverlays(Rapid_City); map.removeOverlays(Sioux_Falls); map.addOverlays(Dell_Rapids); centerByArray(Dell_Rapids, false, false); cntMarker += Dell_Rapids.length; map.addOverlays(Freeman); centerByArray(Freeman, false, false); cntMarker += Freeman.length; map.addOverlays(Hot_Springs); centerByArray(Hot_Springs, false, false); cntMarker += Hot_Springs.length; map.addOverlays(Ipswich); centerByArray(Ipswich, false, false); cntMarker += Ipswich.length; map.addOverlays(Iroquois); centerByArray(Iroquois, false, false); cntMarker += Iroquois.length; map.addOverlays(Madison); centerByArray(Madison, false, false); cntMarker += Madison.length; map.addOverlays(Mitchell); centerByArray(Mitchell, false, false); cntMarker += Mitchell.length; map.addOverlays(Pine_Ridge); centerByArray(Pine_Ridge, false, false); cntMarker += Pine_Ridge.length; map.addOverlays(Rapid_City); centerByArray(Rapid_City, false, false); cntMarker += Rapid_City.length; map.addOverlays(Sioux_Falls); centerByArray(Sioux_Falls, false, false); cntMarker += Sioux_Falls.length; centerByArray(Hot_Springs,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///25886,25841,25863,25854,25871,25886,25841,25823,25844,25894,25893,25851,25862,25848,25904,25871,25874,9436,/all'); //window.open('/map.php?type=2&schools=25886,25841,25863,25854,25871,25886,25841,25823,25844,25894,25893,25851,25862,25848,25904,25871,25874,9436,&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; }