function addMarkers() { mySelect = document.getElementById('selection'); Waldoboro = [];Boothbay_Hbr = [];Pemaquid = [];Dresden = [];Edgecomb = [];Damariscotta = [];Jefferson = [];Monhegan = [];Nobleboro = [];Somerville = [];South_Bristol = [];Southport = [];Whitefield = [];Wiscasset = [];mySelect.options[mySelect.options.length] = new Option("Boothbay Hbr schools",'all=Boothbay_Hbr'); mySelect.options[mySelect.options.length] = new Option("Damariscotta schools",'all=Damariscotta'); mySelect.options[mySelect.options.length] = new Option("Dresden schools",'all=Dresden'); mySelect.options[mySelect.options.length] = new Option("Edgecomb schools",'all=Edgecomb'); mySelect.options[mySelect.options.length] = new Option("Jefferson schools",'all=Jefferson'); mySelect.options[mySelect.options.length] = new Option("Monhegan schools",'all=Monhegan'); mySelect.options[mySelect.options.length] = new Option("Nobleboro schools",'all=Nobleboro'); mySelect.options[mySelect.options.length] = new Option("Pemaquid schools",'all=Pemaquid'); mySelect.options[mySelect.options.length] = new Option("Somerville schools",'all=Somerville'); mySelect.options[mySelect.options.length] = new Option("South Bristol schools",'all=South_Bristol'); mySelect.options[mySelect.options.length] = new Option("Southport schools",'all=Southport'); mySelect.options[mySelect.options.length] = new Option("Waldoboro schools",'all=Waldoboro'); mySelect.options[mySelect.options.length] = new Option("Whitefield schools",'all=Whitefield'); mySelect.options[mySelect.options.length] = new Option("Wiscasset schools",'all=Wiscasset'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Waldoboro[Waldoboro.length] = createMarker(new GPoint(-69.37560272,44.09774399),"
",iconBl); mySelect.options[mySelect.options.length] = new Option("A D Gray Middle School",'Waldoboro=' + Waldoboro.length); Boothbay_Hbr[Boothbay_Hbr.length] = createMarker(new GPoint(-69.62605286,43.85923004),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Boothbay Region Elementary School",'Boothbay_Hbr=' + Boothbay_Hbr.length); Boothbay_Hbr[Boothbay_Hbr.length] = createMarker(new GPoint(-69.62602997,43.85918808),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Boothbay Region High School",'Boothbay_Hbr=' + Boothbay_Hbr.length); Pemaquid[Pemaquid.length] = createMarker(new GPoint(-69.50408173,43.90176010),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Bristol Consolidated School",'Pemaquid=' + Pemaquid.length); Dresden[Dresden.length] = createMarker(new GPoint(-69.75129700,44.13660049),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Dresden Elementary School",'Dresden=' + Dresden.length); Edgecomb[Edgecomb.length] = createMarker(new GPoint(-69.64624786,43.98527527),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Edgecomb Eddy School",'Edgecomb=' + Edgecomb.length); Damariscotta[Damariscotta.length] = createMarker(new GPoint(-69.50888824,44.04267120),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Great Salt Bay Community School",'Damariscotta=' + Damariscotta.length); Jefferson[Jefferson.length] = createMarker(new GPoint(-69.49849701,44.20230103),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Jefferson Village School",'Jefferson=' + Jefferson.length); Waldoboro[Waldoboro.length] = createMarker(new GPoint(-69.30728149,44.12203217),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Medomak Valley High School",'Waldoboro=' + Waldoboro.length); Waldoboro[Waldoboro.length] = createMarker(new GPoint(-69.42514801,44.10430145),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Miller School",'Waldoboro=' + Waldoboro.length); Monhegan[Monhegan.length] = createMarker(new GPoint(-69.31839752,43.76390076),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Monhegan Island School",'Monhegan=' + Monhegan.length); Nobleboro[Nobleboro.length] = createMarker(new GPoint(-69.47985840,44.08196640),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Nobleboro Central School",'Nobleboro=' + Nobleboro.length); Somerville[Somerville.length] = createMarker(new GPoint(-69.51450348,44.13069916),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Somerville Elementary School",'Somerville=' + Somerville.length); South_Bristol[South_Bristol.length] = createMarker(new GPoint(-69.55659485,43.85943604),"",iconRd); mySelect.options[mySelect.options.length] = new Option("South Bristol Elementary School",'South_Bristol=' + South_Bristol.length); Southport[Southport.length] = createMarker(new GPoint(-69.65789032,43.84099197),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Southport Central School",'Southport=' + Southport.length); Whitefield[Whitefield.length] = createMarker(new GPoint(-69.60363770,44.22360229),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Whitefield Elementary School",'Whitefield=' + Whitefield.length); Wiscasset[Wiscasset.length] = createMarker(new GPoint(-69.67005157,44.02315140),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Wiscasset High School",'Wiscasset=' + Wiscasset.length); Wiscasset[Wiscasset.length] = createMarker(new GPoint(-69.65802765,44.01855087),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Wiscasset Middle School",'Wiscasset=' + Wiscasset.length); Wiscasset[Wiscasset.length] = createMarker(new GPoint(-69.66809082,44.01443863),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Wiscasset Primary School",'Wiscasset=' + Wiscasset.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(Boothbay_Hbr); map.removeOverlays(Damariscotta); map.removeOverlays(Dresden); map.removeOverlays(Edgecomb); map.removeOverlays(Jefferson); map.removeOverlays(Monhegan); map.removeOverlays(Nobleboro); map.removeOverlays(Pemaquid); map.removeOverlays(Somerville); map.removeOverlays(South_Bristol); map.removeOverlays(Southport); map.removeOverlays(Waldoboro); map.removeOverlays(Whitefield); map.removeOverlays(Wiscasset); 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(Waldoboro);map.removeOverlays(Boothbay_Hbr); map.removeOverlays(Damariscotta); map.removeOverlays(Dresden); map.removeOverlays(Edgecomb); map.removeOverlays(Jefferson); map.removeOverlays(Monhegan); map.removeOverlays(Nobleboro); map.removeOverlays(Pemaquid); map.removeOverlays(Somerville); map.removeOverlays(South_Bristol); map.removeOverlays(Southport); map.removeOverlays(Waldoboro); map.removeOverlays(Whitefield); map.removeOverlays(Wiscasset); map.addOverlays(Boothbay_Hbr); centerByArray(Boothbay_Hbr, false, false); cntMarker += Boothbay_Hbr.length; map.addOverlays(Damariscotta); centerByArray(Damariscotta, false, false); cntMarker += Damariscotta.length; map.addOverlays(Dresden); centerByArray(Dresden, false, false); cntMarker += Dresden.length; map.addOverlays(Edgecomb); centerByArray(Edgecomb, false, false); cntMarker += Edgecomb.length; map.addOverlays(Jefferson); centerByArray(Jefferson, false, false); cntMarker += Jefferson.length; map.addOverlays(Monhegan); centerByArray(Monhegan, false, false); cntMarker += Monhegan.length; map.addOverlays(Nobleboro); centerByArray(Nobleboro, false, false); cntMarker += Nobleboro.length; map.addOverlays(Pemaquid); centerByArray(Pemaquid, false, false); cntMarker += Pemaquid.length; map.addOverlays(Somerville); centerByArray(Somerville, false, false); cntMarker += Somerville.length; map.addOverlays(South_Bristol); centerByArray(South_Bristol, false, false); cntMarker += South_Bristol.length; map.addOverlays(Southport); centerByArray(Southport, false, false); cntMarker += Southport.length; map.addOverlays(Waldoboro); centerByArray(Waldoboro, false, false); cntMarker += Waldoboro.length; map.addOverlays(Whitefield); centerByArray(Whitefield, false, false); cntMarker += Whitefield.length; map.addOverlays(Wiscasset); centerByArray(Wiscasset, false, false); cntMarker += Wiscasset.length; centerByArray(Waldoboro,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'); } }