function addMarkers() { mySelect = document.getElementById('selection'); Altamont = [];Duchesne = [];Myton = [];Roosevelt = [];Neola = [];Tabiona = [];mySelect.options[mySelect.options.length] = new Option("Altamont schools",'all=Altamont'); mySelect.options[mySelect.options.length] = new Option("Duchesne schools",'all=Duchesne'); mySelect.options[mySelect.options.length] = new Option("Myton schools",'all=Myton'); mySelect.options[mySelect.options.length] = new Option("Neola schools",'all=Neola'); mySelect.options[mySelect.options.length] = new Option("Roosevelt schools",'all=Roosevelt'); mySelect.options[mySelect.options.length] = new Option("Tabiona schools",'all=Tabiona'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Altamont[Altamont.length] = createMarker(new GPoint(-110.45429993,40.36709976),"
Altamont Elementary School
190 W Main
Altamont, UT 84001

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Altamont Elementary School",'Altamont=' + Altamont.length); Altamont[Altamont.length] = createMarker(new GPoint(-110.45429993,40.36709976),"
Altamont High School
200 W Main
Altamont, UT 84001

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Altamont High School",'Altamont=' + Altamont.length); Duchesne[Duchesne.length] = createMarker(new GPoint(-110.40136400,40.16340400),"
Alternative Packet Program
Po Box 446
Duchesne, UT 84021

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Alternative Packet Program",'Duchesne=' + Duchesne.length); Myton[Myton.length] = createMarker(new GPoint(-110.07180023,40.13769913),"
Con Amore School
P O Box 88
Myton, UT 84052

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Con Amore School",'Myton=' + Myton.length); Roosevelt[Roosevelt.length] = createMarker(new GPoint(-109.97727203,40.29973602),"
Duchesne Adult High School
1100 E Lagoon 124-5
Roosevelt, UT 84066

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Duchesne Adult High School",'Roosevelt=' + Roosevelt.length); Duchesne[Duchesne.length] = createMarker(new GPoint(-110.30149841,40.11859894),"
Duchesne Elementary School
Drawer 370
Duchesne, UT 84021

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Duchesne Elementary School",'Duchesne=' + Duchesne.length); Duchesne[Duchesne.length] = createMarker(new GPoint(-110.30149841,40.11859894),"
Duchesne High School
P.o. Box 330
Duchesne, UT 84021

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Duchesne High School",'Duchesne=' + Duchesne.length); Roosevelt[Roosevelt.length] = createMarker(new GPoint(-109.98101807,40.30456161),"
East Elementary School
700 E 400 N 107-10
Roosevelt, UT 84066

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("East Elementary School",'Roosevelt=' + Roosevelt.length); Myton[Myton.length] = createMarker(new GPoint(-110.07180023,40.13769913),"
Myton Elementary School
P O Box 186
Myton, UT 84052

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Myton Elementary School",'Myton=' + Myton.length); Neola[Neola.length] = createMarker(new GPoint(-110.06079865,40.47639847),"
Neola Elementary School
P O Box 220
Neola, UT 84053

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Neola Elementary School",'Neola=' + Neola.length); Roosevelt[Roosevelt.length] = createMarker(new GPoint(-109.99727631,40.30290985),"
Roosevelt Junior High School
265 N 300 W 425-1
Roosevelt, UT 84066

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Roosevelt Junior High School",'Roosevelt=' + Roosevelt.length); Roosevelt[Roosevelt.length] = createMarker(new GPoint(-109.99727631,40.30533600),"
Roosevelt Middle School
437 N 300 W 425-2
Roosevelt, UT 84066

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Roosevelt Middle School",'Roosevelt=' + Roosevelt.length); Tabiona[Tabiona.length] = createMarker(new GPoint(-110.69770050,40.38420105),"
Tabiona Elementary School
P O Box 470
Tabiona, UT 84072

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Tabiona Elementary School",'Tabiona=' + Tabiona.length); Tabiona[Tabiona.length] = createMarker(new GPoint(-110.69770050,40.38420105),"
Tabiona High School
P O Box 470
Tabiona, UT 84072

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Tabiona High School",'Tabiona=' + Tabiona.length); Roosevelt[Roosevelt.length] = createMarker(new GPoint(-110.12480164,40.38899994),"
Thompsen School
Rt 2 Box 2148
Roosevelt, UT 84066

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Thompsen School",'Roosevelt=' + Roosevelt.length); Roosevelt[Roosevelt.length] = createMarker(new GPoint(-109.97663116,40.30113602),"
Union High School
135 N Union 124-3
Roosevelt, UT 84066

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Union High School",'Roosevelt=' + Roosevelt.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,10); /* 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(Altamont); map.removeOverlays(Duchesne); map.removeOverlays(Myton); map.removeOverlays(Neola); map.removeOverlays(Roosevelt); map.removeOverlays(Tabiona); 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(Altamont);map.removeOverlays(Altamont); map.removeOverlays(Duchesne); map.removeOverlays(Myton); map.removeOverlays(Neola); map.removeOverlays(Roosevelt); map.removeOverlays(Tabiona); map.addOverlays(Altamont); centerByArray(Altamont, false, false); cntMarker += Altamont.length; map.addOverlays(Duchesne); centerByArray(Duchesne, false, false); cntMarker += Duchesne.length; map.addOverlays(Myton); centerByArray(Myton, false, false); cntMarker += Myton.length; map.addOverlays(Neola); centerByArray(Neola, false, false); cntMarker += Neola.length; map.addOverlays(Roosevelt); centerByArray(Roosevelt, false, false); cntMarker += Roosevelt.length; map.addOverlays(Tabiona); centerByArray(Tabiona, false, false); cntMarker += Tabiona.length; centerByArray(Altamont,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'); } }