function addMarkers(){ mySelect = document.getElementById('selection'); Layton = [];Woods_Cross = [];Farmington = [];Syracuse = [];Centerville = [];Bountiful = [];Kaysville = [];mySelect.options[mySelect.options.length] = new Option("Bountiful schools",'all=Bountiful'); mySelect.options[mySelect.options.length] = new Option("Centerville schools",'all=Centerville'); mySelect.options[mySelect.options.length] = new Option("Farmington schools",'all=Farmington'); mySelect.options[mySelect.options.length] = new Option("Kaysville schools",'all=Kaysville'); mySelect.options[mySelect.options.length] = new Option("Layton schools",'all=Layton'); mySelect.options[mySelect.options.length] = new Option("Syracuse schools",'all=Syracuse'); mySelect.options[mySelect.options.length] = new Option("Woods Cross schools",'all=Woods_Cross'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Layton[Layton.length] = createMarker(new GPoint(-111.97326800,41.09180000),"
Adventures In Learning
2182 N Hillfield Road Suite 4
Layton, UT 84041
Co-ed school, PK-K
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Adventures In Learning",'Layton=' + Layton.length); Woods_Cross[Woods_Cross.length] = createMarker(new GPoint(-111.89528100,40.87706000),"
Benchmark High School
592 W 1350 S
Woods Cross, UT 84010
All-boys school, 8-12
[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Benchmark High School",'Woods_Cross=' + Woods_Cross.length); Farmington[Farmington.length] = createMarker(new GPoint(-111.91004800,40.99880100),"
Challenger School—Farmington
1089 Shepard Creek Parkway
Farmington, UT 84025
Co-ed school, NS-5
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Challenger School—Farmington",'Farmington=' + Farmington.length); Farmington[Farmington.length] = createMarker(new GPoint(-111.91004800,40.99880100),"
Challenger School—Farmington
1089 Shepard Creek Parkway
Farmington, UT 84025
Co-ed school, PK-5
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Challenger School—Farmington",'Farmington=' + Farmington.length); Layton[Layton.length] = createMarker(new GPoint(-111.94987600,41.09453200),"
Faith Baptist Academy
2430 N Fairfield Road
Layton, UT 84041
Co-ed school, PK-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Faith Baptist Academy",'Layton=' + Layton.length); Syracuse[Syracuse.length] = createMarker(new GPoint(-112.07507800,41.07483700),"
Island View School
2650 W 2700 S
Syracuse, UT 84075
Co-ed school, 8-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Island View School",'Syracuse=' + Syracuse.length); Centerville[Centerville.length] = createMarker(new GPoint(-111.88538100,40.92272800),"
Kinder Care
518 N 400 W
Centerville, UT 84014
Co-ed school, PK-K
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Kinder Care",'Centerville=' + Centerville.length); Layton[Layton.length] = createMarker(new GPoint(-111.92012600,41.10628300),"
Layton Christian Academy
2352 East Highway 193
Layton, UT 84040
Co-ed school, PK-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Layton Christian Academy",'Layton=' + Layton.length); Layton[Layton.length] = createMarker(new GPoint(-111.91721500,41.06589900),"
Mills Montessori School
2621 East Oak Hills Drive
Layton, UT 84040
Co-ed school, PK-3
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Mills Montessori School",'Layton=' + Layton.length); Bountiful[Bountiful.length] = createMarker(new GPoint(-111.87636200,40.87132700),"
St. Olaf Catholic School
1793 Orchard Drive
Bountiful, UT 84010
Co-ed school, PK-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("St. Olaf Catholic School",'Bountiful=' + Bountiful.length); Bountiful[Bountiful.length] = createMarker(new GPoint(-111.88541700,40.88891000),"
Sunrise Montessori
43 South 200 West
Bountiful, UT 84010
Co-ed school, PK-6
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Sunrise Montessori",'Bountiful=' + Bountiful.length); Kaysville[Kaysville.length] = createMarker(new GPoint(-111.95730900,41.04174400),"
Time For Families
440 N. 900 W.
Kaysville, UT 84037
Co-ed school, KG-KG
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Time For Families",'Kaysville=' + Kaysville.length); Layton[Layton.length] = createMarker(new GPoint(-111.97259700,41.07056300),"
Trinity Lutheran Preschool And Kindergarten
385 W Golden Avenue
Layton, UT 84041
Co-ed school, PK-K
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Trinity Lutheran Preschool And Kindergarten",'Layton=' + Layton.length); Layton[Layton.length] = createMarker(new GPoint(-111.99068800,41.07159500),"
Wasatch Intermountain Academy
779 N. McCormick Way
Layton, UT 84041
Co-ed school, NS-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Wasatch Intermountain Academy",'Layton=' + Layton.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/////3/' + showArray); map.removeOverlays(Bountiful); map.removeOverlays(Centerville); map.removeOverlays(Farmington); map.removeOverlays(Kaysville); map.removeOverlays(Layton); map.removeOverlays(Syracuse); map.removeOverlays(Woods_Cross); 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(Layton);map.removeOverlays(Bountiful); map.removeOverlays(Centerville); map.removeOverlays(Farmington); map.removeOverlays(Kaysville); map.removeOverlays(Layton); map.removeOverlays(Syracuse); map.removeOverlays(Woods_Cross); map.addOverlays(Bountiful); centerByArray(Bountiful, false, false); cntMarker += Bountiful.length; map.addOverlays(Centerville); centerByArray(Centerville, false, false); cntMarker += Centerville.length; map.addOverlays(Farmington); centerByArray(Farmington, false, false); cntMarker += Farmington.length; map.addOverlays(Kaysville); centerByArray(Kaysville, false, false); cntMarker += Kaysville.length; map.addOverlays(Layton); centerByArray(Layton, false, false); cntMarker += Layton.length; map.addOverlays(Syracuse); centerByArray(Syracuse, false, false); cntMarker += Syracuse.length; map.addOverlays(Woods_Cross); centerByArray(Woods_Cross, false, false); cntMarker += Woods_Cross.length; centerByArray(Layton,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=3&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; }