function addMarkers() { mySelect = document.getElementById('selection'); Basehor = [];Brooklyn = [];Martinsville = [];Eminence = [];Monrovia = [];Mooresville = [];Camby = [];Paragon = [];mySelect.options[mySelect.options.length] = new Option("Basehor schools",'all=Basehor'); mySelect.options[mySelect.options.length] = new Option("Brooklyn schools",'all=Brooklyn'); mySelect.options[mySelect.options.length] = new Option("Camby schools",'all=Camby'); mySelect.options[mySelect.options.length] = new Option("Eminence schools",'all=Eminence'); mySelect.options[mySelect.options.length] = new Option("Martinsville schools",'all=Martinsville'); mySelect.options[mySelect.options.length] = new Option("Monrovia schools",'all=Monrovia'); mySelect.options[mySelect.options.length] = new Option("Mooresville schools",'all=Mooresville'); mySelect.options[mySelect.options.length] = new Option("Paragon schools",'all=Paragon'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Basehor[Basehor.length] = createMarker(new GPoint(-94.93650055,39.14310074),"
",iconGr); mySelect.options[mySelect.options.length] = new Option("Basehor-linwood Virtual Charter",'Basehor=' + Basehor.length); Brooklyn[Brooklyn.length] = createMarker(new GPoint(-86.36924744,39.54241943),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Brooklyn Elementary School",'Brooklyn=' + Brooklyn.length); Martinsville[Martinsville.length] = createMarker(new GPoint(-86.39331818,39.51478958),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Centerton Elementary School",'Martinsville=' + Martinsville.length); Martinsville[Martinsville.length] = createMarker(new GPoint(-86.41470337,39.44200134),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Central Elementary School",'Martinsville=' + Martinsville.length); Martinsville[Martinsville.length] = createMarker(new GPoint(-86.41228485,39.42483902),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Charles L Smith Elementary School",'Martinsville=' + Martinsville.length); Eminence[Eminence.length] = createMarker(new GPoint(-86.64305115,39.52117157),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Eminence Elementary School",'Eminence=' + Eminence.length); Eminence[Eminence.length] = createMarker(new GPoint(-86.64305115,39.52117157),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Eminence High School",'Eminence=' + Eminence.length); Martinsville[Martinsville.length] = createMarker(new GPoint(-86.31289673,39.46540070),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Green Township Elementary School",'Martinsville=' + Martinsville.length); Martinsville[Martinsville.length] = createMarker(new GPoint(-86.41354370,39.42009354),"",iconGr); mySelect.options[mySelect.options.length] = new Option("H Robert Hammons School",'Martinsville=' + Martinsville.length); Monrovia[Monrovia.length] = createMarker(new GPoint(-86.48230743,39.57888031),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Hall Elementary School",'Monrovia=' + Monrovia.length); Martinsville[Martinsville.length] = createMarker(new GPoint(-86.41120148,39.42480850),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Martinsville East Middle School",'Martinsville=' + Martinsville.length); Martinsville[Martinsville.length] = createMarker(new GPoint(-86.41354370,39.42009354),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Martinsville High School",'Martinsville=' + Martinsville.length); Martinsville[Martinsville.length] = createMarker(new GPoint(-86.42995453,39.42046356),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Martinsville West Middle School",'Martinsville=' + Martinsville.length); Monrovia[Monrovia.length] = createMarker(new GPoint(-86.51280212,39.56320190),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Monrovia Elementary School",'Monrovia=' + Monrovia.length); Monrovia[Monrovia.length] = createMarker(new GPoint(-86.51280212,39.56320190),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Monrovia Junior Senior High School",'Monrovia=' + Monrovia.length); Monrovia[Monrovia.length] = createMarker(new GPoint(-86.48001400,39.57776700),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Monrovia Middle School",'Monrovia=' + Monrovia.length); Mooresville[Mooresville.length] = createMarker(new GPoint(-86.37517548,39.61973572),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Mooresville High School",'Mooresville=' + Mooresville.length); Mooresville[Mooresville.length] = createMarker(new GPoint(-86.37490082,39.61278152),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Neil Armstrong Elementary School",'Mooresville=' + Mooresville.length); Mooresville[Mooresville.length] = createMarker(new GPoint(-86.38033295,39.61487579),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Newby Memorial Elementary School",'Mooresville=' + Mooresville.length); Camby[Camby.length] = createMarker(new GPoint(-86.28910065,39.61113739),"",iconRd); mySelect.options[mySelect.options.length] = new Option("North Madison Elementary School",'Camby=' + Camby.length); Mooresville[Mooresville.length] = createMarker(new GPoint(-86.37517548,39.62060928),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Northwood Elementary School",'Mooresville=' + Mooresville.length); Paragon[Paragon.length] = createMarker(new GPoint(-86.57620239,39.40069962),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Paragon Elementary School",'Paragon=' + Paragon.length); Mooresville[Mooresville.length] = createMarker(new GPoint(-86.37864685,39.61793900),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Paul Hadley Middle School",'Mooresville=' + Mooresville.length); Martinsville[Martinsville.length] = createMarker(new GPoint(-86.42626953,39.41380310),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Poston Road Elementary School",'Martinsville=' + Martinsville.length); Martinsville[Martinsville.length] = createMarker(new GPoint(-86.40734863,39.39501953),"",iconRd); mySelect.options[mySelect.options.length] = new Option("South Elementary School",'Martinsville=' + Martinsville.length); Martinsville[Martinsville.length] = createMarker(new GPoint(-86.41470337,39.44200134),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Waverly Elementary School",'Martinsville=' + Martinsville.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(Basehor); map.removeOverlays(Brooklyn); map.removeOverlays(Camby); map.removeOverlays(Eminence); map.removeOverlays(Martinsville); map.removeOverlays(Monrovia); map.removeOverlays(Mooresville); map.removeOverlays(Paragon); 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(Basehor);map.removeOverlays(Basehor); map.removeOverlays(Brooklyn); map.removeOverlays(Camby); map.removeOverlays(Eminence); map.removeOverlays(Martinsville); map.removeOverlays(Monrovia); map.removeOverlays(Mooresville); map.removeOverlays(Paragon); map.addOverlays(Basehor); centerByArray(Basehor, false, false); cntMarker += Basehor.length; map.addOverlays(Brooklyn); centerByArray(Brooklyn, false, false); cntMarker += Brooklyn.length; map.addOverlays(Camby); centerByArray(Camby, false, false); cntMarker += Camby.length; map.addOverlays(Eminence); centerByArray(Eminence, false, false); cntMarker += Eminence.length; map.addOverlays(Martinsville); centerByArray(Martinsville, false, false); cntMarker += Martinsville.length; map.addOverlays(Monrovia); centerByArray(Monrovia, false, false); cntMarker += Monrovia.length; map.addOverlays(Mooresville); centerByArray(Mooresville, false, false); cntMarker += Mooresville.length; map.addOverlays(Paragon); centerByArray(Paragon, false, false); cntMarker += Paragon.length; centerByArray(Basehor,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'); } }