function addMarkers() { mySelect = document.getElementById('selection'); Elkhart = [];Goshen = [];Bristol = [];Middlebury = [];Millersburg = [];Nappanee = [];New_Paris = [];Wakarusa = [];mySelect.options[mySelect.options.length] = new Option("Bristol schools",'all=Bristol'); mySelect.options[mySelect.options.length] = new Option("Elkhart schools",'all=Elkhart'); mySelect.options[mySelect.options.length] = new Option("Goshen schools",'all=Goshen'); mySelect.options[mySelect.options.length] = new Option("Middlebury schools",'all=Middlebury'); mySelect.options[mySelect.options.length] = new Option("Millersburg schools",'all=Millersburg'); mySelect.options[mySelect.options.length] = new Option("Nappanee schools",'all=Nappanee'); mySelect.options[mySelect.options.length] = new Option("New Paris schools",'all=New_Paris'); mySelect.options[mySelect.options.length] = new Option("Wakarusa schools",'all=Wakarusa'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Elkhart[Elkhart.length] = createMarker(new GPoint(-85.96366882,41.69821548),"
",iconRd); mySelect.options[mySelect.options.length] = new Option("Beardsley Elementary School",'Elkhart=' + Elkhart.length); Elkhart[Elkhart.length] = createMarker(new GPoint(-85.95751190,41.67603683),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Beck Elementary School",'Elkhart=' + Elkhart.length); Goshen[Goshen.length] = createMarker(new GPoint(-85.83441925,41.58237076),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Benton Elementary School",'Goshen=' + Goshen.length); Bristol[Bristol.length] = createMarker(new GPoint(-85.82469940,41.71746445),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Bristol Elementary School",'Bristol=' + Bristol.length); Goshen[Goshen.length] = createMarker(new GPoint(-85.83291626,41.59224319),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Chamberlain Elementary School",'Goshen=' + Goshen.length); Goshen[Goshen.length] = createMarker(new GPoint(-85.82828522,41.58198929),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Chandler Elementary School",'Goshen=' + Goshen.length); Elkhart[Elkhart.length] = createMarker(new GPoint(-85.97628784,41.68154144),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Cleveland Elementary School",'Elkhart=' + Elkhart.length); Elkhart[Elkhart.length] = createMarker(new GPoint(-85.92738342,41.63373566),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Concord Community High School",'Elkhart=' + Elkhart.length); Elkhart[Elkhart.length] = createMarker(new GPoint(-85.97628784,41.68154144),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Concord East Side Elementary School",'Elkhart=' + Elkhart.length); Elkhart[Elkhart.length] = createMarker(new GPoint(-85.97628784,41.68154144),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Concord Junior High School",'Elkhart=' + Elkhart.length); Elkhart[Elkhart.length] = createMarker(new GPoint(-85.97628784,41.68154144),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Concord Ox-bow Elementary School",'Elkhart=' + Elkhart.length); Elkhart[Elkhart.length] = createMarker(new GPoint(-85.92023468,41.63316345),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Concord South Side Elementary School",'Elkhart=' + Elkhart.length); Elkhart[Elkhart.length] = createMarker(new GPoint(-85.96874237,41.65247726),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Concord West Side Elementary School",'Elkhart=' + Elkhart.length); Elkhart[Elkhart.length] = createMarker(new GPoint(-86.00177002,41.68556213),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Daly Elementary School",'Elkhart=' + Elkhart.length); Elkhart[Elkhart.length] = createMarker(new GPoint(-85.90345764,41.72096634),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Eastwood Elementary School",'Elkhart=' + Elkhart.length); Elkhart[Elkhart.length] = createMarker(new GPoint(-85.95240021,41.70441818),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Elkhart Area Career Center",'Elkhart=' + Elkhart.length); Elkhart[Elkhart.length] = createMarker(new GPoint(-85.95405579,41.68627167),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Elkhart Central High School",'Elkhart=' + Elkhart.length); Elkhart[Elkhart.length] = createMarker(new GPoint(-86.01198578,41.69562149),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Elkhart Memorial High School",'Elkhart=' + Elkhart.length); Goshen[Goshen.length] = createMarker(new GPoint(-85.83441925,41.58237076),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Fairfield Junior Senior High School",'Goshen=' + Goshen.length); Elkhart[Elkhart.length] = createMarker(new GPoint(-85.97628784,41.68154144),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Feeser Elementary School",'Elkhart=' + Elkhart.length); Goshen[Goshen.length] = createMarker(new GPoint(-85.82409668,41.57839966),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Goshen High School",'Goshen=' + Goshen.length); Goshen[Goshen.length] = createMarker(new GPoint(-85.84781647,41.57121658),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Goshen Middle School",'Goshen=' + Goshen.length); Elkhart[Elkhart.length] = createMarker(new GPoint(-85.97386932,41.66666412),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Hawthorne Elementary School",'Elkhart=' + Elkhart.length); Middlebury[Middlebury.length] = createMarker(new GPoint(-85.72510529,41.67136383),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Heritage Middle School",'Middlebury=' + Middlebury.length); Goshen[Goshen.length] = createMarker(new GPoint(-85.83441925,41.58237076),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Jefferson Elementary School",'Goshen=' + Goshen.length); Elkhart[Elkhart.length] = createMarker(new GPoint(-86.02228546,41.63749313),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Jimtown High School",'Elkhart=' + Elkhart.length); Elkhart[Elkhart.length] = createMarker(new GPoint(-85.95240021,41.70441818),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Jimtown Intermediate School",'Elkhart=' + Elkhart.length); Elkhart[Elkhart.length] = createMarker(new GPoint(-86.02228546,41.63931656),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Jimtown Junior High School",'Elkhart=' + Elkhart.length); Elkhart[Elkhart.length] = createMarker(new GPoint(-85.97628784,41.68154144),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Jimtown North Elementary School",'Elkhart=' + Elkhart.length); Elkhart[Elkhart.length] = createMarker(new GPoint(-86.02228546,41.63934708),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Jimtown South Elementary School",'Elkhart=' + Elkhart.length); Middlebury[Middlebury.length] = createMarker(new GPoint(-85.70349884,41.68500137),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Middlebury Elementary School",'Middlebury=' + Middlebury.length); Millersburg[Millersburg.length] = createMarker(new GPoint(-85.68520355,41.52550125),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Millersburg Elementary School",'Millersburg=' + Millersburg.length); Goshen[Goshen.length] = createMarker(new GPoint(-85.86717224,41.58261490),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Model Elementary School",'Goshen=' + Goshen.length); Elkhart[Elkhart.length] = createMarker(new GPoint(-85.95191193,41.65963745),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Monger Elementary School",'Elkhart=' + Elkhart.length); Nappanee[Nappanee.length] = createMarker(new GPoint(-85.99374390,41.44541931),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Nappanee Elementary School",'Nappanee=' + Nappanee.length); New_Paris[New_Paris.length] = createMarker(new GPoint(-85.83630371,41.49209976),"",iconRd); mySelect.options[mySelect.options.length] = new Option("New Paris Elementary School",'New_Paris=' + New_Paris.length); Elkhart[Elkhart.length] = createMarker(new GPoint(-85.97361755,41.70103836),"",iconBl); mySelect.options[mySelect.options.length] = new Option("North Side Middle School",'Elkhart=' + Elkhart.length); Nappanee[Nappanee.length] = createMarker(new GPoint(-86.00122070,41.45605087),"",iconGr); mySelect.options[mySelect.options.length] = new Option("North Wood High School",'Nappanee=' + Nappanee.length); Wakarusa[Wakarusa.length] = createMarker(new GPoint(-86.02117920,41.53762054),"",iconBl); mySelect.options[mySelect.options.length] = new Option("North Wood Middle School",'Wakarusa=' + Wakarusa.length); Middlebury[Middlebury.length] = createMarker(new GPoint(-85.72547150,41.67135239),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Northridge High School",'Middlebury=' + Middlebury.length); Goshen[Goshen.length] = createMarker(new GPoint(-85.83752441,41.60369873),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Oaklawn Hospital School",'Goshen=' + Goshen.length); Middlebury[Middlebury.length] = createMarker(new GPoint(-85.72511292,41.67180252),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Orchard View School",'Middlebury=' + Middlebury.length); Elkhart[Elkhart.length] = createMarker(new GPoint(-85.97628784,41.68154144),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Osolo Elementary School",'Elkhart=' + Elkhart.length); Goshen[Goshen.length] = createMarker(new GPoint(-85.82943726,41.57154083),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Parkside Elementary School",'Goshen=' + Goshen.length); Elkhart[Elkhart.length] = createMarker(new GPoint(-85.96848297,41.66683578),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Pierre Moran Middle School",'Elkhart=' + Elkhart.length); Elkhart[Elkhart.length] = createMarker(new GPoint(-85.92491150,41.70233536),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Pinewood Elementary School",'Elkhart=' + Elkhart.length); Elkhart[Elkhart.length] = createMarker(new GPoint(-85.93894196,41.69086456),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Riverview Elementary School",'Elkhart=' + Elkhart.length); Elkhart[Elkhart.length] = createMarker(new GPoint(-85.96373749,41.67376328),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Roosevelt Elementary School",'Elkhart=' + Elkhart.length); Wakarusa[Wakarusa.length] = createMarker(new GPoint(-86.02448273,41.53983688),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Wakarusa Elementary School",'Wakarusa=' + Wakarusa.length); Goshen[Goshen.length] = createMarker(new GPoint(-85.83441925,41.58237076),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Waterford Elementary School",'Goshen=' + Goshen.length); Goshen[Goshen.length] = createMarker(new GPoint(-85.84897614,41.58541489),"",iconRd); mySelect.options[mySelect.options.length] = new Option("West Goshen Elementary School",'Goshen=' + Goshen.length); Elkhart[Elkhart.length] = createMarker(new GPoint(-86.00358582,41.68554688),"",iconBl); mySelect.options[mySelect.options.length] = new Option("West Side Middle School",'Elkhart=' + Elkhart.length); Elkhart[Elkhart.length] = createMarker(new GPoint(-86.01791382,41.69897461),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Woodland Elementary School",'Elkhart=' + Elkhart.length); Nappanee[Nappanee.length] = createMarker(new GPoint(-85.99342346,41.45724106),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Woodview Elementary School",'Nappanee=' + Nappanee.length); Bristol[Bristol.length] = createMarker(new GPoint(-85.81749725,41.72151184),"",iconRd); mySelect.options[mySelect.options.length] = new Option("York Elementary School",'Bristol=' + Bristol.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(Bristol); map.removeOverlays(Elkhart); map.removeOverlays(Goshen); map.removeOverlays(Middlebury); map.removeOverlays(Millersburg); map.removeOverlays(Nappanee); map.removeOverlays(New_Paris); map.removeOverlays(Wakarusa); 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(Elkhart);map.removeOverlays(Bristol); map.removeOverlays(Elkhart); map.removeOverlays(Goshen); map.removeOverlays(Middlebury); map.removeOverlays(Millersburg); map.removeOverlays(Nappanee); map.removeOverlays(New_Paris); map.removeOverlays(Wakarusa); map.addOverlays(Bristol); centerByArray(Bristol, false, false); cntMarker += Bristol.length; map.addOverlays(Elkhart); centerByArray(Elkhart, false, false); cntMarker += Elkhart.length; map.addOverlays(Goshen); centerByArray(Goshen, false, false); cntMarker += Goshen.length; map.addOverlays(Middlebury); centerByArray(Middlebury, false, false); cntMarker += Middlebury.length; map.addOverlays(Millersburg); centerByArray(Millersburg, false, false); cntMarker += Millersburg.length; map.addOverlays(Nappanee); centerByArray(Nappanee, false, false); cntMarker += Nappanee.length; map.addOverlays(New_Paris); centerByArray(New_Paris, false, false); cntMarker += New_Paris.length; map.addOverlays(Wakarusa); centerByArray(Wakarusa, false, false); cntMarker += Wakarusa.length; centerByArray(Elkhart,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'); } }