function addMarkers() { mySelect = document.getElementById('selection'); Hanoverrnie = [];Baltimore = [];Edgewater = [];Frederick = [];mySelect.options[mySelect.options.length] = new Option("Baltimore charter schools",'all=Baltimore'); mySelect.options[mySelect.options.length] = new Option("Edgewater charter schools",'all=Edgewater'); mySelect.options[mySelect.options.length] = new Option("Frederick charter schools",'all=Frederick'); mySelect.options[mySelect.options.length] = new Option("Hanoverrnie charter schools",'all=Hanoverrnie'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Hanoverrnie[Hanoverrnie.length] = createMarker(new GPoint(-76.70574000,39.16657600),"
",iconBl); mySelect.options[mySelect.options.length] = new Option("Chesapeake Science Point",'Hanoverrnie=' + Hanoverrnie.length); Baltimore[Baltimore.length] = createMarker(new GPoint(-76.53442200,39.34903600),"",iconRd); mySelect.options[mySelect.options.length] = new Option("City Neighborhood Charter School",'Baltimore=' + Baltimore.length); Baltimore[Baltimore.length] = createMarker(new GPoint(-76.59726715,39.29015350),"",iconRd); mySelect.options[mySelect.options.length] = new Option("City Springs Elementary School",'Baltimore=' + Baltimore.length); Baltimore[Baltimore.length] = createMarker(new GPoint(-76.58702087,39.30712128),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Collington Square Elementary School",'Baltimore=' + Baltimore.length); Baltimore[Baltimore.length] = createMarker(new GPoint(-76.59676361,39.28223801),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Crossroads School",'Baltimore=' + Baltimore.length); Baltimore[Baltimore.length] = createMarker(new GPoint(-76.67079926,39.31060028),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Empowerment Academy",'Baltimore=' + Baltimore.length); Baltimore[Baltimore.length] = createMarker(new GPoint(-76.57595825,39.28615189),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Hampstead Hill Elementary School",'Baltimore=' + Baltimore.length); Baltimore[Baltimore.length] = createMarker(new GPoint(-76.60000800,39.29419400),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Inner Harbor East Academy",'Baltimore=' + Baltimore.length); Edgewater[Edgewater.length] = createMarker(new GPoint(-76.57057000,38.94029600),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Kipp Harbor Academy At Annapolis",'Edgewater=' + Edgewater.length); Baltimore[Baltimore.length] = createMarker(new GPoint(-76.65878296,39.34461212),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Kipp Ujima Village Academy",'Baltimore=' + Baltimore.length); Baltimore[Baltimore.length] = createMarker(new GPoint(-76.62203217,39.30820847),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Midtown Academy",'Baltimore=' + Baltimore.length); Frederick[Frederick.length] = createMarker(new GPoint(-77.38664246,39.44884872),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Monocacy Valley Montessori School",'Frederick=' + Frederick.length); Baltimore[Baltimore.length] = createMarker(new GPoint(-76.59177400,39.34562900),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Northwood Community Academy",'Baltimore=' + Baltimore.length); Baltimore[Baltimore.length] = createMarker(new GPoint(-76.57908500,39.29284500),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Patterson Park Public Charter School",'Baltimore=' + Baltimore.length); Baltimore[Baltimore.length] = createMarker(new GPoint(-76.63349300,39.28766300),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Southwest Baltimore Charter School",'Baltimore=' + Baltimore.length); maxLng = -76.53442200; maxLat = 39.44884872; minLng = -77.38664246; minLat = 38.94029600; reCenterMap(); map.removeOverlays(Baltimore); map.removeOverlays(Edgewater); map.removeOverlays(Frederick); map.removeOverlays(Hanoverrnie); setTimeout(function(){map.addOverlays(Baltimore)},1000); setTimeout(function(){map.addOverlays(Edgewater)},1000); setTimeout(function(){map.addOverlays(Frederick)},1000); setTimeout(function(){map.addOverlays(Hanoverrnie)},1000); } // 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,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) { 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////' + showArray); map.removeOverlays(Baltimore); map.removeOverlays(Edgewater); map.removeOverlays(Frederick); map.removeOverlays(Hanoverrnie); 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(Hanoverrnie);map.removeOverlays(Baltimore); map.removeOverlays(Edgewater); map.removeOverlays(Frederick); map.removeOverlays(Hanoverrnie); map.addOverlays(Baltimore); centerByArray(Baltimore, false, false); cntMarker += Baltimore.length; map.addOverlays(Edgewater); centerByArray(Edgewater, false, false); cntMarker += Edgewater.length; map.addOverlays(Frederick); centerByArray(Frederick, false, false); cntMarker += Frederick.length; map.addOverlays(Hanoverrnie); centerByArray(Hanoverrnie, false, false); cntMarker += Hanoverrnie.length; centerByArray(Hanoverrnie,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'); } }