function addMarkers() { mySelect = document.getElementById('selection'); Sandstone = [];Finlayson = [];Hinckley = [];Pine_City = [];Willow_River = [];mySelect.options[mySelect.options.length] = new Option("Finlayson schools",'all=Finlayson'); mySelect.options[mySelect.options.length] = new Option("Hinckley schools",'all=Hinckley'); mySelect.options[mySelect.options.length] = new Option("Pine City schools",'all=Pine_City'); mySelect.options[mySelect.options.length] = new Option("Sandstone schools",'all=Sandstone'); mySelect.options[mySelect.options.length] = new Option("Willow River schools",'all=Willow_River'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Sandstone[Sandstone.length] = createMarker(new GPoint(-92.86498260,46.13776398),"
Crossroads Alc High School
130 Oriole Avenue E
Sandstone, MN 55072

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Crossroads Alc High School",'Sandstone=' + Sandstone.length); Finlayson[Finlayson.length] = createMarker(new GPoint(-92.72740173,46.11809921),"
East Central Elementary School
61085 State Highway 23
Finlayson, MN 55735

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("East Central Elementary School",'Finlayson=' + Finlayson.length); Finlayson[Finlayson.length] = createMarker(new GPoint(-92.75180054,46.19919968),"
East Central Middle School
61085 State Highway 23
Finlayson, MN 55735

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("East Central Middle School",'Finlayson=' + Finlayson.length); Finlayson[Finlayson.length] = createMarker(new GPoint(-92.72740173,46.11809921),"
East Central Senior High School
61085 State Highway 23
Finlayson, MN 55735

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("East Central Senior High School",'Finlayson=' + Finlayson.length); Finlayson[Finlayson.length] = createMarker(new GPoint(-92.92309570,46.20203781),"
Finlayson Elementary School
2159 Highway 18
Finlayson, MN 55735

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Finlayson Elementary School",'Finlayson=' + Finlayson.length); Hinckley[Hinckley.length] = createMarker(new GPoint(-92.87960052,46.01929855),"
Hinckley Elementary School
Box 308
Hinckley, MN 55037

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Hinckley Elementary School",'Hinckley=' + Hinckley.length); Hinckley[Hinckley.length] = createMarker(new GPoint(-92.87960052,46.01929855),"
Hinckley-finlayson Secondary School
Box 308
Hinckley, MN 55037

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Hinckley-finlayson Secondary School",'Hinckley=' + Hinckley.length); Pine_City[Pine_City.length] = createMarker(new GPoint(-92.97039795,45.81949997),"
Pine City Alc High School
1400 Main St. S.
Pine City, MN 55063

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Pine City Alc High School",'Pine_City=' + Pine_City.length); Pine_City[Pine_City.length] = createMarker(new GPoint(-92.97189331,45.82326126),"
Pine City Elementary School
700 6th Avenue Sw
Pine City, MN 55063

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Pine City Elementary School",'Pine_City=' + Pine_City.length); Pine_City[Pine_City.length] = createMarker(new GPoint(-92.97044900,45.82810500),"
Pine City Secondary
1400 Main Street S
Pine City, MN 55063

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Pine City Secondary",'Pine_City=' + Pine_City.length); Pine_City[Pine_City.length] = createMarker(new GPoint(-92.97039795,45.81949997),"
Pine City Secondary School
1400 Main Street S
Pine City, MN 55063

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Pine City Secondary School",'Pine_City=' + Pine_City.length); Pine_City[Pine_City.length] = createMarker(new GPoint(-92.96679687,45.82749939),"
Pine City Ts
1400 Main St. S.
Pine City, MN 55063

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Pine City Ts",'Pine_City=' + Pine_City.length); Willow_River[Willow_River.length] = createMarker(new GPoint(-92.82879639,46.29940033),"
Willow River Alp High School
Box 66, 8142 Pine St.
Willow River, MN 55795

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Willow River Alp High School",'Willow_River=' + Willow_River.length); Willow_River[Willow_River.length] = createMarker(new GPoint(-92.82879639,46.29940033),"
Willow River Elementary School
Box 66
Willow River, MN 55795

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Willow River Elementary School",'Willow_River=' + Willow_River.length); Willow_River[Willow_River.length] = createMarker(new GPoint(-92.82879639,46.29940033),"
Willow River Secondary School
Box 66
Willow River, MN 55795

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Willow River Secondary School",'Willow_River=' + Willow_River.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(Finlayson); map.removeOverlays(Hinckley); map.removeOverlays(Pine_City); map.removeOverlays(Sandstone); map.removeOverlays(Willow_River); 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(Sandstone);map.removeOverlays(Finlayson); map.removeOverlays(Hinckley); map.removeOverlays(Pine_City); map.removeOverlays(Sandstone); map.removeOverlays(Willow_River); map.addOverlays(Finlayson); centerByArray(Finlayson, false, false); cntMarker += Finlayson.length; map.addOverlays(Hinckley); centerByArray(Hinckley, false, false); cntMarker += Hinckley.length; map.addOverlays(Pine_City); centerByArray(Pine_City, false, false); cntMarker += Pine_City.length; map.addOverlays(Sandstone); centerByArray(Sandstone, false, false); cntMarker += Sandstone.length; map.addOverlays(Willow_River); centerByArray(Willow_River, false, false); cntMarker += Willow_River.length; centerByArray(Sandstone,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'); } }