function addMarkers(){ mySelect = document.getElementById('selection'); Saint_Louis = [];Kirkwood = [];Fenton = [];Hazelwood = [];Saint_Ann = [];Sunset_Hills = [];mySelect.options[mySelect.options.length] = new Option("Fenton Schools",'all=Fenton'); mySelect.options[mySelect.options.length] = new Option("Hazelwood Schools",'all=Hazelwood'); mySelect.options[mySelect.options.length] = new Option("Kirkwood Schools",'all=Kirkwood'); mySelect.options[mySelect.options.length] = new Option("Saint Ann Schools",'all=Saint_Ann'); mySelect.options[mySelect.options.length] = new Option("Saint Louis Schools",'all=Saint_Louis'); mySelect.options[mySelect.options.length] = new Option("Sunset Hills Schools",'all=Sunset_Hills'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); var tmpLatLng=0; var tmpLen=0; tmpLatLng=new GLatLng(38.69875100000000145,-90.4235170000000039); tmpLen=Saint_Louis.length; Saint_Louis[tmpLen] = createMarker(tmpLatLng,"
Hickey College
940 Westport Plaza
Saint Louis, MO 63146

[ View School Profile ]
",iconRd); Saint_Louis[tmpLen].point = tmpLatLng; mySelect.options[mySelect.options.length] = new Option("Hickey College",'Saint_Louis=' + Saint_Louis.length); tmpLatLng=new GLatLng(38.60211900000000184,-90.3896170000000012); tmpLen=Saint_Louis.length; Saint_Louis[tmpLen] = createMarker(tmpLatLng,"
Missouri College
10121 Manchester Rd
Saint Louis, MO 63122

[ View School Profile ]
",iconRd); Saint_Louis[tmpLen].point = tmpLatLng; mySelect.options[mySelect.options.length] = new Option("Missouri College",'Saint_Louis=' + Saint_Louis.length); tmpLatLng=new GLatLng(38.77015500000000258,-90.2845750000000037); tmpLen=Saint_Louis.length; Saint_Louis[tmpLen] = createMarker(tmpLatLng,"
Saint Louis Community College-florissant Valley
3400 Pershall Rd
Saint Louis, MO 63135

[ View School Profile ]
",iconGr); Saint_Louis[tmpLen].point = tmpLatLng; mySelect.options[mySelect.options.length] = new Option("Saint Louis Community College-florissant Valley",'Saint_Louis=' + Saint_Louis.length); tmpLatLng=new GLatLng(38.56875200000000347,-90.3899169999999969); tmpLen=Kirkwood.length; Kirkwood[tmpLen] = createMarker(tmpLatLng,"
Saint Louis Community College-meramec
11333 Big Bend Blvd
Kirkwood, MO 63122

[ View School Profile ]
",iconGr); Kirkwood[tmpLen].point = tmpLatLng; mySelect.options[mySelect.options.length] = new Option("Saint Louis Community College-meramec",'Kirkwood=' + Kirkwood.length); tmpLatLng=new GLatLng(38.52335599999999971,-90.4717830000000020); tmpLen=Fenton.length; Fenton[tmpLen] = createMarker(tmpLatLng,"
Sanford-brown College
1345 Smizer Mill Road
Fenton, MO 63026

[ View School Profile ]
",iconRd); Fenton[tmpLen].point = tmpLatLng; mySelect.options[mySelect.options.length] = new Option("Sanford-brown College",'Fenton=' + Fenton.length); tmpLatLng=new GLatLng(38.78084199999999981,-90.3619089999999971); tmpLen=Hazelwood.length; Hazelwood[tmpLen] = createMarker(tmpLatLng,"
Sanford-brown College
75 Village Square
Hazelwood, MO 63042

[ View School Profile ]
",iconRd); Hazelwood[tmpLen].point = tmpLatLng; mySelect.options[mySelect.options.length] = new Option("Sanford-brown College",'Hazelwood=' + Hazelwood.length); tmpLatLng=new GLatLng(38.72756499999999846,-90.3802450000000021); tmpLen=Saint_Ann.length; Saint_Ann[tmpLen] = createMarker(tmpLatLng,"
Vatterott College
3925 Industrial Drive
Saint Ann, MO 63074

[ View School Profile ]
",iconRd); Saint_Ann[tmpLen].point = tmpLatLng; mySelect.options[mySelect.options.length] = new Option("Vatterott College",'Saint_Ann=' + Saint_Ann.length); tmpLatLng=new GLatLng(38.52136899999999997,-90.4177810000000050); tmpLen=Sunset_Hills.length; Sunset_Hills[tmpLen] = createMarker(tmpLatLng,"
Vatterott College
12970 Maurer Industrial Dr
Sunset Hills, MO 63127

[ View School Profile ]
",iconRd); Sunset_Hills[tmpLen].point = tmpLatLng; mySelect.options[mySelect.options.length] = new Option("Vatterott College",'Sunset_Hills=' + Sunset_Hills.length); map.removeOverlays(Fenton); map.removeOverlays(Hazelwood); map.removeOverlays(Kirkwood); map.removeOverlays(Saint_Ann); map.removeOverlays(Saint_Louis); map.removeOverlays(Sunset_Hills); setTimeout(function(){map.addOverlays(Fenton)},1000); setTimeout(function(){map.addOverlays(Hazelwood)},1000); setTimeout(function(){map.addOverlays(Kirkwood)},1000); setTimeout(function(){map.addOverlays(Saint_Ann)},1000); setTimeout(function(){map.addOverlays(Saint_Louis)},1000); setTimeout(function(){map.addOverlays(Sunset_Hills)},1000); maxLng = -90.2845750000000037; maxLat = 38.78084199999999981; minLng = -90.4717830000000020; minLat = 38.52136899999999997; reCenterMap(); } // End addStateMarkers JavaScript Function //open all when map is defined function openAll() { if (map) { selectChange("all"); } else { setTimeout("openAll()",200); } } // 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].point.x; var markLat = myArray[i].point.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].point.x; maxLat = myArray[0].point.y; minLng = myArray[0].point.x; minLat = myArray[0].point.y; } // Recenter map based on global max/mins function reCenterMap(){ //alert('#' + minLat + '#' + minLng + '#' + maxLat + '#' + maxLng); 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) { if (selection.options) { var _openNewWindow=true; var myVal = selection.options[selection.selectedIndex].value; } else { var _openNewWindow=false; var myVal=selection; } 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('schools-by-distance') == -1) window.open(location.href + '/map/all'); else window.open('/search////all'); map.removeOverlays(Fenton); map.removeOverlays(Hazelwood); map.removeOverlays(Kirkwood); map.removeOverlays(Saint_Ann); map.removeOverlays(Saint_Louis); map.removeOverlays(Sunset_Hills); 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(Saint_Louis);map.removeOverlays(Fenton); map.removeOverlays(Hazelwood); map.removeOverlays(Kirkwood); map.removeOverlays(Saint_Ann); map.removeOverlays(Saint_Louis); map.removeOverlays(Sunset_Hills); map.addOverlays(Fenton); centerByArray(Fenton, false, false); cntMarker += Fenton.length; map.addOverlays(Hazelwood); centerByArray(Hazelwood, false, false); cntMarker += Hazelwood.length; map.addOverlays(Kirkwood); centerByArray(Kirkwood, false, false); cntMarker += Kirkwood.length; map.addOverlays(Saint_Ann); centerByArray(Saint_Ann, false, false); cntMarker += Saint_Ann.length; map.addOverlays(Saint_Louis); centerByArray(Saint_Louis, false, false); cntMarker += Saint_Louis.length; map.addOverlays(Sunset_Hills); centerByArray(Sunset_Hills, false, false); cntMarker += Sunset_Hills.length; reCenterMap(); //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'); } } function createMarker(point, label, icon){ var marker = new GMarker(point, icon); var html = label; GEvent.addListener(marker, "click", function() { marker.openInfoWindowHtml(html); }); return marker; }