function addMarkers() { mySelect = document.getElementById('selection'); Celestine = [];Dubois = [];Jasper = [];Ferdinand = [];Holland = [];Huntingburg = [];Ireland = [];Birdseye = [];Saint_Anthony = [];mySelect.options[mySelect.options.length] = new Option("Birdseye schools",'all=Birdseye'); mySelect.options[mySelect.options.length] = new Option("Celestine schools",'all=Celestine'); mySelect.options[mySelect.options.length] = new Option("Dubois schools",'all=Dubois'); mySelect.options[mySelect.options.length] = new Option("Ferdinand schools",'all=Ferdinand'); mySelect.options[mySelect.options.length] = new Option("Holland schools",'all=Holland'); mySelect.options[mySelect.options.length] = new Option("Huntingburg schools",'all=Huntingburg'); mySelect.options[mySelect.options.length] = new Option("Ireland schools",'all=Ireland'); mySelect.options[mySelect.options.length] = new Option("Jasper schools",'all=Jasper'); mySelect.options[mySelect.options.length] = new Option("Saint Anthony schools",'all=Saint_Anthony'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Celestine[Celestine.length] = createMarker(new GPoint(-86.77861023,38.38373566),"
",iconRd); mySelect.options[mySelect.options.length] = new Option("Celestine Elementary School",'Celestine=' + Celestine.length); Dubois[Dubois.length] = createMarker(new GPoint(-86.80177307,38.44336319),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Dubois Elementary School",'Dubois=' + Dubois.length); Dubois[Dubois.length] = createMarker(new GPoint(-86.80287170,38.44673157),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Dubois Middle School",'Dubois=' + Dubois.length); Jasper[Jasper.length] = createMarker(new GPoint(-86.94097900,38.38610077),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Dubois-spencer-perry Exc Coop",'Jasper=' + Jasper.length); Ferdinand[Ferdinand.length] = createMarker(new GPoint(-86.85968781,38.22231293),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Ferdinand Elementary School",'Ferdinand=' + Ferdinand.length); Jasper[Jasper.length] = createMarker(new GPoint(-86.94017792,38.39056778),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Fifth Street Elementary School",'Jasper=' + Jasper.length); Ferdinand[Ferdinand.length] = createMarker(new GPoint(-86.85842133,38.22706985),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Forest Park Junior Senior High School",'Ferdinand=' + Ferdinand.length); Holland[Holland.length] = createMarker(new GPoint(-87.03607178,38.24454117),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Holland Elementary School",'Holland=' + Holland.length); Huntingburg[Huntingburg.length] = createMarker(new GPoint(-86.96794891,38.27661896),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Huntingburg Elementary School",'Huntingburg=' + Huntingburg.length); Ireland[Ireland.length] = createMarker(new GPoint(-86.99920654,38.41463089),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Ireland Elementary School",'Ireland=' + Ireland.length); Jasper[Jasper.length] = createMarker(new GPoint(-86.95172119,38.40111923),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Jasper High School",'Jasper=' + Jasper.length); Jasper[Jasper.length] = createMarker(new GPoint(-86.93416595,38.39159775),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Jasper Middle School",'Jasper=' + Jasper.length); Dubois[Dubois.length] = createMarker(new GPoint(-86.79670715,38.44897842),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Northeast Dubois High School",'Dubois=' + Dubois.length); Birdseye[Birdseye.length] = createMarker(new GPoint(-86.76505280,38.31510925),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Pine Ridge Elementary School",'Birdseye=' + Birdseye.length); Saint_Anthony[Saint_Anthony.length] = createMarker(new GPoint(-86.82632446,38.31513596),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Saint Anthony Elementary School",'Saint_Anthony=' + Saint_Anthony.length); Huntingburg[Huntingburg.length] = createMarker(new GPoint(-86.95556641,38.28564453),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Southridge High School",'Huntingburg=' + Huntingburg.length); Huntingburg[Huntingburg.length] = createMarker(new GPoint(-86.95556641,38.28564072),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Southridge Middle School",'Huntingburg=' + Huntingburg.length); Jasper[Jasper.length] = createMarker(new GPoint(-86.93372345,38.39453506),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Tenth Street School",'Jasper=' + Jasper.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(Birdseye); map.removeOverlays(Celestine); map.removeOverlays(Dubois); map.removeOverlays(Ferdinand); map.removeOverlays(Holland); map.removeOverlays(Huntingburg); map.removeOverlays(Ireland); map.removeOverlays(Jasper); map.removeOverlays(Saint_Anthony); 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(Celestine);map.removeOverlays(Birdseye); map.removeOverlays(Celestine); map.removeOverlays(Dubois); map.removeOverlays(Ferdinand); map.removeOverlays(Holland); map.removeOverlays(Huntingburg); map.removeOverlays(Ireland); map.removeOverlays(Jasper); map.removeOverlays(Saint_Anthony); map.addOverlays(Birdseye); centerByArray(Birdseye, false, false); cntMarker += Birdseye.length; map.addOverlays(Celestine); centerByArray(Celestine, false, false); cntMarker += Celestine.length; map.addOverlays(Dubois); centerByArray(Dubois, false, false); cntMarker += Dubois.length; map.addOverlays(Ferdinand); centerByArray(Ferdinand, false, false); cntMarker += Ferdinand.length; map.addOverlays(Holland); centerByArray(Holland, false, false); cntMarker += Holland.length; map.addOverlays(Huntingburg); centerByArray(Huntingburg, false, false); cntMarker += Huntingburg.length; map.addOverlays(Ireland); centerByArray(Ireland, false, false); cntMarker += Ireland.length; map.addOverlays(Jasper); centerByArray(Jasper, false, false); cntMarker += Jasper.length; map.addOverlays(Saint_Anthony); centerByArray(Saint_Anthony, false, false); cntMarker += Saint_Anthony.length; centerByArray(Celestine,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'); } }