function addMarkers(){
mySelect = document.getElementById('selection');
Las_Vegas = [];Henderson = [];mySelect.options[mySelect.options.length] = new Option("Henderson schools",'all=Henderson');
mySelect.options[mySelect.options.length] = new Option("Las Vegas schools",'all=Las_Vegas');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Las_Vegas[Las_Vegas.length] = createMarker(new GPoint(-115.14066700,36.14505100),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Academy For Learning",'Las_Vegas=' + Las_Vegas.length);
Henderson[Henderson.length] = createMarker(new GPoint(-115.05602500,36.02341600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Achievement Academy, The",'Henderson=' + Henderson.length);
Las_Vegas[Las_Vegas.length] = createMarker(new GPoint(-115.13678400,36.15010800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bishop Gorman High School",'Las_Vegas=' + Las_Vegas.length);
Henderson[Henderson.length] = createMarker(new GPoint(-115.02976900,36.02817700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Black Mountain Christian School",'Henderson=' + Henderson.length);
Henderson[Henderson.length] = createMarker(new GPoint(-115.02976900,36.02817700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Black Mountain Fellowship",'Henderson=' + Henderson.length);
Las_Vegas[Las_Vegas.length] = createMarker(new GPoint(-115.24844000,36.08131600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Calvary Chapel Christian School",'Las_Vegas=' + Las_Vegas.length);
Las_Vegas[Las_Vegas.length] = createMarker(new GPoint(-115.30544300,36.19922600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Dr. Miriam and Sheldon G. Adelson Educational Campus",'Las_Vegas=' + Las_Vegas.length);
Las_Vegas[Las_Vegas.length] = createMarker(new GPoint(-115.12763100,36.15967100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Exodus Christian Academy",'Las_Vegas=' + Las_Vegas.length);
Las_Vegas[Las_Vegas.length] = createMarker(new GPoint(-115.31588400,36.15396300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Faith Lutheran Jr/sr High School",'Las_Vegas=' + Las_Vegas.length);
Las_Vegas[Las_Vegas.length] = createMarker(new GPoint(-115.08672900,36.19386000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Gateway Christian Academy",'Las_Vegas=' + Las_Vegas.length);
Las_Vegas[Las_Vegas.length] = createMarker(new GPoint(-115.27977200,36.13503700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Glad Tidings Christian School",'Las_Vegas=' + Las_Vegas.length);
Henderson[Henderson.length] = createMarker(new GPoint(-115.06689800,36.06880800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("GV Christian School",'Henderson=' + Henderson.length);
Henderson[Henderson.length] = createMarker(new GPoint(-115.09041700,35.98691500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Henderson International School",'Henderson=' + Henderson.length);
Las_Vegas[Las_Vegas.length] = createMarker(new GPoint(-115.13976000,36.17182800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("House Of Knowledge Christian Academy",'Las_Vegas=' + Las_Vegas.length);
Las_Vegas[Las_Vegas.length] = createMarker(new GPoint(-115.27878300,36.16183700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("La Madre Mountain School",'Las_Vegas=' + Las_Vegas.length);
Henderson[Henderson.length] = createMarker(new GPoint(-114.97429100,36.04574200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lake Mead Christian Academy",'Henderson=' + Henderson.length);
Las_Vegas[Las_Vegas.length] = createMarker(new GPoint(-115.22461800,36.15166300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Las Vegas Jr Academy",'Las_Vegas=' + Las_Vegas.length);
Las_Vegas[Las_Vegas.length] = createMarker(new GPoint(-115.23645400,36.19568800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Liberty Baptist Academy",'Las_Vegas=' + Las_Vegas.length);
Las_Vegas[Las_Vegas.length] = createMarker(new GPoint(-115.28003800,36.19630800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Meadows School",'Las_Vegas=' + Las_Vegas.length);
Las_Vegas[Las_Vegas.length] = createMarker(new GPoint(-115.09785800,36.07128600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Montessori Visions Academy",'Las_Vegas=' + Las_Vegas.length);
Las_Vegas[Las_Vegas.length] = createMarker(new GPoint(-115.09258100,36.17365700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mountain View Christian Schools",'Las_Vegas=' + Las_Vegas.length);
Las_Vegas[Las_Vegas.length] = createMarker(new GPoint(-115.13293200,36.16464700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("New Life Christian Academy",'Las_Vegas=' + Las_Vegas.length);
Las_Vegas[Las_Vegas.length] = createMarker(new GPoint(-115.11580000,36.12596300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Paradise Christian Academy",'Las_Vegas=' + Las_Vegas.length);
Las_Vegas[Las_Vegas.length] = createMarker(new GPoint(-115.24545300,36.12584200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Spring Mountain Treatment Center",'Las_Vegas=' + Las_Vegas.length);
Las_Vegas[Las_Vegas.length] = createMarker(new GPoint(-115.13319600,36.10953700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("University Baptist Academy",'Las_Vegas=' + Las_Vegas.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/////2/' + showArray);
map.removeOverlays(Henderson);
map.removeOverlays(Las_Vegas);
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(Las_Vegas);map.removeOverlays(Henderson);
map.removeOverlays(Las_Vegas);
map.addOverlays(Henderson);
centerByArray(Henderson, false, false);
cntMarker += Henderson.length;
map.addOverlays(Las_Vegas);
centerByArray(Las_Vegas, false, false);
cntMarker += Las_Vegas.length;
centerByArray(Las_Vegas,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=2&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;
}