function addMarkers(){ mySelect = document.getElementById('selection'); Norway = [];Dixfield = [];Bryant_Pond = [];Hebron = [];Fryeburg = [];South_Paris = [];Rumford = [];Sumner = [];mySelect.options[mySelect.options.length] = new Option("Bryant Pond schools",'all=Bryant_Pond'); mySelect.options[mySelect.options.length] = new Option("Dixfield schools",'all=Dixfield'); mySelect.options[mySelect.options.length] = new Option("Fryeburg schools",'all=Fryeburg'); mySelect.options[mySelect.options.length] = new Option("Hebron schools",'all=Hebron'); mySelect.options[mySelect.options.length] = new Option("Norway schools",'all=Norway'); mySelect.options[mySelect.options.length] = new Option("Rumford schools",'all=Rumford'); mySelect.options[mySelect.options.length] = new Option("South Paris schools",'all=South_Paris'); mySelect.options[mySelect.options.length] = new Option("Sumner schools",'all=Sumner'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Norway[Norway.length] = createMarker(new GPoint(-70.53856400,44.21257500),"
Boxberry School
Po Box 2037
Norway, ME 04268
Co-ed school, PK-4
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Boxberry School",'Norway=' + Norway.length); Dixfield[Dixfield.length] = createMarker(new GPoint(-70.42290000,44.55780000),"
Emmanuel Academy
Po Box 661
Dixfield, ME 04224
Co-ed school, K-10
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Emmanuel Academy",'Dixfield=' + Dixfield.length); Bryant_Pond[Bryant_Pond.length] = createMarker(new GPoint(-70.56259900,44.38341800),"
Forestdale Sda School
27 Perkins Valley Road
Bryant Pond, ME 04219
Co-ed school, K-9
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Forestdale Sda School",'Bryant_Pond=' + Bryant_Pond.length); Hebron[Hebron.length] = createMarker(new GPoint(-70.40761400,44.19821800),"
Hebron Academy
Po Box 309
Hebron, ME 04238
Co-ed school, 6-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Hebron Academy",'Hebron=' + Hebron.length); Fryeburg[Fryeburg.length] = createMarker(new GPoint(-70.98510000,44.01620400),"
New Life Christian Academy
8 Drift Road
Fryeburg, ME 04037
Co-ed school, K-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("New Life Christian Academy",'Fryeburg=' + Fryeburg.length); South_Paris[South_Paris.length] = createMarker(new GPoint(-70.50800000,44.23590000),"
Oxford Hills Christian Academy
Po Box 318
South Paris, ME 04281
Co-ed school, K-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Oxford Hills Christian Academy",'South_Paris=' + South_Paris.length); Rumford[Rumford.length] = createMarker(new GPoint(-70.55436100,44.54725500),"
River Valley Christian School
209 Pine Street
Rumford, ME 04276
Co-ed school, 1-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("River Valley Christian School",'Rumford=' + Rumford.length); Rumford[Rumford.length] = createMarker(new GPoint(-70.55536400,44.55305400),"
Roy House-rumford Group Home
160 Lincoln Avenue
Rumford, ME 04276
All-boys school, 5-8
[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Roy House-rumford Group Home",'Rumford=' + Rumford.length); Rumford[Rumford.length] = createMarker(new GPoint(-70.55333400,44.54730800),"
St. Athanasius - St. John Elementary School
115 Maine Avenue
Rumford, ME 04276
Co-ed school, PK-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("St. Athanasius - St. John Elementary School",'Rumford=' + Rumford.length); Sumner[Sumner.length] = createMarker(new GPoint(-70.44309400,44.37219800),"
West Sumner Christian School
854 Main Street
Sumner, ME 04292
Co-ed school, 3-11
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("West Sumner Christian School",'Sumner=' + Sumner.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(Bryant_Pond); map.removeOverlays(Dixfield); map.removeOverlays(Fryeburg); map.removeOverlays(Hebron); map.removeOverlays(Norway); map.removeOverlays(Rumford); map.removeOverlays(South_Paris); map.removeOverlays(Sumner); 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(Norway);map.removeOverlays(Bryant_Pond); map.removeOverlays(Dixfield); map.removeOverlays(Fryeburg); map.removeOverlays(Hebron); map.removeOverlays(Norway); map.removeOverlays(Rumford); map.removeOverlays(South_Paris); map.removeOverlays(Sumner); map.addOverlays(Bryant_Pond); centerByArray(Bryant_Pond, false, false); cntMarker += Bryant_Pond.length; map.addOverlays(Dixfield); centerByArray(Dixfield, false, false); cntMarker += Dixfield.length; map.addOverlays(Fryeburg); centerByArray(Fryeburg, false, false); cntMarker += Fryeburg.length; map.addOverlays(Hebron); centerByArray(Hebron, false, false); cntMarker += Hebron.length; map.addOverlays(Norway); centerByArray(Norway, false, false); cntMarker += Norway.length; map.addOverlays(Rumford); centerByArray(Rumford, false, false); cntMarker += Rumford.length; map.addOverlays(South_Paris); centerByArray(South_Paris, false, false); cntMarker += South_Paris.length; map.addOverlays(Sumner); centerByArray(Sumner, false, false); cntMarker += Sumner.length; centerByArray(Norway,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; }