function addMarkers()
{
mySelect = document.getElementById('selection');
Baltimore = [];Baltimore[Baltimore.length] = createMarker(new GPoint(-76.60015106,39.32482147),"
",iconRd);
mySelect.options[mySelect.options.length] = new Option("Abbottston Elementary School",'Baltimore=' + Baltimore.length);
Baltimore[Baltimore.length] = createMarker(new GPoint(-76.59509277,39.32729340),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Baltimore City College High School",'Baltimore=' + Baltimore.length);
Baltimore[Baltimore.length] = createMarker(new GPoint(-76.61126709,39.32354355),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Barclay Elementary Middle School",'Baltimore=' + Baltimore.length);
Baltimore[Baltimore.length] = createMarker(new GPoint(-76.60538483,39.31282425),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Cecil Elementary School",'Baltimore=' + Baltimore.length);
Baltimore[Baltimore.length] = createMarker(new GPoint(-76.60152435,39.32046890),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Coldstream Park Elementary School",'Baltimore=' + Baltimore.length);
Baltimore[Baltimore.length] = createMarker(new GPoint(-76.61369324,39.31317902),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Dallas F. Nicholas Senior Elementary School",'Baltimore=' + Baltimore.length);
Baltimore[Baltimore.length] = createMarker(new GPoint(-76.59375763,39.31825256),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Fairmount-harford High School",'Baltimore=' + Baltimore.length);
Baltimore[Baltimore.length] = createMarker(new GPoint(-76.61087799,39.27746582),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Federal Hill Elementary School",'Baltimore=' + Baltimore.length);
Baltimore[Baltimore.length] = createMarker(new GPoint(-76.61531830,39.31953812),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Margaret Brent Elementary School",'Baltimore=' + Baltimore.length);
Baltimore[Baltimore.length] = createMarker(new GPoint(-76.58925629,39.33105087),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mergenthaler Vocational-technical High School",'Baltimore=' + Baltimore.length);
Baltimore[Baltimore.length] = createMarker(new GPoint(-76.58623505,39.32748032),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Montebello Elementary School",'Baltimore=' + Baltimore.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.56226349,39.36687088),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Stadium School",'Baltimore=' + Baltimore.length);
Baltimore[Baltimore.length] = createMarker(new GPoint(-76.60610962,39.32976151),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Waverly Career Center",'Baltimore=' + Baltimore.length);
Baltimore[Baltimore.length] = createMarker(new GPoint(-76.60377502,39.33003998),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Waverly Elementary School",'Baltimore=' + Baltimore.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,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.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(Baltimore);map.removeOverlays(Baltimore);
map.addOverlays(Baltimore);
centerByArray(Baltimore, false, false);
cntMarker += Baltimore.length;
centerByArray(Baltimore,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');
}
}