function addMarkers(){ mySelect = document.getElementById('selection'); Port_Huron = [];Marysville = [];Marine_City = [];Fair_Haven = [];Yale = [];Fort_Gratiot = [];Saint_Clair = [];Kimball = [];Algonac = [];Lakeport = [];mySelect.options[mySelect.options.length] = new Option("Algonac schools",'all=Algonac'); mySelect.options[mySelect.options.length] = new Option("Fair Haven schools",'all=Fair_Haven'); mySelect.options[mySelect.options.length] = new Option("Fort Gratiot schools",'all=Fort_Gratiot'); mySelect.options[mySelect.options.length] = new Option("Kimball schools",'all=Kimball'); mySelect.options[mySelect.options.length] = new Option("Lakeport schools",'all=Lakeport'); mySelect.options[mySelect.options.length] = new Option("Marine City schools",'all=Marine_City'); mySelect.options[mySelect.options.length] = new Option("Marysville schools",'all=Marysville'); mySelect.options[mySelect.options.length] = new Option("Port Huron schools",'all=Port_Huron'); mySelect.options[mySelect.options.length] = new Option("Saint Clair schools",'all=Saint_Clair'); mySelect.options[mySelect.options.length] = new Option("Yale schools",'all=Yale'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Port_Huron[Port_Huron.length] = createMarker(new GPoint(-82.45436200,42.94451800),"
Anthonita Montessori Academy
2625 Moak Street
Port Huron, MI 48060
Co-ed school, PK-K
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Anthonita Montessori Academy",'Port_Huron=' + Port_Huron.length); Marysville[Marysville.length] = createMarker(new GPoint(-82.49524100,42.92070100),"
Blue Water Sda Elementary School
1365 6th Street
Marysville, MI 48040
Co-ed school, 4-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Blue Water Sda Elementary School",'Marysville=' + Marysville.length); Marine_City[Marine_City.length] = createMarker(new GPoint(-82.49455200,42.71264500),"
Cardinal Mooney Catholic High School
660 Sout Water St
Marine City, MI 48039
Co-ed school, 9-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Cardinal Mooney Catholic High School",'Marine_City=' + Marine_City.length); Fair_Haven[Fair_Haven.length] = createMarker(new GPoint(-82.64901800,42.67819800),"
Country Meadows Montessori
8622 Dixie Hwy
Fair Haven, MI 48023
Co-ed school, NS-K
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Country Meadows Montessori",'Fair_Haven=' + Fair_Haven.length); Yale[Yale.length] = createMarker(new GPoint(-82.78126400,43.13026300),"
Emanuel Redeemer Lutheran School
11089 Yale Road
Yale, MI 48097
Co-ed school, K-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Emanuel Redeemer Lutheran School",'Yale=' + Yale.length); Marine_City[Marine_City.length] = createMarker(new GPoint(-82.49412300,42.71327700),"
Holy Cross Catholic
618 S Water Street
Marine City, MI 48039
Co-ed school, K-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Holy Cross Catholic",'Marine_City=' + Marine_City.length); Fair_Haven[Fair_Haven.length] = createMarker(new GPoint(-82.68855700,42.69216800),"
Immaculate Conception School
7043 Church Road
Fair Haven, MI 48023
Co-ed school, PK-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Immaculate Conception School",'Fair_Haven=' + Fair_Haven.length); Port_Huron[Port_Huron.length] = createMarker(new GPoint(-82.46174700,42.98112700),"
Mc Cormick Catholic Academy
2865 Henry Street
Port Huron, MI 48060
Co-ed school, 6-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Mc Cormick Catholic Academy",'Port_Huron=' + Port_Huron.length); Fort_Gratiot[Fort_Gratiot.length] = createMarker(new GPoint(-82.42747100,42.96922900),"
Montessori Academy Port Huron
3675 N River Road
Fort Gratiot, MI 48059
Co-ed school, PK-K
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Montessori Academy Port Huron",'Fort_Gratiot=' + Fort_Gratiot.length); Saint_Clair[Saint_Clair.length] = createMarker(new GPoint(-82.49468500,42.81736700),"
Montessori Children's Academy
1280 S. 9th 955 Fred W Moore
Saint Clair, MI 48079
Co-ed school, PK-3
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Montessori Children's Academy",'Saint_Clair=' + Saint_Clair.length); Kimball[Kimball.length] = createMarker(new GPoint(-82.54401000,42.96324700),"
New Life Christian Academy
5517 Griswold Road
Kimball, MI 48074
Co-ed school, PK-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("New Life Christian Academy",'Kimball=' + Kimball.length); Algonac[Algonac.length] = createMarker(new GPoint(-82.53391700,42.61967100),"
St. Catherine Elementary School
1106 St Clair Blvd
Algonac, MI 48001
Co-ed school, PK-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("St. Catherine Elementary School",'Algonac=' + Algonac.length); Saint_Clair[Saint_Clair.length] = createMarker(new GPoint(-82.49198800,42.82733700),"
St. Mary Elementary School
800 Orchard Street
Saint Clair, MI 48079
Co-ed school, PK-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("St. Mary Elementary School",'Saint_Clair=' + Saint_Clair.length); Lakeport[Lakeport.length] = createMarker(new GPoint(-82.49129000,43.11209200),"
St Edward On The Lake School
6995 Lakeshore Road
Lakeport, MI 48059
Co-ed school, PK-5
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("St Edward On The Lake School",'Lakeport=' + Lakeport.length); Port_Huron[Port_Huron.length] = createMarker(new GPoint(-82.43808300,43.00871200),"
St Mary Academy
1429 Ballentine Street
Port Huron, MI 48060
Co-ed school, PK-5
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("St Mary Academy",'Port_Huron=' + Port_Huron.length); Port_Huron[Port_Huron.length] = createMarker(new GPoint(-82.43269900,42.96789600),"
Trinity Lutheran School
1517 10th Street
Port Huron, MI 48060
Co-ed school, PK-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Trinity Lutheran School",'Port_Huron=' + Port_Huron.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,11); /* 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/////3/' + showArray); map.removeOverlays(Algonac); map.removeOverlays(Fair_Haven); map.removeOverlays(Fort_Gratiot); map.removeOverlays(Kimball); map.removeOverlays(Lakeport); map.removeOverlays(Marine_City); map.removeOverlays(Marysville); map.removeOverlays(Port_Huron); map.removeOverlays(Saint_Clair); map.removeOverlays(Yale); 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(Port_Huron);map.removeOverlays(Algonac); map.removeOverlays(Fair_Haven); map.removeOverlays(Fort_Gratiot); map.removeOverlays(Kimball); map.removeOverlays(Lakeport); map.removeOverlays(Marine_City); map.removeOverlays(Marysville); map.removeOverlays(Port_Huron); map.removeOverlays(Saint_Clair); map.removeOverlays(Yale); map.addOverlays(Algonac); centerByArray(Algonac, false, false); cntMarker += Algonac.length; map.addOverlays(Fair_Haven); centerByArray(Fair_Haven, false, false); cntMarker += Fair_Haven.length; map.addOverlays(Fort_Gratiot); centerByArray(Fort_Gratiot, false, false); cntMarker += Fort_Gratiot.length; map.addOverlays(Kimball); centerByArray(Kimball, false, false); cntMarker += Kimball.length; map.addOverlays(Lakeport); centerByArray(Lakeport, false, false); cntMarker += Lakeport.length; map.addOverlays(Marine_City); centerByArray(Marine_City, false, false); cntMarker += Marine_City.length; map.addOverlays(Marysville); centerByArray(Marysville, false, false); cntMarker += Marysville.length; map.addOverlays(Port_Huron); centerByArray(Port_Huron, false, false); cntMarker += Port_Huron.length; map.addOverlays(Saint_Clair); centerByArray(Saint_Clair, false, false); cntMarker += Saint_Clair.length; map.addOverlays(Yale); centerByArray(Yale, false, false); cntMarker += Yale.length; centerByArray(Port_Huron,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'); //window.open('/map.php?type=1&schools=&school_level=3&radius=&zipcode=&school_type_search=&school_type_code='); } } function createMarker(point, label, icon) { var marker = new GMarker(point, icon); var html = label; GEvent.addListener(marker, "click", function() { marker.openInfoWindowHtml(html); }); return marker; }