function addMarkers(){ mySelect = document.getElementById('selection'); Chelsea = [];Randolph = [];East_Randolph = [];Newbury = [];Thetford = [];mySelect.options[mySelect.options.length] = new Option("Chelsea schools",'all=Chelsea'); mySelect.options[mySelect.options.length] = new Option("East Randolph schools",'all=East_Randolph'); mySelect.options[mySelect.options.length] = new Option("Newbury schools",'all=Newbury'); mySelect.options[mySelect.options.length] = new Option("Randolph schools",'all=Randolph'); mySelect.options[mySelect.options.length] = new Option("Thetford schools",'all=Thetford'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Chelsea[Chelsea.length] = createMarker(new GPoint(-72.46080000,43.99180000),"
Brewster D Martin Learning Center
Po Box 127 Main Street
Chelsea, VT 05038
All-boys school, 3-8
[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Brewster D Martin Learning Center",'Chelsea=' + Chelsea.length); Randolph[Randolph.length] = createMarker(new GPoint(-72.66720000,43.94880000),"
Christ Covenant School Of Rand
Po Box 39
Randolph, VT 05060
Co-ed school, 1-9
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Christ Covenant School Of Rand",'Randolph=' + Randolph.length); East_Randolph[East_Randolph.length] = createMarker(new GPoint(-72.55028500,43.95227900),"
East Valley Academy
Po Box 237
East Randolph, VT 05041
Co-ed school, 2-10
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("East Valley Academy",'East_Randolph=' + East_Randolph.length); Randolph[Randolph.length] = createMarker(new GPoint(-72.63394200,43.94097000),"
Justin Morgan Christian School
106 Hebard Hill Road
Randolph, VT 05060
Co-ed school, 1-9
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Justin Morgan Christian School",'Randolph=' + Randolph.length); Newbury[Newbury.length] = createMarker(new GPoint(-72.09760000,44.08270000),"
Newbury Christian School
Po Box 170 Cross Street
Newbury, VT 05051
Co-ed school, K-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Newbury Christian School",'Newbury=' + Newbury.length); Thetford[Thetford.length] = createMarker(new GPoint(-72.22640000,43.81970000),"
Open Fields School
Po Box 53
Thetford, VT 05074
Co-ed school, K-6
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Open Fields School",'Thetford=' + Thetford.length); Chelsea[Chelsea.length] = createMarker(new GPoint(-72.46080000,43.99180000),"
Wellspring School, Inc.
Po Box 291
Chelsea, VT 05038
Co-ed school, PK-6
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Wellspring School, Inc.",'Chelsea=' + Chelsea.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/////1/' + showArray); map.removeOverlays(Chelsea); map.removeOverlays(East_Randolph); map.removeOverlays(Newbury); map.removeOverlays(Randolph); map.removeOverlays(Thetford); 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(Chelsea);map.removeOverlays(Chelsea); map.removeOverlays(East_Randolph); map.removeOverlays(Newbury); map.removeOverlays(Randolph); map.removeOverlays(Thetford); map.addOverlays(Chelsea); centerByArray(Chelsea, false, false); cntMarker += Chelsea.length; map.addOverlays(East_Randolph); centerByArray(East_Randolph, false, false); cntMarker += East_Randolph.length; map.addOverlays(Newbury); centerByArray(Newbury, false, false); cntMarker += Newbury.length; map.addOverlays(Randolph); centerByArray(Randolph, false, false); cntMarker += Randolph.length; map.addOverlays(Thetford); centerByArray(Thetford, false, false); cntMarker += Thetford.length; centerByArray(Chelsea,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=1&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; }