function addMarkers(){ mySelect = document.getElementById('selection'); Carleton = [];Petersburg = [];Monroe = [];Lasalle = [];Temperance = [];Newport = [];Erie = [];mySelect.options[mySelect.options.length] = new Option("Carleton schools",'all=Carleton'); mySelect.options[mySelect.options.length] = new Option("Erie schools",'all=Erie'); mySelect.options[mySelect.options.length] = new Option("Lasalle schools",'all=Lasalle'); mySelect.options[mySelect.options.length] = new Option("Monroe schools",'all=Monroe'); mySelect.options[mySelect.options.length] = new Option("Newport schools",'all=Newport'); mySelect.options[mySelect.options.length] = new Option("Petersburg schools",'all=Petersburg'); mySelect.options[mySelect.options.length] = new Option("Temperance schools",'all=Temperance'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Carleton[Carleton.length] = createMarker(new GPoint(-83.39978400,42.05932800),"
Carleton Country Day School
12707 Maxwell Road
Carleton, MI 48117
Co-ed school, PK-K
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Carleton Country Day School",'Carleton=' + Carleton.length); Petersburg[Petersburg.length] = createMarker(new GPoint(-83.70672200,41.90018800),"
Holiness Christian School
400 E Elm Street
Petersburg, MI 49270
Co-ed school, 1-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Holiness Christian School",'Petersburg=' + Petersburg.length); Monroe[Monroe.length] = createMarker(new GPoint(-83.42798800,41.99257700),"
Holy Ghost Lutheran School
3563 Heiss Road
Monroe, MI 48162
Co-ed school, PK-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Holy Ghost Lutheran School",'Monroe=' + Monroe.length); Monroe[Monroe.length] = createMarker(new GPoint(-83.42260000,41.90390000),"
Meadow Montessori School
1670 S Raisinville Road
Monroe, MI 48161
Co-ed school, PK-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Meadow Montessori School",'Monroe=' + Monroe.length); Lasalle[Lasalle.length] = createMarker(new GPoint(-83.38840000,41.94240000),"
Pathway Christian School
3418 Yargerville Rd.
Lasalle, MI 48162
Co-ed school, PK-7
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Pathway Christian School",'Lasalle=' + Lasalle.length); Temperance[Temperance.length] = createMarker(new GPoint(-83.65530400,41.79906300),"
St. Anthony Catholic School
4609 Saint Anthony Road
Temperance, MI 48182
Co-ed school, PK-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("St. Anthony Catholic School",'Temperance=' + Temperance.length); Monroe[Monroe.length] = createMarker(new GPoint(-83.39628400,41.91901800),"
St. Mary School
151 North Monroe Street
Monroe, MI 48162
Co-ed school, K-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("St. Mary School",'Monroe=' + Monroe.length); Newport[Newport.length] = createMarker(new GPoint(-83.29046200,41.99620600),"
St Charles Elementary School
8125 Swan Creek Road
Newport, MI 48166
Co-ed school, PK-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("St Charles Elementary School",'Newport=' + Newport.length); Monroe[Monroe.length] = createMarker(new GPoint(-83.40115000,41.91198800),"
St John Elementary School
521 S Monroe Street
Monroe, MI 48161
Co-ed school, K-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("St John Elementary School",'Monroe=' + Monroe.length); Erie[Erie.length] = createMarker(new GPoint(-83.49465400,41.79218700),"
St Joseph Catholic School
2238 Manhattan Street
Erie, MI 48133
Co-ed school, PK-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("St Joseph Catholic School",'Erie=' + Erie.length); Monroe[Monroe.length] = createMarker(new GPoint(-83.40481100,41.91778100),"
St Michael School
510 W Front Street
Monroe, MI 48161
Co-ed school, K-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("St Michael School",'Monroe=' + Monroe.length); Carleton[Carleton.length] = createMarker(new GPoint(-83.41831400,42.02476800),"
St Patrick Elementary School
2970 West Labo Road
Carleton, MI 48117
Co-ed school, PK-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("St Patrick Elementary School",'Carleton=' + Carleton.length); Temperance[Temperance.length] = createMarker(new GPoint(-83.56679000,41.73213200),"
State Line Christian School
6320 Lewis Avenue
Temperance, MI 48182
Co-ed school, PK-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("State Line Christian School",'Temperance=' + Temperance.length); Monroe[Monroe.length] = createMarker(new GPoint(-83.39624100,41.91206700),"
Trinity Lutheran School
315 Scott Street
Monroe, MI 48161
Co-ed school, PK-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Trinity Lutheran School",'Monroe=' + Monroe.length); Monroe[Monroe.length] = createMarker(new GPoint(-83.38397300,41.93620300),"
Zion Lutheran School
186 Cole Road
Monroe, MI 48162
Co-ed school, PK-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Zion Lutheran School",'Monroe=' + Monroe.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/////1/' + showArray); map.removeOverlays(Carleton); map.removeOverlays(Erie); map.removeOverlays(Lasalle); map.removeOverlays(Monroe); map.removeOverlays(Newport); map.removeOverlays(Petersburg); map.removeOverlays(Temperance); 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(Carleton);map.removeOverlays(Carleton); map.removeOverlays(Erie); map.removeOverlays(Lasalle); map.removeOverlays(Monroe); map.removeOverlays(Newport); map.removeOverlays(Petersburg); map.removeOverlays(Temperance); map.addOverlays(Carleton); centerByArray(Carleton, false, false); cntMarker += Carleton.length; map.addOverlays(Erie); centerByArray(Erie, false, false); cntMarker += Erie.length; map.addOverlays(Lasalle); centerByArray(Lasalle, false, false); cntMarker += Lasalle.length; map.addOverlays(Monroe); centerByArray(Monroe, false, false); cntMarker += Monroe.length; map.addOverlays(Newport); centerByArray(Newport, false, false); cntMarker += Newport.length; map.addOverlays(Petersburg); centerByArray(Petersburg, false, false); cntMarker += Petersburg.length; map.addOverlays(Temperance); centerByArray(Temperance, false, false); cntMarker += Temperance.length; centerByArray(Carleton,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=1&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; }