function addMarkers(){ mySelect = document.getElementById('selection'); Sebewaing = [];Pigeon = [];Harbor_Beach = [];Ruth = [];Port_Hope = [];Cass_City = [];mySelect.options[mySelect.options.length] = new Option("Cass City schools",'all=Cass_City'); mySelect.options[mySelect.options.length] = new Option("Harbor Beach schools",'all=Harbor_Beach'); mySelect.options[mySelect.options.length] = new Option("Pigeon schools",'all=Pigeon'); mySelect.options[mySelect.options.length] = new Option("Port Hope schools",'all=Port_Hope'); mySelect.options[mySelect.options.length] = new Option("Ruth schools",'all=Ruth'); mySelect.options[mySelect.options.length] = new Option("Sebewaing schools",'all=Sebewaing'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Sebewaing[Sebewaing.length] = createMarker(new GPoint(-83.44335000,43.72594000),"
Christ The King Lutheran School
612 E Bay St
Sebewaing, MI 48759
Co-ed school, PK-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Christ The King Lutheran School",'Sebewaing=' + Sebewaing.length); Pigeon[Pigeon.length] = createMarker(new GPoint(-83.27160000,43.82550000),"
Cross Lutheran School
200 Ruppert Street
Pigeon, MI 48755
Co-ed school, PK-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Cross Lutheran School",'Pigeon=' + Pigeon.length); Sebewaing[Sebewaing.length] = createMarker(new GPoint(-83.44891400,43.73038800),"
New Salem Evangelical Lutheran School
214 E Grove Street
Sebewaing, MI 48759
Co-ed school, K-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("New Salem Evangelical Lutheran School",'Sebewaing=' + Sebewaing.length); Harbor_Beach[Harbor_Beach.length] = createMarker(new GPoint(-82.65277200,43.84006300),"
Our Lady Of Lake Huron School
222 Court Street
Harbor Beach, MI 48441
Co-ed school, K-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Our Lady Of Lake Huron School",'Harbor_Beach=' + Harbor_Beach.length); Ruth[Ruth.length] = createMarker(new GPoint(-82.73677800,43.71567500),"
Saints Peter And Paul Catholic
7135 E. Atwater Rd
Ruth, MI 48470
Co-ed school, K-7
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Saints Peter And Paul Catholic",'Ruth=' + Ruth.length); Pigeon[Pigeon.length] = createMarker(new GPoint(-83.27570200,43.84430600),"
St John Lutheran School
7379 Berne Road
Pigeon, MI 48755
Co-ed school, K-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("St John Lutheran School",'Pigeon=' + Pigeon.length); Port_Hope[Port_Hope.length] = createMarker(new GPoint(-82.71825000,43.94128300),"
St John Lutheran School
7885 State Road
Port Hope, MI 48468
Co-ed school, PK-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("St John Lutheran School",'Port_Hope=' + Port_Hope.length); Cass_City[Cass_City.length] = createMarker(new GPoint(-83.06920900,43.57501900),"
Thumb Parochial School
3124 Huron Line Road
Cass City, MI 48726
Co-ed school, 1-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Thumb Parochial School",'Cass_City=' + Cass_City.length); Harbor_Beach[Harbor_Beach.length] = createMarker(new GPoint(-82.65390200,43.84592400),"
Zion Lutheran School
299 Garden St
Harbor Beach, MI 48441
Co-ed school, 4-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Zion Lutheran School",'Harbor_Beach=' + Harbor_Beach.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(Cass_City); map.removeOverlays(Harbor_Beach); map.removeOverlays(Pigeon); map.removeOverlays(Port_Hope); map.removeOverlays(Ruth); map.removeOverlays(Sebewaing); 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(Sebewaing);map.removeOverlays(Cass_City); map.removeOverlays(Harbor_Beach); map.removeOverlays(Pigeon); map.removeOverlays(Port_Hope); map.removeOverlays(Ruth); map.removeOverlays(Sebewaing); map.addOverlays(Cass_City); centerByArray(Cass_City, false, false); cntMarker += Cass_City.length; map.addOverlays(Harbor_Beach); centerByArray(Harbor_Beach, false, false); cntMarker += Harbor_Beach.length; map.addOverlays(Pigeon); centerByArray(Pigeon, false, false); cntMarker += Pigeon.length; map.addOverlays(Port_Hope); centerByArray(Port_Hope, false, false); cntMarker += Port_Hope.length; map.addOverlays(Ruth); centerByArray(Ruth, false, false); cntMarker += Ruth.length; map.addOverlays(Sebewaing); centerByArray(Sebewaing, false, false); cntMarker += Sebewaing.length; centerByArray(Sebewaing,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; }