function addMarkers(){
mySelect = document.getElementById('selection');
Santa_Fe = [];Edgewood = [];Santa_Cruz = [];mySelect.options[mySelect.options.length] = new Option("Edgewood schools",'all=Edgewood');
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("---------------------------",'');
Santa_Fe[Santa_Fe.length] = createMarker(new GPoint(-105.95577800,35.67655300),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Childrens School",'Santa_Fe=' + Santa_Fe.length);
Santa_Fe[Santa_Fe.length] = createMarker(new GPoint(-105.95299200,35.65213700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Christian Life Academy",'Santa_Fe=' + Santa_Fe.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);
Santa_Fe[Santa_Fe.length] = createMarker(new GPoint(-105.96500800,35.68297100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Desert Academy",'Santa_Fe=' + Santa_Fe.length);
Santa_Fe[Santa_Fe.length] = createMarker(new GPoint(-105.91865200,35.67871600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Desert Montessori School",'Santa_Fe=' + Santa_Fe.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);
Santa_Fe[Santa_Fe.length] = createMarker(new GPoint(-105.96333400,35.67794700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Fayette St Academy",'Santa_Fe=' + Santa_Fe.length);
Santa_Fe[Santa_Fe.length] = createMarker(new GPoint(-105.93189000,35.67791900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Garcia Street Club, Inc.",'Santa_Fe=' + Santa_Fe.length);
Santa_Fe[Santa_Fe.length] = createMarker(new GPoint(-105.91057600,35.67882000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Gentle Nudge",'Santa_Fe=' + Santa_Fe.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);
Santa_Fe[Santa_Fe.length] = createMarker(new GPoint(-105.95455900,35.69649100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("La Casita Pre School And Kindergarten",'Santa_Fe=' + Santa_Fe.length);
Santa_Fe[Santa_Fe.length] = createMarker(new GPoint(-105.92739300,35.63281800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("La Mariposa Montessori",'Santa_Fe=' + Santa_Fe.length);
Santa_Fe[Santa_Fe.length] = createMarker(new GPoint(-105.94841400,35.64587800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Little Earth School",'Santa_Fe=' + Santa_Fe.length);
Santa_Fe[Santa_Fe.length] = createMarker(new GPoint(-105.99848000,35.62450600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mission Viejo Christian Academy",'Santa_Fe=' + Santa_Fe.length);
Santa_Fe[Santa_Fe.length] = createMarker(new GPoint(-105.90931300,35.53923900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Monte Vista Montessori School",'Santa_Fe=' + Santa_Fe.length);
Santa_Fe[Santa_Fe.length] = createMarker(new GPoint(-105.97779600,35.63451700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Montessori Childrens House",'Santa_Fe=' + Santa_Fe.length);
Santa_Fe[Santa_Fe.length] = createMarker(new GPoint(-105.95336900,35.65686500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Montessori Discovery School",'Santa_Fe=' + Santa_Fe.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);
Santa_Fe[Santa_Fe.length] = createMarker(new GPoint(-105.96422500,35.68042200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Philos School",'Santa_Fe=' + Santa_Fe.length);
Santa_Fe[Santa_Fe.length] = createMarker(new GPoint(-105.95652100,35.68733600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Reach The Children School",'Santa_Fe=' + Santa_Fe.length);
Santa_Fe[Santa_Fe.length] = createMarker(new GPoint(-105.91343900,35.67287800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Rio Grande School",'Santa_Fe=' + Santa_Fe.length);
Santa_Fe[Santa_Fe.length] = createMarker(new GPoint(-105.94823000,35.64561600),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Santa Fe Girls' School",'Santa_Fe=' + Santa_Fe.length);
Santa_Fe[Santa_Fe.length] = createMarker(new GPoint(-105.91326100,35.66918600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Santa Fe Preparatory School",'Santa_Fe=' + Santa_Fe.length);
Santa_Fe[Santa_Fe.length] = createMarker(new GPoint(-106.03666300,35.62780000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Santa Fe School For The Arts",'Santa_Fe=' + Santa_Fe.length);
Santa_Fe[Santa_Fe.length] = createMarker(new GPoint(-105.95459300,35.68705600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Santa Fe Secondary School",'Santa_Fe=' + Santa_Fe.length);
Santa_Fe[Santa_Fe.length] = createMarker(new GPoint(-105.92858900,35.63329500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Santa Fe Waldorf School",'Santa_Fe=' + Santa_Fe.length);
Santa_Fe[Santa_Fe.length] = createMarker(new GPoint(-105.97459500,35.64859600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Small World Learning",'Santa_Fe=' + Santa_Fe.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);
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);
Santa_Fe[Santa_Fe.length] = createMarker(new GPoint(-105.96426900,35.68041200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Tara School",'Santa_Fe=' + Santa_Fe.length);
Santa_Fe[Santa_Fe.length] = createMarker(new GPoint(-105.97396800,35.65159000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Temple Baptist Christian School",'Santa_Fe=' + Santa_Fe.length);
Santa_Fe[Santa_Fe.length] = createMarker(new GPoint(-105.94023600,35.67243700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Temple Beth Shalom Preschool",'Santa_Fe=' + Santa_Fe.length);
Santa_Fe[Santa_Fe.length] = createMarker(new GPoint(-105.95100100,35.65448400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Tutorial School",'Santa_Fe=' + Santa_Fe.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/////3/' + showArray);
map.removeOverlays(Edgewood);
map.removeOverlays(Santa_Cruz);
map.removeOverlays(Santa_Fe);
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(Santa_Fe);map.removeOverlays(Edgewood);
map.removeOverlays(Santa_Cruz);
map.removeOverlays(Santa_Fe);
map.addOverlays(Edgewood);
centerByArray(Edgewood, false, false);
cntMarker += Edgewood.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;
centerByArray(Santa_Fe,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=3&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;
}