function addMarkers() { mySelect = document.getElementById('selection'); Curtice = [];Port_Clinton = [];Genoa = [];Oak_Harbor = [];Lakeside_Marblehead = [];Graytown = [];Isle_St_George = [];Gypsum = [];Put_In_Bay = [];Rocky_Ridge = [];Elmore = [];mySelect.options[mySelect.options.length] = new Option("Curtice schools",'all=Curtice'); mySelect.options[mySelect.options.length] = new Option("Elmore schools",'all=Elmore'); mySelect.options[mySelect.options.length] = new Option("Genoa schools",'all=Genoa'); mySelect.options[mySelect.options.length] = new Option("Graytown schools",'all=Graytown'); mySelect.options[mySelect.options.length] = new Option("Gypsum schools",'all=Gypsum'); mySelect.options[mySelect.options.length] = new Option("Isle St George schools",'all=Isle_St_George'); mySelect.options[mySelect.options.length] = new Option("Lakeside Marblehead schools",'all=Lakeside_Marblehead'); mySelect.options[mySelect.options.length] = new Option("Oak Harbor schools",'all=Oak_Harbor'); mySelect.options[mySelect.options.length] = new Option("Port Clinton schools",'all=Port_Clinton'); mySelect.options[mySelect.options.length] = new Option("Put In Bay schools",'all=Put_In_Bay'); mySelect.options[mySelect.options.length] = new Option("Rocky Ridge schools",'all=Rocky_Ridge'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Curtice[Curtice.length] = createMarker(new GPoint(-83.35831451,41.58583450),"
",iconRd); mySelect.options[mySelect.options.length] = new Option("Allen Elementary School",'Curtice=' + Curtice.length); Port_Clinton[Port_Clinton.length] = createMarker(new GPoint(-82.94906616,41.50624084),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Bataan Elementary School",'Port_Clinton=' + Port_Clinton.length); Genoa[Genoa.length] = createMarker(new GPoint(-83.36028290,41.52528763),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Brunner Elementary School",'Genoa=' + Genoa.length); Oak_Harbor[Oak_Harbor.length] = createMarker(new GPoint(-83.14508057,41.56632233),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Carroll Elementary School",'Oak_Harbor=' + Oak_Harbor.length); Port_Clinton[Port_Clinton.length] = createMarker(new GPoint(-82.84597778,41.57288361),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Catawba Elementary School",'Port_Clinton=' + Port_Clinton.length); Lakeside_Marblehead[Lakeside_Marblehead.length] = createMarker(new GPoint(-82.75522614,41.53566742),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Danbury Elementary School",'Lakeside_Marblehead=' + Lakeside_Marblehead.length); Lakeside_Marblehead[Lakeside_Marblehead.length] = createMarker(new GPoint(-82.75522614,41.53566742),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Danbury High School",'Lakeside_Marblehead=' + Lakeside_Marblehead.length); Genoa[Genoa.length] = createMarker(new GPoint(-83.35877991,41.55932236),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Genoa Area High School",'Genoa=' + Genoa.length); Genoa[Genoa.length] = createMarker(new GPoint(-83.35877991,41.55893707),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Genoa Area Middle School",'Genoa=' + Genoa.length); Graytown[Graytown.length] = createMarker(new GPoint(-83.26090240,41.54275894),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Graytown Elementary School",'Graytown=' + Graytown.length); Port_Clinton[Port_Clinton.length] = createMarker(new GPoint(-82.93918610,41.50858688),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Jefferson Elementary School",'Port_Clinton=' + Port_Clinton.length); Isle_St_George[Isle_St_George.length] = createMarker(new GPoint(-82.81563568,41.71591568),"",iconBl); mySelect.options[mySelect.options.length] = new Option("North Bass Elementary School",'Isle_St_George=' + Isle_St_George.length); Oak_Harbor[Oak_Harbor.length] = createMarker(new GPoint(-83.15249634,41.50826645),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Oak Harbor High School",'Oak_Harbor=' + Oak_Harbor.length); Oak_Harbor[Oak_Harbor.length] = createMarker(new GPoint(-83.14721680,41.51259232),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Oak Harbor Middle School",'Oak_Harbor=' + Oak_Harbor.length); Port_Clinton[Port_Clinton.length] = createMarker(new GPoint(-82.93915558,41.50310898),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Port Clinton High School",'Port_Clinton=' + Port_Clinton.length); Port_Clinton[Port_Clinton.length] = createMarker(new GPoint(-82.94084167,41.50894165),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Port Clinton Middle School",'Port_Clinton=' + Port_Clinton.length); Gypsum[Gypsum.length] = createMarker(new GPoint(-82.87169647,41.50439835),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Portage Elementary School",'Gypsum=' + Gypsum.length); Put_In_Bay[Put_In_Bay.length] = createMarker(new GPoint(-82.81700134,41.65240097),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Put-in-bay Elementary School",'Put_In_Bay=' + Put_In_Bay.length); Put_In_Bay[Put_In_Bay.length] = createMarker(new GPoint(-82.81700134,41.65240097),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Put-in-bay High School",'Put_In_Bay=' + Put_In_Bay.length); Oak_Harbor[Oak_Harbor.length] = createMarker(new GPoint(-83.14065552,41.50976181),"",iconRd); mySelect.options[mySelect.options.length] = new Option("R C Waters Elementary School",'Oak_Harbor=' + Oak_Harbor.length); Rocky_Ridge[Rocky_Ridge.length] = createMarker(new GPoint(-83.21267700,41.53229904),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Rocky Ridge Elementary School",'Rocky_Ridge=' + Rocky_Ridge.length); Elmore[Elmore.length] = createMarker(new GPoint(-83.29319763,41.47233582),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Woodmore High School",'Elmore=' + Elmore.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(Curtice); map.removeOverlays(Elmore); map.removeOverlays(Genoa); map.removeOverlays(Graytown); map.removeOverlays(Gypsum); map.removeOverlays(Isle_St_George); map.removeOverlays(Lakeside_Marblehead); map.removeOverlays(Oak_Harbor); map.removeOverlays(Port_Clinton); map.removeOverlays(Put_In_Bay); map.removeOverlays(Rocky_Ridge); 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(Curtice);map.removeOverlays(Curtice); map.removeOverlays(Elmore); map.removeOverlays(Genoa); map.removeOverlays(Graytown); map.removeOverlays(Gypsum); map.removeOverlays(Isle_St_George); map.removeOverlays(Lakeside_Marblehead); map.removeOverlays(Oak_Harbor); map.removeOverlays(Port_Clinton); map.removeOverlays(Put_In_Bay); map.removeOverlays(Rocky_Ridge); map.addOverlays(Curtice); centerByArray(Curtice, false, false); cntMarker += Curtice.length; map.addOverlays(Elmore); centerByArray(Elmore, false, false); cntMarker += Elmore.length; map.addOverlays(Genoa); centerByArray(Genoa, false, false); cntMarker += Genoa.length; map.addOverlays(Graytown); centerByArray(Graytown, false, false); cntMarker += Graytown.length; map.addOverlays(Gypsum); centerByArray(Gypsum, false, false); cntMarker += Gypsum.length; map.addOverlays(Isle_St_George); centerByArray(Isle_St_George, false, false); cntMarker += Isle_St_George.length; map.addOverlays(Lakeside_Marblehead); centerByArray(Lakeside_Marblehead, false, false); cntMarker += Lakeside_Marblehead.length; map.addOverlays(Oak_Harbor); centerByArray(Oak_Harbor, false, false); cntMarker += Oak_Harbor.length; map.addOverlays(Port_Clinton); centerByArray(Port_Clinton, false, false); cntMarker += Port_Clinton.length; map.addOverlays(Put_In_Bay); centerByArray(Put_In_Bay, false, false); cntMarker += Put_In_Bay.length; map.addOverlays(Rocky_Ridge); centerByArray(Rocky_Ridge, false, false); cntMarker += Rocky_Ridge.length; centerByArray(Curtice,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'); } }