function addMarkers(){ mySelect = document.getElementById('selection'); Fruitport = [];Muskegon = [];Holton = [];Ravenna = [];Montague = [];mySelect.options[mySelect.options.length] = new Option("Fruitport schools",'all=Fruitport'); mySelect.options[mySelect.options.length] = new Option("Holton schools",'all=Holton'); mySelect.options[mySelect.options.length] = new Option("Montague schools",'all=Montague'); mySelect.options[mySelect.options.length] = new Option("Muskegon schools",'all=Muskegon'); mySelect.options[mySelect.options.length] = new Option("Ravenna schools",'all=Ravenna'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Fruitport[Fruitport.length] = createMarker(new GPoint(-86.17357500,43.14815500),"
Calvary Christian Schools
5873 Kendra Road
Fruitport, MI 49415
Co-ed school, PK-12
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Calvary Christian Schools",'Fruitport=' + Fruitport.length); Muskegon[Muskegon.length] = createMarker(new GPoint(-86.21411100,43.23170400),"
Grace Christian Academy
1128 Roberts Street
Muskegon, MI 49442
Co-ed school, K-9
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Grace Christian Academy",'Muskegon=' + Muskegon.length); Holton[Holton.length] = createMarker(new GPoint(-86.08068800,43.41004200),"
Holton Ev Lutheran School
6655 Marvin Rd
Holton, MI 49425
Co-ed school, K-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Holton Ev Lutheran School",'Holton=' + Holton.length); Muskegon[Muskegon.length] = createMarker(new GPoint(-86.26409900,43.15727800),"
Michigan Dunes Montessori
5248 Henry Street
Muskegon, MI 49441
Co-ed school, PK-1
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Michigan Dunes Montessori",'Muskegon=' + Muskegon.length); Muskegon[Muskegon.length] = createMarker(new GPoint(-86.27162800,43.21983800),"
Muskegon Catholic Central Elementary School
1145 W Laketon Avenue
Muskegon, MI 49441
Co-ed school, PK-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Muskegon Catholic Central Elementary School",'Muskegon=' + Muskegon.length); Muskegon[Muskegon.length] = createMarker(new GPoint(-86.22151100,43.23162600),"
Muskegon Christian School
1220 Eastgate Street
Muskegon, MI 49442
Co-ed school, PK-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Muskegon Christian School",'Muskegon=' + Muskegon.length); Muskegon[Muskegon.length] = createMarker(new GPoint(-86.16844900,43.21263700),"
Muskegon Sda School
3050 Evanston Avenue
Muskegon, MI 49442
Co-ed school, 1-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Muskegon Sda School",'Muskegon=' + Muskegon.length); Ravenna[Ravenna.length] = createMarker(new GPoint(-85.95700000,43.20500000),"
St Catherine School
Po Box 216 3376 Thomas Street
Ravenna, MI 49451
Co-ed school, K-6
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("St Catherine School",'Ravenna=' + Ravenna.length); Montague[Montague.length] = createMarker(new GPoint(-86.36985900,43.41866300),"
St James Catholic School
5149 Dowling Street
Montague, MI 49437
Co-ed school, K-5
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("St James Catholic School",'Montague=' + Montague.length); Muskegon[Muskegon.length] = createMarker(new GPoint(-86.24962600,43.22186300),"
St Michael Elementary School
215 W Dale Avenue
Muskegon, MI 49441
Co-ed school, PK-5
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("St Michael Elementary School",'Muskegon=' + Muskegon.length); Muskegon[Muskegon.length] = createMarker(new GPoint(-86.27908100,43.19380900),"
West Shore Lutheran School
3225 Roosevelt Road
Muskegon, MI 49441
Co-ed school, PK-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("West Shore Lutheran School",'Muskegon=' + Muskegon.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(Fruitport); map.removeOverlays(Holton); map.removeOverlays(Montague); map.removeOverlays(Muskegon); map.removeOverlays(Ravenna); 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(Fruitport);map.removeOverlays(Fruitport); map.removeOverlays(Holton); map.removeOverlays(Montague); map.removeOverlays(Muskegon); map.removeOverlays(Ravenna); map.addOverlays(Fruitport); centerByArray(Fruitport, false, false); cntMarker += Fruitport.length; map.addOverlays(Holton); centerByArray(Holton, false, false); cntMarker += Holton.length; map.addOverlays(Montague); centerByArray(Montague, false, false); cntMarker += Montague.length; map.addOverlays(Muskegon); centerByArray(Muskegon, false, false); cntMarker += Muskegon.length; map.addOverlays(Ravenna); centerByArray(Ravenna, false, false); cntMarker += Ravenna.length; centerByArray(Fruitport,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; }