function addMarkers() { mySelect = document.getElementById('selection'); Dowagiac = [];Union = [];Cassopolis = [];Edwardsburg = [];Niles = [];Marcellus = [];mySelect.options[mySelect.options.length] = new Option("Cassopolis schools",'all=Cassopolis'); mySelect.options[mySelect.options.length] = new Option("Dowagiac schools",'all=Dowagiac'); mySelect.options[mySelect.options.length] = new Option("Edwardsburg schools",'all=Edwardsburg'); mySelect.options[mySelect.options.length] = new Option("Marcellus schools",'all=Marcellus'); mySelect.options[mySelect.options.length] = new Option("Niles schools",'all=Niles'); mySelect.options[mySelect.options.length] = new Option("Union schools",'all=Union'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Dowagiac[Dowagiac.length] = createMarker(new GPoint(-86.11085510,41.98183823),"
Alternative Education Center
206 Main Street
Dowagiac, MI 49047

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Alternative Education Center",'Dowagiac=' + Dowagiac.length); Union[Union.length] = createMarker(new GPoint(-85.84856415,41.78749084),"
Baldwin Elementary School
14701 Us-12
Union, MI 49130

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Baldwin Elementary School",'Union=' + Union.length); Cassopolis[Cassopolis.length] = createMarker(new GPoint(-86.08760071,41.90300751),"
Brookside Learning Center
61662 Dailey Road
Cassopolis, MI 49031

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Brookside Learning Center",'Cassopolis=' + Cassopolis.length); Cassopolis[Cassopolis.length] = createMarker(new GPoint(-85.98339844,41.90399933),"
Cassopolis Alternative Ed. High School
63700 Brick Church Road
Cassopolis, MI 49031

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Cassopolis Alternative Ed. High School",'Cassopolis=' + Cassopolis.length); Dowagiac[Dowagiac.length] = createMarker(new GPoint(-86.11085510,41.98183823),"
Central Middle School
206 Main Street
Dowagiac, MI 49047

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Central Middle School",'Dowagiac=' + Dowagiac.length); Edwardsburg[Edwardsburg.length] = createMarker(new GPoint(-86.08837128,41.79019165),"
Chicago Road School
69410 Section Street
Edwardsburg, MI 49112

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Chicago Road School",'Edwardsburg=' + Edwardsburg.length); Edwardsburg[Edwardsburg.length] = createMarker(new GPoint(-86.08837128,41.79019165),"
Eagle Lake Elementary School
69410 Section Street
Edwardsburg, MI 49112

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Eagle Lake Elementary School",'Edwardsburg=' + Edwardsburg.length); Edwardsburg[Edwardsburg.length] = createMarker(new GPoint(-86.08837128,41.79019165),"
Edwardsburg High School
69410 Section Street
Edwardsburg, MI 49112

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Edwardsburg High School",'Edwardsburg=' + Edwardsburg.length); Edwardsburg[Edwardsburg.length] = createMarker(new GPoint(-86.08837128,41.79019165),"
Edwardsburg Intermediate School
69410 Section Street
Edwardsburg, MI 49112

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Edwardsburg Intermediate School",'Edwardsburg=' + Edwardsburg.length); Edwardsburg[Edwardsburg.length] = createMarker(new GPoint(-86.08837128,41.79019165),"
Edwardsburg Middle School
69410 Section Street
Edwardsburg, MI 49112

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Edwardsburg Middle School",'Edwardsburg=' + Edwardsburg.length); Edwardsburg[Edwardsburg.length] = createMarker(new GPoint(-86.08837128,41.79019165),"
Edwardsburg Primary School
69410 Section Street
Edwardsburg, MI 49112

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Edwardsburg Primary School",'Edwardsburg=' + Edwardsburg.length); Cassopolis[Cassopolis.length] = createMarker(new GPoint(-85.98339844,41.90399933),"
Frank Squires Early Elementary School
63700 Brick Church Road
Cassopolis, MI 49031

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Frank Squires Early Elementary School",'Cassopolis=' + Cassopolis.length); Dowagiac[Dowagiac.length] = createMarker(new GPoint(-86.12039948,42.00630188),"
Hamilton Lower Middle School
614 Spruce Street
Dowagiac, MI 49047

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Hamilton Lower Middle School",'Dowagiac=' + Dowagiac.length); Niles[Niles.length] = createMarker(new GPoint(-86.16710663,41.84786224),"
Howard Community School
2788 Mannix Street
Niles, MI 49120

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Howard Community School",'Niles=' + Niles.length); Niles[Niles.length] = createMarker(new GPoint(-86.17157745,41.84778595),"
James Ellis School
2740 Mannix Street
Niles, MI 49120

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("James Ellis School",'Niles=' + Niles.length); Dowagiac[Dowagiac.length] = createMarker(new GPoint(-86.11087036,41.98201370),"
Justus Gage Elementary School
206 Main Street
Dowagiac, MI 49047

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Justus Gage Elementary School",'Dowagiac=' + Dowagiac.length); Dowagiac[Dowagiac.length] = createMarker(new GPoint(-86.11085510,41.98183823),"
Kincheloe Elementary School
206 Main Street
Dowagiac, MI 49047

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Kincheloe Elementary School",'Dowagiac=' + Dowagiac.length); Dowagiac[Dowagiac.length] = createMarker(new GPoint(-86.11087036,41.98201370),"
Lincoln Early Childhood Center
206 Main Street
Dowagiac, MI 49047

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Lincoln Early Childhood Center",'Dowagiac=' + Dowagiac.length); Dowagiac[Dowagiac.length] = createMarker(new GPoint(-86.12039948,42.00630188),"
Lincoln Elementary School
405 E. Division Street
Dowagiac, MI 49047

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Lincoln Elementary School",'Dowagiac=' + Dowagiac.length); Marcellus[Marcellus.length] = createMarker(new GPoint(-85.80840302,42.02450180),"
Marcellus Elementary School
P.o. Box 48
Marcellus, MI 49067

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Marcellus Elementary School",'Marcellus=' + Marcellus.length); Marcellus[Marcellus.length] = createMarker(new GPoint(-85.80840302,42.02450180),"
Marcellus High School
P.o. Box 48
Marcellus, MI 49067

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Marcellus High School",'Marcellus=' + Marcellus.length); Marcellus[Marcellus.length] = createMarker(new GPoint(-85.80840302,42.02450180),"
Marcellus Middle School
P.o. Box 48
Marcellus, MI 49067

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Marcellus Middle School",'Marcellus=' + Marcellus.length); Dowagiac[Dowagiac.length] = createMarker(new GPoint(-86.11085510,41.98183823),"
Mckinley Elementary School
206 Main Street
Dowagiac, MI 49047

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Mckinley Elementary School",'Dowagiac=' + Dowagiac.length); Dowagiac[Dowagiac.length] = createMarker(new GPoint(-86.10831451,41.99118805),"
North Pointe Center
704 North Orchard
Dowagiac, MI 49047

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("North Pointe Center",'Dowagiac=' + Dowagiac.length); Dowagiac[Dowagiac.length] = createMarker(new GPoint(-86.11087036,41.98201370),"
Patrick Hamilton Middle School
206 Main Street
Dowagiac, MI 49047

[ View School Profile ]
",iconBl); mySelect.options[mySelect.options.length] = new Option("Patrick Hamilton Middle School",'Dowagiac=' + Dowagiac.length); Cassopolis[Cassopolis.length] = createMarker(new GPoint(-85.98339844,41.90399933),"
Ross Beatty High School
63700 Brick Church Road
Cassopolis, MI 49031

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Ross Beatty High School",'Cassopolis=' + Cassopolis.length); Cassopolis[Cassopolis.length] = createMarker(new GPoint(-85.98339844,41.90399933),"
Sam Adams Elementary School
63700 Brick Church Road
Cassopolis, MI 49031

[ View School Profile ]
",iconRd); mySelect.options[mySelect.options.length] = new Option("Sam Adams Elementary School",'Cassopolis=' + Cassopolis.length); Dowagiac[Dowagiac.length] = createMarker(new GPoint(-86.11087036,41.98201370),"
Union High School
206 Main Street
Dowagiac, MI 49047

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Union High School",'Dowagiac=' + Dowagiac.length); Dowagiac[Dowagiac.length] = createMarker(new GPoint(-86.12039948,42.00630188),"
Union Senior High School
701 W. Prairie Ronde Street
Dowagiac, MI 49047

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Union Senior High School",'Dowagiac=' + Dowagiac.length); Marcellus[Marcellus.length] = createMarker(new GPoint(-85.80840302,42.02450180),"
Volinia Outcome Base School
P.o. Box 48
Marcellus, MI 49067

[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Volinia Outcome Base School",'Marcellus=' + Marcellus.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(Cassopolis); map.removeOverlays(Dowagiac); map.removeOverlays(Edwardsburg); map.removeOverlays(Marcellus); map.removeOverlays(Niles); map.removeOverlays(Union); 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(Dowagiac);map.removeOverlays(Cassopolis); map.removeOverlays(Dowagiac); map.removeOverlays(Edwardsburg); map.removeOverlays(Marcellus); map.removeOverlays(Niles); map.removeOverlays(Union); map.addOverlays(Cassopolis); centerByArray(Cassopolis, false, false); cntMarker += Cassopolis.length; map.addOverlays(Dowagiac); centerByArray(Dowagiac, false, false); cntMarker += Dowagiac.length; map.addOverlays(Edwardsburg); centerByArray(Edwardsburg, false, false); cntMarker += Edwardsburg.length; map.addOverlays(Marcellus); centerByArray(Marcellus, false, false); cntMarker += Marcellus.length; map.addOverlays(Niles); centerByArray(Niles, false, false); cntMarker += Niles.length; map.addOverlays(Union); centerByArray(Union, false, false); cntMarker += Union.length; centerByArray(Dowagiac,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'); } }