function addMarkers(){
mySelect = document.getElementById('selection');
Silver_City = [];Albuquerque = [];Truth_Or_Consequences = [];Las_Cruces = [];Clovis = [];Rio_Rancho = [];Tijeras = [];Edgewood = [];Roswell = [];Gallup = [];Belen = [];Estancia = [];Santa_Fe = [];Rehoboth = [];Ruidoso_Downs = [];Zuni = [];mySelect.options[mySelect.options.length] = new Option("Albuquerque schools",'all=Albuquerque');
mySelect.options[mySelect.options.length] = new Option("Belen schools",'all=Belen');
mySelect.options[mySelect.options.length] = new Option("Clovis schools",'all=Clovis');
mySelect.options[mySelect.options.length] = new Option("Edgewood schools",'all=Edgewood');
mySelect.options[mySelect.options.length] = new Option("Estancia schools",'all=Estancia');
mySelect.options[mySelect.options.length] = new Option("Gallup schools",'all=Gallup');
mySelect.options[mySelect.options.length] = new Option("Las Cruces schools",'all=Las_Cruces');
mySelect.options[mySelect.options.length] = new Option("Rehoboth schools",'all=Rehoboth');
mySelect.options[mySelect.options.length] = new Option("Rio Rancho schools",'all=Rio_Rancho');
mySelect.options[mySelect.options.length] = new Option("Roswell schools",'all=Roswell');
mySelect.options[mySelect.options.length] = new Option("Ruidoso Downs schools",'all=Ruidoso_Downs');
mySelect.options[mySelect.options.length] = new Option("Santa Fe schools",'all=Santa_Fe');
mySelect.options[mySelect.options.length] = new Option("Silver City schools",'all=Silver_City');
mySelect.options[mySelect.options.length] = new Option("Tijeras schools",'all=Tijeras');
mySelect.options[mySelect.options.length] = new Option("Truth Or Consequences schools",'all=Truth_Or_Consequences');
mySelect.options[mySelect.options.length] = new Option("Zuni schools",'all=Zuni');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Silver_City[Silver_City.length] = createMarker(new GPoint(-108.27845000,32.77905600),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Agape Community Christian School",'Silver_City=' + Silver_City.length);
Albuquerque[Albuquerque.length] = createMarker(new GPoint(-106.56990000,35.15430000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Albuquerque Christian School",'Albuquerque=' + Albuquerque.length);
Truth_Or_Consequences[Truth_Or_Consequences.length] = createMarker(new GPoint(-107.26695100,33.12195200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Apple Tree Educational Center",'Truth_Or_Consequences=' + Truth_Or_Consequences.length);
Las_Cruces[Las_Cruces.length] = createMarker(new GPoint(-106.75363200,32.29470800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Calvary Christian Academy",'Las_Cruces=' + Las_Cruces.length);
Clovis[Clovis.length] = createMarker(new GPoint(-103.20533900,34.40523000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Clovis Christian School",'Clovis=' + Clovis.length);
Las_Cruces[Las_Cruces.length] = createMarker(new GPoint(-106.75769000,32.29047000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("College Heights Kindergarten",'Las_Cruces=' + Las_Cruces.length);
Las_Cruces[Las_Cruces.length] = createMarker(new GPoint(-106.75743500,32.29047400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Colleges Heights Kindergarten",'Las_Cruces=' + Las_Cruces.length);
Rio_Rancho[Rio_Rancho.length] = createMarker(new GPoint(-106.65421600,35.23279800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Covenant School Of Rio Rancho",'Rio_Rancho=' + Rio_Rancho.length);
Albuquerque[Albuquerque.length] = createMarker(new GPoint(-106.69385800,35.15434900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cross Of Hope Lutheran School",'Albuquerque=' + Albuquerque.length);
Albuquerque[Albuquerque.length] = createMarker(new GPoint(-106.51208100,35.07926300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("East Gate Kids",'Albuquerque=' + Albuquerque.length);
Tijeras[Tijeras.length] = createMarker(new GPoint(-106.28855900,34.92670000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("East Mountain Christian Academy",'Tijeras=' + Tijeras.length);
Albuquerque[Albuquerque.length] = createMarker(new GPoint(-106.52433100,35.11793700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Eastern Hills Christian Academy",'Albuquerque=' + Albuquerque.length);
Edgewood[Edgewood.length] = createMarker(new GPoint(-106.19300000,35.08160000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Edgewood Christian School",'Edgewood=' + Edgewood.length);
Albuquerque[Albuquerque.length] = createMarker(new GPoint(-106.72739600,35.08374000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("First Fruits Christian Academy",'Albuquerque=' + Albuquerque.length);
Roswell[Roswell.length] = createMarker(new GPoint(-104.52550000,33.39670000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Gateway Christian School",'Roswell=' + Roswell.length);
Gallup[Gallup.length] = createMarker(new GPoint(-108.72698000,35.51780000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Hilltop Christian",'Gallup=' + Gallup.length);
Albuquerque[Albuquerque.length] = createMarker(new GPoint(-106.56893900,35.17301300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Hope Christian Schools Inc",'Albuquerque=' + Albuquerque.length);
Albuquerque[Albuquerque.length] = createMarker(new GPoint(-106.64345000,35.08238200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Immanuel Lutheran School",'Albuquerque=' + Albuquerque.length);
Belen[Belen.length] = createMarker(new GPoint(-106.68630000,34.62020000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("La Mesa Christian School",'Belen=' + Belen.length);
Estancia[Estancia.length] = createMarker(new GPoint(-106.06910400,34.75406000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Liberty Ranch School",'Estancia=' + Estancia.length);
Las_Cruces[Las_Cruces.length] = createMarker(new GPoint(-106.74826000,32.26986500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mesilla Valley Christian Schools",'Las_Cruces=' + Las_Cruces.length);
Santa_Fe[Santa_Fe.length] = createMarker(new GPoint(-105.92305200,35.64045100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("New Mexico Academy For Sci",'Santa_Fe=' + Santa_Fe.length);
Las_Cruces[Las_Cruces.length] = createMarker(new GPoint(-106.78392200,32.29127400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Noah's Ark Learning Center",'Las_Cruces=' + Las_Cruces.length);
Roswell[Roswell.length] = createMarker(new GPoint(-104.55893500,33.39735500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Noah's Ark Preschool, Kindergarten And Daycare",'Roswell=' + Roswell.length);
Rehoboth[Rehoboth.length] = createMarker(new GPoint(-107.96660000,35.75970000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Rehoboth Christian School",'Rehoboth=' + Rehoboth.length);
Ruidoso_Downs[Ruidoso_Downs.length] = createMarker(new GPoint(-105.54110000,33.35860000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Ruidoso Christian School",'Ruidoso_Downs=' + Ruidoso_Downs.length);
Albuquerque[Albuquerque.length] = createMarker(new GPoint(-106.57640500,35.09305700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Temple Baptist Academy",'Albuquerque=' + Albuquerque.length);
Albuquerque[Albuquerque.length] = createMarker(new GPoint(-106.71483100,35.01166300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Valley Christian",'Albuquerque=' + Albuquerque.length);
Albuquerque[Albuquerque.length] = createMarker(new GPoint(-106.71461900,35.01170800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Valley Christian Academy",'Albuquerque=' + Albuquerque.length);
Albuquerque[Albuquerque.length] = createMarker(new GPoint(-106.62520700,35.17676000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Victory Christian School",'Albuquerque=' + Albuquerque.length);
Zuni[Zuni.length] = createMarker(new GPoint(-108.81310000,35.08070000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Zuni Christian Mission School",'Zuni=' + Zuni.length);
map.removeOverlays(Albuquerque);
map.removeOverlays(Belen);
map.removeOverlays(Clovis);
map.removeOverlays(Edgewood);
map.removeOverlays(Estancia);
map.removeOverlays(Gallup);
map.removeOverlays(Las_Cruces);
map.removeOverlays(Rehoboth);
map.removeOverlays(Rio_Rancho);
map.removeOverlays(Roswell);
map.removeOverlays(Ruidoso_Downs);
map.removeOverlays(Santa_Fe);
map.removeOverlays(Silver_City);
map.removeOverlays(Tijeras);
map.removeOverlays(Truth_Or_Consequences);
map.removeOverlays(Zuni);
setTimeout(function(){map.addOverlays(Albuquerque)},1000);
setTimeout(function(){map.addOverlays(Belen)},1000);
setTimeout(function(){map.addOverlays(Clovis)},1000);
setTimeout(function(){map.addOverlays(Edgewood)},1000);
setTimeout(function(){map.addOverlays(Estancia)},1000);
setTimeout(function(){map.addOverlays(Gallup)},1000);
setTimeout(function(){map.addOverlays(Las_Cruces)},1000);
setTimeout(function(){map.addOverlays(Rehoboth)},1000);
setTimeout(function(){map.addOverlays(Rio_Rancho)},1000);
setTimeout(function(){map.addOverlays(Roswell)},1000);
setTimeout(function(){map.addOverlays(Ruidoso_Downs)},1000);
setTimeout(function(){map.addOverlays(Santa_Fe)},1000);
setTimeout(function(){map.addOverlays(Silver_City)},1000);
setTimeout(function(){map.addOverlays(Tijeras)},1000);
setTimeout(function(){map.addOverlays(Truth_Or_Consequences)},1000);
setTimeout(function(){map.addOverlays(Zuni)},1000);
maxLng = -103.20533900;
maxLat = 35.75970000;
minLng = -108.81310000;
minLat = 32.26986500;
reCenterMap();
} // 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//////' + showArray);
map.removeOverlays(Albuquerque);
map.removeOverlays(Belen);
map.removeOverlays(Clovis);
map.removeOverlays(Edgewood);
map.removeOverlays(Estancia);
map.removeOverlays(Gallup);
map.removeOverlays(Las_Cruces);
map.removeOverlays(Rehoboth);
map.removeOverlays(Rio_Rancho);
map.removeOverlays(Roswell);
map.removeOverlays(Ruidoso_Downs);
map.removeOverlays(Santa_Fe);
map.removeOverlays(Silver_City);
map.removeOverlays(Tijeras);
map.removeOverlays(Truth_Or_Consequences);
map.removeOverlays(Zuni);
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(Silver_City);map.removeOverlays(Albuquerque);
map.removeOverlays(Belen);
map.removeOverlays(Clovis);
map.removeOverlays(Edgewood);
map.removeOverlays(Estancia);
map.removeOverlays(Gallup);
map.removeOverlays(Las_Cruces);
map.removeOverlays(Rehoboth);
map.removeOverlays(Rio_Rancho);
map.removeOverlays(Roswell);
map.removeOverlays(Ruidoso_Downs);
map.removeOverlays(Santa_Fe);
map.removeOverlays(Silver_City);
map.removeOverlays(Tijeras);
map.removeOverlays(Truth_Or_Consequences);
map.removeOverlays(Zuni);
map.addOverlays(Albuquerque);
centerByArray(Albuquerque, false, false);
cntMarker += Albuquerque.length;
map.addOverlays(Belen);
centerByArray(Belen, false, false);
cntMarker += Belen.length;
map.addOverlays(Clovis);
centerByArray(Clovis, false, false);
cntMarker += Clovis.length;
map.addOverlays(Edgewood);
centerByArray(Edgewood, false, false);
cntMarker += Edgewood.length;
map.addOverlays(Estancia);
centerByArray(Estancia, false, false);
cntMarker += Estancia.length;
map.addOverlays(Gallup);
centerByArray(Gallup, false, false);
cntMarker += Gallup.length;
map.addOverlays(Las_Cruces);
centerByArray(Las_Cruces, false, false);
cntMarker += Las_Cruces.length;
map.addOverlays(Rehoboth);
centerByArray(Rehoboth, false, false);
cntMarker += Rehoboth.length;
map.addOverlays(Rio_Rancho);
centerByArray(Rio_Rancho, false, false);
cntMarker += Rio_Rancho.length;
map.addOverlays(Roswell);
centerByArray(Roswell, false, false);
cntMarker += Roswell.length;
map.addOverlays(Ruidoso_Downs);
centerByArray(Ruidoso_Downs, false, false);
cntMarker += Ruidoso_Downs.length;
map.addOverlays(Santa_Fe);
centerByArray(Santa_Fe, false, false);
cntMarker += Santa_Fe.length;
map.addOverlays(Silver_City);
centerByArray(Silver_City, false, false);
cntMarker += Silver_City.length;
map.addOverlays(Tijeras);
centerByArray(Tijeras, false, false);
cntMarker += Tijeras.length;
map.addOverlays(Truth_Or_Consequences);
centerByArray(Truth_Or_Consequences, false, false);
cntMarker += Truth_Or_Consequences.length;
map.addOverlays(Zuni);
centerByArray(Zuni, false, false);
cntMarker += Zuni.length;
centerByArray(Silver_City,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///34407,33617,18590,18475,18426,33616,18490,18435,18458,18503,18396,18400,36024,18469,18444,33615,34407,18466,33617,18586,33618,18590,18475,18426,18445,33616,18462,18413,33613,18428,18490,18506,18435,35174,18458,18507,18526,18503,18396,33614,18404,18595,/all');
//window.open('/map.php?type=2&schools=34407,33617,18590,18475,18426,33616,18490,18435,18458,18503,18396,18400,36024,18469,18444,33615,34407,18466,33617,18586,33618,18590,18475,18426,18445,33616,18462,18413,33613,18428,18490,18506,18435,35174,18458,18507,18526,18503,18396,33614,18404,18595,&school_level=&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;
}