function addMarkers(){
mySelect = document.getElementById('selection');
Roswell = [];Albuquerque = [];Santa_Fe = [];Alamogordo = [];Santa_Cruz = [];Cuba = [];Las_Cruces = [];Farmington = [];Lumberton = [];Belen = [];Zuni = [];Thoreau = [];Carlsbad = [];Gallup = [];Hobbs = [];San_Fidel = [];Grants = [];Rio_Rancho = [];mySelect.options[mySelect.options.length] = new Option("Alamogordo schools",'all=Alamogordo');
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("Carlsbad schools",'all=Carlsbad');
mySelect.options[mySelect.options.length] = new Option("Cuba schools",'all=Cuba');
mySelect.options[mySelect.options.length] = new Option("Farmington schools",'all=Farmington');
mySelect.options[mySelect.options.length] = new Option("Gallup schools",'all=Gallup');
mySelect.options[mySelect.options.length] = new Option("Grants schools",'all=Grants');
mySelect.options[mySelect.options.length] = new Option("Hobbs schools",'all=Hobbs');
mySelect.options[mySelect.options.length] = new Option("Las Cruces schools",'all=Las_Cruces');
mySelect.options[mySelect.options.length] = new Option("Lumberton schools",'all=Lumberton');
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("San Fidel schools",'all=San_Fidel');
mySelect.options[mySelect.options.length] = new Option("Santa Cruz schools",'all=Santa_Cruz');
mySelect.options[mySelect.options.length] = new Option("Santa Fe schools",'all=Santa_Fe');
mySelect.options[mySelect.options.length] = new Option("Thoreau schools",'all=Thoreau');
mySelect.options[mySelect.options.length] = new Option("Zuni schools",'all=Zuni');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Roswell[Roswell.length] = createMarker(new GPoint(-104.52752700,33.42748600),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("All Saints Catholic School",'Roswell=' + Roswell.length);
Albuquerque[Albuquerque.length] = createMarker(new GPoint(-106.55527400,35.11134800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Annunciation Elementary School",'Albuquerque=' + Albuquerque.length);
Santa_Fe[Santa_Fe.length] = createMarker(new GPoint(-105.91867300,35.67876900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cristo Rey Elementary School",'Santa_Fe=' + Santa_Fe.length);
Alamogordo[Alamogordo.length] = createMarker(new GPoint(-105.94983600,32.89766300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Fr James B Hay Catholic School",'Alamogordo=' + Alamogordo.length);
Santa_Cruz[Santa_Cruz.length] = createMarker(new GPoint(-106.02640000,35.94810000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Holy Cross Catholic School",'Santa_Cruz=' + Santa_Cruz.length);
Albuquerque[Albuquerque.length] = createMarker(new GPoint(-92.06349000,31.12486900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Holy Ghost Catholic School",'Albuquerque=' + Albuquerque.length);
Cuba[Cuba.length] = createMarker(new GPoint(-107.25094800,35.95445000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Immaculate Conception School",'Cuba=' + Cuba.length);
Las_Cruces[Las_Cruces.length] = createMarker(new GPoint(-106.78911000,32.32020300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Las Cruces Catholic/holy Cross",'Las_Cruces=' + Las_Cruces.length);
Las_Cruces[Las_Cruces.length] = createMarker(new GPoint(-106.76696000,32.29845700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Las Cruces Catholic/ihm Campus",'Las_Cruces=' + Las_Cruces.length);
Albuquerque[Albuquerque.length] = createMarker(new GPoint(-106.55890900,35.08555900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Our Lady Of The Assumption Catholic School",'Albuquerque=' + Albuquerque.length);
Albuquerque[Albuquerque.length] = createMarker(new GPoint(-106.59961600,35.08726300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Our Lady Of Fatima Elementary School",'Albuquerque=' + Albuquerque.length);
Farmington[Farmington.length] = createMarker(new GPoint(-108.20671400,36.73296500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sacred Heart Catholic School",'Farmington=' + Farmington.length);
Albuquerque[Albuquerque.length] = createMarker(new GPoint(-106.62839700,35.07673700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Charles Borromeo Elementary School",'Albuquerque=' + Albuquerque.length);
Lumberton[Lumberton.length] = createMarker(new GPoint(-107.24388900,36.59570900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Francis Of Assisi School",'Lumberton=' + Lumberton.length);
Belen[Belen.length] = createMarker(new GPoint(-106.77986900,34.66187000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Mary's Catholic School Belen",'Belen=' + Belen.length);
Albuquerque[Albuquerque.length] = createMarker(new GPoint(-106.65460000,35.08711000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Mary's School",'Albuquerque=' + Albuquerque.length);
Albuquerque[Albuquerque.length] = createMarker(new GPoint(-106.64363300,35.11831200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Therese Catholic School",'Albuquerque=' + Albuquerque.length);
Albuquerque[Albuquerque.length] = createMarker(new GPoint(-106.66865000,35.09336300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("San Felipe De Neri School",'Albuquerque=' + Albuquerque.length);
Zuni[Zuni.length] = createMarker(new GPoint(-108.81310000,35.08070000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Anthony Indian School",'Zuni=' + Zuni.length);
Thoreau[Thoreau.length] = createMarker(new GPoint(-107.68400000,35.58950000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Bonaventure School",'Thoreau=' + Thoreau.length);
Carlsbad[Carlsbad.length] = createMarker(new GPoint(-104.24446200,32.42891400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Edward School, Inc.",'Carlsbad=' + Carlsbad.length);
Gallup[Gallup.length] = createMarker(new GPoint(-108.74489200,35.53186100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Francis Assisi School",'Gallup=' + Gallup.length);
Santa_Fe[Santa_Fe.length] = createMarker(new GPoint(-105.93475000,35.68453600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Francis Cathedral School",'Santa_Fe=' + Santa_Fe.length);
Hobbs[Hobbs.length] = createMarker(new GPoint(-103.13596600,32.72706300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Helena School",'Hobbs=' + Hobbs.length);
San_Fidel[San_Fidel.length] = createMarker(new GPoint(-108.03360000,34.86730000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Joseph Mission School",'San_Fidel=' + San_Fidel.length);
Santa_Fe[Santa_Fe.length] = createMarker(new GPoint(-105.95036700,35.65186300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Michaels High School",'Santa_Fe=' + Santa_Fe.length);
Albuquerque[Albuquerque.length] = createMarker(new GPoint(-106.69695000,35.12781800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Pius X High School",'Albuquerque=' + Albuquerque.length);
Grants[Grants.length] = createMarker(new GPoint(-107.84560000,35.25530000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Teresa Of Avila School",'Grants=' + Grants.length);
Rio_Rancho[Rio_Rancho.length] = createMarker(new GPoint(-106.71298700,35.24698700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Thomas Aquinas School",'Rio_Rancho=' + Rio_Rancho.length);
map.removeOverlays(Alamogordo);
map.removeOverlays(Albuquerque);
map.removeOverlays(Belen);
map.removeOverlays(Carlsbad);
map.removeOverlays(Cuba);
map.removeOverlays(Farmington);
map.removeOverlays(Gallup);
map.removeOverlays(Grants);
map.removeOverlays(Hobbs);
map.removeOverlays(Las_Cruces);
map.removeOverlays(Lumberton);
map.removeOverlays(Rio_Rancho);
map.removeOverlays(Roswell);
map.removeOverlays(San_Fidel);
map.removeOverlays(Santa_Cruz);
map.removeOverlays(Santa_Fe);
map.removeOverlays(Thoreau);
map.removeOverlays(Zuni);
setTimeout(function(){map.addOverlays(Alamogordo)},1000);
setTimeout(function(){map.addOverlays(Albuquerque)},1000);
setTimeout(function(){map.addOverlays(Belen)},1000);
setTimeout(function(){map.addOverlays(Carlsbad)},1000);
setTimeout(function(){map.addOverlays(Cuba)},1000);
setTimeout(function(){map.addOverlays(Farmington)},1000);
setTimeout(function(){map.addOverlays(Gallup)},1000);
setTimeout(function(){map.addOverlays(Grants)},1000);
setTimeout(function(){map.addOverlays(Hobbs)},1000);
setTimeout(function(){map.addOverlays(Las_Cruces)},1000);
setTimeout(function(){map.addOverlays(Lumberton)},1000);
setTimeout(function(){map.addOverlays(Rio_Rancho)},1000);
setTimeout(function(){map.addOverlays(Roswell)},1000);
setTimeout(function(){map.addOverlays(San_Fidel)},1000);
setTimeout(function(){map.addOverlays(Santa_Cruz)},1000);
setTimeout(function(){map.addOverlays(Santa_Fe)},1000);
setTimeout(function(){map.addOverlays(Thoreau)},1000);
setTimeout(function(){map.addOverlays(Zuni)},1000);
maxLng = -92.06349000;
maxLat = 36.73296500;
minLng = -108.81310000;
minLat = 31.12486900;
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(Alamogordo);
map.removeOverlays(Albuquerque);
map.removeOverlays(Belen);
map.removeOverlays(Carlsbad);
map.removeOverlays(Cuba);
map.removeOverlays(Farmington);
map.removeOverlays(Gallup);
map.removeOverlays(Grants);
map.removeOverlays(Hobbs);
map.removeOverlays(Las_Cruces);
map.removeOverlays(Lumberton);
map.removeOverlays(Rio_Rancho);
map.removeOverlays(Roswell);
map.removeOverlays(San_Fidel);
map.removeOverlays(Santa_Cruz);
map.removeOverlays(Santa_Fe);
map.removeOverlays(Thoreau);
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(Roswell);map.removeOverlays(Alamogordo);
map.removeOverlays(Albuquerque);
map.removeOverlays(Belen);
map.removeOverlays(Carlsbad);
map.removeOverlays(Cuba);
map.removeOverlays(Farmington);
map.removeOverlays(Gallup);
map.removeOverlays(Grants);
map.removeOverlays(Hobbs);
map.removeOverlays(Las_Cruces);
map.removeOverlays(Lumberton);
map.removeOverlays(Rio_Rancho);
map.removeOverlays(Roswell);
map.removeOverlays(San_Fidel);
map.removeOverlays(Santa_Cruz);
map.removeOverlays(Santa_Fe);
map.removeOverlays(Thoreau);
map.removeOverlays(Zuni);
map.addOverlays(Alamogordo);
centerByArray(Alamogordo, false, false);
cntMarker += Alamogordo.length;
map.addOverlays(Albuquerque);
centerByArray(Albuquerque, false, false);
cntMarker += Albuquerque.length;
map.addOverlays(Belen);
centerByArray(Belen, false, false);
cntMarker += Belen.length;
map.addOverlays(Carlsbad);
centerByArray(Carlsbad, false, false);
cntMarker += Carlsbad.length;
map.addOverlays(Cuba);
centerByArray(Cuba, false, false);
cntMarker += Cuba.length;
map.addOverlays(Farmington);
centerByArray(Farmington, false, false);
cntMarker += Farmington.length;
map.addOverlays(Gallup);
centerByArray(Gallup, false, false);
cntMarker += Gallup.length;
map.addOverlays(Grants);
centerByArray(Grants, false, false);
cntMarker += Grants.length;
map.addOverlays(Hobbs);
centerByArray(Hobbs, false, false);
cntMarker += Hobbs.length;
map.addOverlays(Las_Cruces);
centerByArray(Las_Cruces, false, false);
cntMarker += Las_Cruces.length;
map.addOverlays(Lumberton);
centerByArray(Lumberton, false, false);
cntMarker += Lumberton.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(San_Fidel);
centerByArray(San_Fidel, false, false);
cntMarker += San_Fidel.length;
map.addOverlays(Santa_Cruz);
centerByArray(Santa_Cruz, false, false);
cntMarker += Santa_Cruz.length;
map.addOverlays(Santa_Fe);
centerByArray(Santa_Fe, false, false);
cntMarker += Santa_Fe.length;
map.addOverlays(Thoreau);
centerByArray(Thoreau, false, false);
cntMarker += Thoreau.length;
map.addOverlays(Zuni);
centerByArray(Zuni, false, false);
cntMarker += Zuni.length;
centerByArray(Roswell,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///18566,18454,18402,11652,18512,18511,18549,18560,18563,18530,18565,18550,36025,18528,18553,18562,18554,18478,18479,18552,18567,34600,18556,18463,18434,18551,18561,18548,18547,/all');
//window.open('/map.php?type=2&schools=18566,18454,18402,11652,18512,18511,18549,18560,18563,18530,18565,18550,36025,18528,18553,18562,18554,18478,18479,18552,18567,34600,18556,18463,18434,18551,18561,18548,18547,&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;
}