function addMarkers(){
mySelect = document.getElementById('selection');
Chesapeake = [];mySelect.options[mySelect.options.length] = new Option("Chesapeake schools",'all=Chesapeake');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Chesapeake[Chesapeake.length] = createMarker(new GPoint(-76.26597100,36.71013700),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("A World Of Children",'Chesapeake=' + Chesapeake.length);
Chesapeake[Chesapeake.length] = createMarker(new GPoint(-76.23869800,36.76758700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Apple Tree Learning Center",'Chesapeake=' + Chesapeake.length);
Chesapeake[Chesapeake.length] = createMarker(new GPoint(-76.18541500,36.75897500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Atlantic Shores Christian School",'Chesapeake=' + Chesapeake.length);
Chesapeake[Chesapeake.length] = createMarker(new GPoint(-76.22378900,36.78072800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Basics Primary School & Daycare",'Chesapeake=' + Chesapeake.length);
Chesapeake[Chesapeake.length] = createMarker(new GPoint(-76.26932400,36.78536300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cathedral Of Faith Christian School",'Chesapeake=' + Chesapeake.length);
Chesapeake[Chesapeake.length] = createMarker(new GPoint(-76.27171900,36.71097000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cedar Road Christian Academy",'Chesapeake=' + Chesapeake.length);
Chesapeake[Chesapeake.length] = createMarker(new GPoint(-76.23960000,36.81420000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Chesapeake Christian Academy",'Chesapeake=' + Chesapeake.length);
Chesapeake[Chesapeake.length] = createMarker(new GPoint(-76.25623200,36.71653300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Chesapeake Montessori Preschool",'Chesapeake=' + Chesapeake.length);
Chesapeake[Chesapeake.length] = createMarker(new GPoint(-76.40931300,36.85715800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Churchland Country Day School",'Chesapeake=' + Chesapeake.length);
Chesapeake[Chesapeake.length] = createMarker(new GPoint(-76.22832600,36.81819400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cornerstone Christian School",'Chesapeake=' + Chesapeake.length);
Chesapeake[Chesapeake.length] = createMarker(new GPoint(-76.24744800,36.82502600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Fairview Baptist Christian Academy",'Chesapeake=' + Chesapeake.length);
Chesapeake[Chesapeake.length] = createMarker(new GPoint(-76.34326400,36.77920400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Faith Diamond Christian Academy",'Chesapeake=' + Chesapeake.length);
Chesapeake[Chesapeake.length] = createMarker(new GPoint(-76.25062500,36.71456300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Great Bridge Presbyterian Preschool",'Chesapeake=' + Chesapeake.length);
Chesapeake[Chesapeake.length] = createMarker(new GPoint(-76.23443400,36.70634800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Great Bridge Preschool",'Chesapeake=' + Chesapeake.length);
Chesapeake[Chesapeake.length] = createMarker(new GPoint(-76.22662400,36.67559000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Great Hope Baptist School",'Chesapeake=' + Chesapeake.length);
Chesapeake[Chesapeake.length] = createMarker(new GPoint(-76.23223600,36.73767700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Greenbrier Christian Academy",'Chesapeake=' + Chesapeake.length);
Chesapeake[Chesapeake.length] = createMarker(new GPoint(-76.22438400,36.75155500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Greenbrier Enrichment Ctr & School",'Chesapeake=' + Chesapeake.length);
Chesapeake[Chesapeake.length] = createMarker(new GPoint(-76.21338500,36.74239000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Greenbrier Manor School",'Chesapeake=' + Chesapeake.length);
Chesapeake[Chesapeake.length] = createMarker(new GPoint(-76.22603000,36.76424400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Greenbrier Montessori School",'Chesapeake=' + Chesapeake.length);
Chesapeake[Chesapeake.length] = createMarker(new GPoint(-76.20492400,36.75840800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("ICW Baptist Church School",'Chesapeake=' + Chesapeake.length);
Chesapeake[Chesapeake.length] = createMarker(new GPoint(-76.39164200,36.80047200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Leaders Of Tomorrow Academy",'Chesapeake=' + Chesapeake.length);
Chesapeake[Chesapeake.length] = createMarker(new GPoint(-76.20376500,36.76743400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Montessori Academy Of Virginia",'Chesapeake=' + Chesapeake.length);
Chesapeake[Chesapeake.length] = createMarker(new GPoint(-76.26581600,36.71736200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mount Lebanon Christian Academy",'Chesapeake=' + Chesapeake.length);
Chesapeake[Chesapeake.length] = createMarker(new GPoint(-76.17551800,36.71476200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mt Pleasant Christian School",'Chesapeake=' + Chesapeake.length);
Chesapeake[Chesapeake.length] = createMarker(new GPoint(-76.24302300,36.80144300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Providence Baptist School",'Chesapeake=' + Chesapeake.length);
Chesapeake[Chesapeake.length] = createMarker(new GPoint(-76.43904000,36.80277800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("StoneBridge School",'Chesapeake=' + Chesapeake.length);
Chesapeake[Chesapeake.length] = createMarker(new GPoint(-76.18547900,36.75789400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Tidewater Adventist Academy",'Chesapeake=' + Chesapeake.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(Chesapeake);
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(Chesapeake);map.removeOverlays(Chesapeake);
map.addOverlays(Chesapeake);
centerByArray(Chesapeake, false, false);
cntMarker += Chesapeake.length;
centerByArray(Chesapeake,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;
}