function addMarkers(){
mySelect = document.getElementById('selection');
Albuquerque = [];Clovis = [];Roswell = [];Ruidoso = [];Las_Vegas = [];Tucumcari = [];Hobbs = [];Alamogordo = [];Carlsbad = [];Las_Cruces = [];Grants = [];Espanola = [];Farmington = [];Santa_Fe = [];Gallup = [];Los_Alamos = [];Taos = [];Los_Lunas = [];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("Carlsbad Schools",'all=Carlsbad');
mySelect.options[mySelect.options.length] = new Option("Clovis Schools",'all=Clovis');
mySelect.options[mySelect.options.length] = new Option("Espanola Schools",'all=Espanola');
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("Las Vegas Schools",'all=Las_Vegas');
mySelect.options[mySelect.options.length] = new Option("Los Alamos Schools",'all=Los_Alamos');
mySelect.options[mySelect.options.length] = new Option("Los Lunas Schools",'all=Los_Lunas');
mySelect.options[mySelect.options.length] = new Option("Roswell Schools",'all=Roswell');
mySelect.options[mySelect.options.length] = new Option("Ruidoso Schools",'all=Ruidoso');
mySelect.options[mySelect.options.length] = new Option("Santa Fe Schools",'all=Santa_Fe');
mySelect.options[mySelect.options.length] = new Option("Taos Schools",'all=Taos');
mySelect.options[mySelect.options.length] = new Option("Tucumcari Schools",'all=Tucumcari');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
var tmpLatLng=0;
var tmpLen=0;
tmpLatLng=new GLatLng(35.08924999999999982,-106.589693999999994);
tmpLen=Albuquerque.length;
Albuquerque[tmpLen] = createMarker(tmpLatLng,"
",iconGr);
Albuquerque[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("Art Center Design College-albuquerque",'Albuquerque=' + Albuquerque.length);
tmpLatLng=new GLatLng(35.07667899999999860,-106.624166999999999);
tmpLen=Albuquerque.length;
Albuquerque[tmpLen] = createMarker(tmpLatLng,"",iconGr);
Albuquerque[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("Central New Mexico Community College",'Albuquerque=' + Albuquerque.length);
tmpLatLng=new GLatLng(34.40170899999999676,-103.168322000000003);
tmpLen=Clovis.length;
Clovis[tmpLen] = createMarker(tmpLatLng,"",iconGr);
Clovis[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("Clovis Community College",'Clovis=' + Clovis.length);
tmpLatLng=new GLatLng(33.31459199999999754,-104.524362999999993);
tmpLen=Roswell.length;
Roswell[tmpLen] = createMarker(tmpLatLng,"",iconGr);
Roswell[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("Eastern New Mexico University-roswell Campus",'Roswell=' + Roswell.length);
tmpLatLng=new GLatLng(33.34577800000000280,-105.674970999999999);
tmpLen=Ruidoso.length;
Ruidoso[tmpLen] = createMarker(tmpLatLng,"",iconGr);
Ruidoso[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("Eastern New Mexico University-ruidoso",'Ruidoso=' + Ruidoso.length);
tmpLatLng=new GLatLng(35.59241999999999706,-105.227400000000002);
tmpLen=Las_Vegas.length;
Las_Vegas[tmpLen] = createMarker(tmpLatLng,"",iconGr);
Las_Vegas[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("Luna Community College",'Las_Vegas=' + Las_Vegas.length);
tmpLatLng=new GLatLng(35.15912099999999895,-103.736233999999996);
tmpLen=Tucumcari.length;
Tucumcari[tmpLen] = createMarker(tmpLatLng,"",iconGr);
Tucumcari[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("Mesalands Community College",'Tucumcari=' + Tucumcari.length);
tmpLatLng=new GLatLng(32.75958299999999923,-103.179704000000000);
tmpLen=Hobbs.length;
Hobbs[tmpLen] = createMarker(tmpLatLng,"",iconGr);
Hobbs[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("New Mexico Junior College",'Hobbs=' + Hobbs.length);
tmpLatLng=new GLatLng(33.40862599999999815,-104.522761000000002);
tmpLen=Roswell.length;
Roswell[tmpLen] = createMarker(tmpLatLng,"",iconGr);
Roswell[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("New Mexico Military Institute",'Roswell=' + Roswell.length);
tmpLatLng=new GLatLng(32.92530599999999907,-105.931753999999997);
tmpLen=Alamogordo.length;
Alamogordo[tmpLen] = createMarker(tmpLatLng,"",iconGr);
Alamogordo[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("New Mexico State University-alamogordo",'Alamogordo=' + Alamogordo.length);
tmpLatLng=new GLatLng(32.44387499999999846,-104.262648999999996);
tmpLen=Carlsbad.length;
Carlsbad[tmpLen] = createMarker(tmpLatLng,"",iconGr);
Carlsbad[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("New Mexico State University-carlsbad",'Carlsbad=' + Carlsbad.length);
tmpLatLng=new GLatLng(32.27709399999999817,-106.754457999999999);
tmpLen=Las_Cruces.length;
Las_Cruces[tmpLen] = createMarker(tmpLatLng,"",iconGr);
Las_Cruces[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("New Mexico State University-dona Ana",'Las_Cruces=' + Las_Cruces.length);
tmpLatLng=new GLatLng(35.16407699999999891,-107.843485000000001);
tmpLen=Grants.length;
Grants[tmpLen] = createMarker(tmpLatLng,"",iconGr);
Grants[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("New Mexico State University-grants",'Grants=' + Grants.length);
tmpLatLng=new GLatLng(36.00213099999999855,-106.086337000000000);
tmpLen=Espanola.length;
Espanola[tmpLen] = createMarker(tmpLatLng,"",iconGr);
Espanola[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("Northern New Mexico College",'Espanola=' + Espanola.length);
tmpLatLng=new GLatLng(36.76979999999999648,-108.166337999999996);
tmpLen=Farmington.length;
Farmington[tmpLen] = createMarker(tmpLatLng,"",iconGr);
Farmington[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("San Juan College",'Farmington=' + Farmington.length);
tmpLatLng=new GLatLng(35.64613099999999690,-105.998377000000004);
tmpLen=Santa_Fe.length;
Santa_Fe[tmpLen] = createMarker(tmpLatLng,"",iconGr);
Santa_Fe[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("Santa Fe Community College",'Santa_Fe=' + Santa_Fe.length);
tmpLatLng=new GLatLng(35.50191900000000089,-108.727861000000004);
tmpLen=Gallup.length;
Gallup[tmpLen] = createMarker(tmpLatLng,"",iconGr);
Gallup[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("University Of New Mexico-gallup Campus",'Gallup=' + Gallup.length);
tmpLatLng=new GLatLng(35.88569900000000245,-106.318089999999997);
tmpLen=Los_Alamos.length;
Los_Alamos[tmpLen] = createMarker(tmpLatLng,"",iconGr);
Los_Alamos[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("University Of New Mexico-los Alamos Campus",'Los_Alamos=' + Los_Alamos.length);
tmpLatLng=new GLatLng(36.40928900000000112,-105.572304000000002);
tmpLen=Taos.length;
Taos[tmpLen] = createMarker(tmpLatLng,"",iconGr);
Taos[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("University Of New Mexico-taos Branch",'Taos=' + Taos.length);
tmpLatLng=new GLatLng(34.72933199999999942,-106.707475999999999);
tmpLen=Los_Lunas.length;
Los_Lunas[tmpLen] = createMarker(tmpLatLng,"",iconGr);
Los_Lunas[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("University Of New Mexico-valencia County Branch",'Los_Lunas=' + Los_Lunas.length);
map.removeOverlays(Alamogordo);
map.removeOverlays(Albuquerque);
map.removeOverlays(Carlsbad);
map.removeOverlays(Clovis);
map.removeOverlays(Espanola);
map.removeOverlays(Farmington);
map.removeOverlays(Gallup);
map.removeOverlays(Grants);
map.removeOverlays(Hobbs);
map.removeOverlays(Las_Cruces);
map.removeOverlays(Las_Vegas);
map.removeOverlays(Los_Alamos);
map.removeOverlays(Los_Lunas);
map.removeOverlays(Roswell);
map.removeOverlays(Ruidoso);
map.removeOverlays(Santa_Fe);
map.removeOverlays(Taos);
map.removeOverlays(Tucumcari);
setTimeout(function(){map.addOverlays(Alamogordo)},1000);
setTimeout(function(){map.addOverlays(Albuquerque)},1000);
setTimeout(function(){map.addOverlays(Carlsbad)},1000);
setTimeout(function(){map.addOverlays(Clovis)},1000);
setTimeout(function(){map.addOverlays(Espanola)},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(Las_Vegas)},1000);
setTimeout(function(){map.addOverlays(Los_Alamos)},1000);
setTimeout(function(){map.addOverlays(Los_Lunas)},1000);
setTimeout(function(){map.addOverlays(Roswell)},1000);
setTimeout(function(){map.addOverlays(Ruidoso)},1000);
setTimeout(function(){map.addOverlays(Santa_Fe)},1000);
setTimeout(function(){map.addOverlays(Taos)},1000);
setTimeout(function(){map.addOverlays(Tucumcari)},1000);
getPoly("","state","","NM");}
// End addStateMarkers JavaScript Function
//open all when map is defined
function openAll() {
if (map) {
selectChange("all");
} else {
setTimeout("openAll()",200);
}
}
// 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].point.x;
var markLat = myArray[i].point.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].point.x;
maxLat = myArray[0].point.y;
minLng = myArray[0].point.x;
minLat = myArray[0].point.y;
}
// Recenter map based on global max/mins
function reCenterMap(){
//alert('#' + minLat + '#' + minLng + '#' + maxLat + '#' + maxLng);
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) {
if (selection.options) {
var _openNewWindow=true;
var myVal = selection.options[selection.selectedIndex].value;
} else {
var _openNewWindow=false;
var myVal=selection;
}
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('schools-by-distance') == -1)
window.open(location.href + '/map/all');
else
window.open('/search////all');
map.removeOverlays(Alamogordo);
map.removeOverlays(Albuquerque);
map.removeOverlays(Carlsbad);
map.removeOverlays(Clovis);
map.removeOverlays(Espanola);
map.removeOverlays(Farmington);
map.removeOverlays(Gallup);
map.removeOverlays(Grants);
map.removeOverlays(Hobbs);
map.removeOverlays(Las_Cruces);
map.removeOverlays(Las_Vegas);
map.removeOverlays(Los_Alamos);
map.removeOverlays(Los_Lunas);
map.removeOverlays(Roswell);
map.removeOverlays(Ruidoso);
map.removeOverlays(Santa_Fe);
map.removeOverlays(Taos);
map.removeOverlays(Tucumcari);
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(Albuquerque);map.removeOverlays(Alamogordo);
map.removeOverlays(Albuquerque);
map.removeOverlays(Carlsbad);
map.removeOverlays(Clovis);
map.removeOverlays(Espanola);
map.removeOverlays(Farmington);
map.removeOverlays(Gallup);
map.removeOverlays(Grants);
map.removeOverlays(Hobbs);
map.removeOverlays(Las_Cruces);
map.removeOverlays(Las_Vegas);
map.removeOverlays(Los_Alamos);
map.removeOverlays(Los_Lunas);
map.removeOverlays(Roswell);
map.removeOverlays(Ruidoso);
map.removeOverlays(Santa_Fe);
map.removeOverlays(Taos);
map.removeOverlays(Tucumcari);
map.addOverlays(Alamogordo);
centerByArray(Alamogordo, false, false);
cntMarker += Alamogordo.length;
map.addOverlays(Albuquerque);
centerByArray(Albuquerque, false, false);
cntMarker += Albuquerque.length;
map.addOverlays(Carlsbad);
centerByArray(Carlsbad, false, false);
cntMarker += Carlsbad.length;
map.addOverlays(Clovis);
centerByArray(Clovis, false, false);
cntMarker += Clovis.length;
map.addOverlays(Espanola);
centerByArray(Espanola, false, false);
cntMarker += Espanola.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(Las_Vegas);
centerByArray(Las_Vegas, false, false);
cntMarker += Las_Vegas.length;
map.addOverlays(Los_Alamos);
centerByArray(Los_Alamos, false, false);
cntMarker += Los_Alamos.length;
map.addOverlays(Los_Lunas);
centerByArray(Los_Lunas, false, false);
cntMarker += Los_Lunas.length;
map.addOverlays(Roswell);
centerByArray(Roswell, false, false);
cntMarker += Roswell.length;
map.addOverlays(Ruidoso);
centerByArray(Ruidoso, false, false);
cntMarker += Ruidoso.length;
map.addOverlays(Santa_Fe);
centerByArray(Santa_Fe, false, false);
cntMarker += Santa_Fe.length;
map.addOverlays(Taos);
centerByArray(Taos, false, false);
cntMarker += Taos.length;
map.addOverlays(Tucumcari);
centerByArray(Tucumcari, false, false);
cntMarker += Tucumcari.length;
reCenterMap();
//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');
}
}
function createMarker(point, label, icon){
var marker = new GMarker(point, icon);
var html = label;
GEvent.addListener(marker, "click", function() { marker.openInfoWindowHtml(html); });
return marker;
}