function addMarkers() { mySelect = document.getElementById('selection'); South_Point = [];Chesapeake = [];Ironton = [];Coal_Grove = [];Proctorville = [];Willow_Wood = [];mySelect.options[mySelect.options.length] = new Option("Chesapeake schools",'all=Chesapeake'); mySelect.options[mySelect.options.length] = new Option("Coal Grove schools",'all=Coal_Grove'); mySelect.options[mySelect.options.length] = new Option("Ironton schools",'all=Ironton'); mySelect.options[mySelect.options.length] = new Option("Proctorville schools",'all=Proctorville'); mySelect.options[mySelect.options.length] = new Option("South Point schools",'all=South_Point'); mySelect.options[mySelect.options.length] = new Option("Willow Wood schools",'all=Willow_Wood'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); South_Point[South_Point.length] = createMarker(new GPoint(-82.55650330,38.43299866),"
",iconRd); mySelect.options[mySelect.options.length] = new Option("Burlington Elementary School",'South_Point=' + South_Point.length); Chesapeake[Chesapeake.length] = createMarker(new GPoint(-82.48378754,38.42256165),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Chesapeake Elementary School",'Chesapeake=' + Chesapeake.length); Chesapeake[Chesapeake.length] = createMarker(new GPoint(-82.48613739,38.42224503),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Chesapeake High School",'Chesapeake=' + Chesapeake.length); Chesapeake[Chesapeake.length] = createMarker(new GPoint(-82.48194885,38.42275620),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Chesapeake Middle School",'Chesapeake=' + Chesapeake.length); Ironton[Ironton.length] = createMarker(new GPoint(-82.58322906,38.50339127),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Dawson-bryant Elementary School",'Ironton=' + Ironton.length); Coal_Grove[Coal_Grove.length] = createMarker(new GPoint(-82.64427185,38.50153732),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Dawson-bryant High School",'Coal_Grove=' + Coal_Grove.length); Coal_Grove[Coal_Grove.length] = createMarker(new GPoint(-82.64427185,38.50153732),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Dawson-bryant Middle School",'Coal_Grove=' + Coal_Grove.length); Proctorville[Proctorville.length] = createMarker(new GPoint(-82.32320404,38.45662308),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Fairland East Elementary School",'Proctorville=' + Proctorville.length); Proctorville[Proctorville.length] = createMarker(new GPoint(-82.36216736,38.44927216),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Fairland High School",'Proctorville=' + Proctorville.length); Proctorville[Proctorville.length] = createMarker(new GPoint(-82.35527039,38.44290924),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Fairland Middle School",'Proctorville=' + Proctorville.length); Proctorville[Proctorville.length] = createMarker(new GPoint(-82.35852051,38.44552612),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Fairland West Elementary School",'Proctorville=' + Proctorville.length); Ironton[Ironton.length] = createMarker(new GPoint(-82.67065430,38.52401733),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Ironton High School",'Ironton=' + Ironton.length); Ironton[Ironton.length] = createMarker(new GPoint(-82.67065430,38.52401733),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Ironton Junior High School",'Ironton=' + Ironton.length); Ironton[Ironton.length] = createMarker(new GPoint(-82.70637512,38.55117035),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Ironton Middle School",'Ironton=' + Ironton.length); Ironton[Ironton.length] = createMarker(new GPoint(-82.68131256,38.53536224),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Kingsbury Elementary School",'Ironton=' + Ironton.length); Chesapeake[Chesapeake.length] = createMarker(new GPoint(-82.47749329,38.49439621),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Lawrence County High School",'Chesapeake=' + Chesapeake.length); Ironton[Ironton.length] = createMarker(new GPoint(-82.67236300,38.47115200),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Rock Hill Child Devlopment Center",'Ironton=' + Ironton.length); Ironton[Ironton.length] = createMarker(new GPoint(-82.65763855,38.61212158),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Rock Hill Elementary School",'Ironton=' + Ironton.length); Ironton[Ironton.length] = createMarker(new GPoint(-82.66340637,38.61401749),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Rock Hill High School",'Ironton=' + Ironton.length); Ironton[Ironton.length] = createMarker(new GPoint(-82.66340637,38.61401749),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Rock Hill Middle School",'Ironton=' + Ironton.length); Ironton[Ironton.length] = createMarker(new GPoint(-82.65789032,38.61236954),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Rock Hill Senior High School",'Ironton=' + Ironton.length); South_Point[South_Point.length] = createMarker(new GPoint(-82.53562927,38.41049957),"",iconRd); mySelect.options[mySelect.options.length] = new Option("South Point Elementary School",'South_Point=' + South_Point.length); South_Point[South_Point.length] = createMarker(new GPoint(-82.58248138,38.42393875),"",iconGr); mySelect.options[mySelect.options.length] = new Option("South Point High School",'South_Point=' + South_Point.length); South_Point[South_Point.length] = createMarker(new GPoint(-82.58221436,38.42243576),"",iconBl); mySelect.options[mySelect.options.length] = new Option("South Point Middle School",'South_Point=' + South_Point.length); Willow_Wood[Willow_Wood.length] = createMarker(new GPoint(-82.48418427,38.60849380),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Symmes Valley Elementary School",'Willow_Wood=' + Willow_Wood.length); Willow_Wood[Willow_Wood.length] = createMarker(new GPoint(-82.48535919,38.60760117),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Symmes Valley High School",'Willow_Wood=' + Willow_Wood.length); Ironton[Ironton.length] = createMarker(new GPoint(-82.69510651,38.54446411),"",iconRd); mySelect.options[mySelect.options.length] = new Option("West Ironton Elementary School",'Ironton=' + Ironton.length); Ironton[Ironton.length] = createMarker(new GPoint(-82.66929626,38.51886749),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Whitwell Elementary School",'Ironton=' + Ironton.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(Chesapeake); map.removeOverlays(Coal_Grove); map.removeOverlays(Ironton); map.removeOverlays(Proctorville); map.removeOverlays(South_Point); map.removeOverlays(Willow_Wood); 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(South_Point);map.removeOverlays(Chesapeake); map.removeOverlays(Coal_Grove); map.removeOverlays(Ironton); map.removeOverlays(Proctorville); map.removeOverlays(South_Point); map.removeOverlays(Willow_Wood); map.addOverlays(Chesapeake); centerByArray(Chesapeake, false, false); cntMarker += Chesapeake.length; map.addOverlays(Coal_Grove); centerByArray(Coal_Grove, false, false); cntMarker += Coal_Grove.length; map.addOverlays(Ironton); centerByArray(Ironton, false, false); cntMarker += Ironton.length; map.addOverlays(Proctorville); centerByArray(Proctorville, false, false); cntMarker += Proctorville.length; map.addOverlays(South_Point); centerByArray(South_Point, false, false); cntMarker += South_Point.length; map.addOverlays(Willow_Wood); centerByArray(Willow_Wood, false, false); cntMarker += Willow_Wood.length; centerByArray(South_Point,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'); } }