function addMarkers(){
mySelect = document.getElementById('selection');
Glendale = [];Phoenix = [];Chandler = [];Avondale = [];Mesa = [];Tempe = [];Scottsdale = [];mySelect.options[mySelect.options.length] = new Option("Avondale Schools",'all=Avondale');
mySelect.options[mySelect.options.length] = new Option("Chandler Schools",'all=Chandler');
mySelect.options[mySelect.options.length] = new Option("Glendale Schools",'all=Glendale');
mySelect.options[mySelect.options.length] = new Option("Mesa Schools",'all=Mesa');
mySelect.options[mySelect.options.length] = new Option("Phoenix Schools",'all=Phoenix');
mySelect.options[mySelect.options.length] = new Option("Scottsdale Schools",'all=Scottsdale');
mySelect.options[mySelect.options.length] = new Option("Tempe Schools",'all=Tempe');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
var tmpLatLng=0;
var tmpLen=0;
tmpLatLng=new GLatLng(33.53615800000000035,-112.157454000000001);
tmpLen=Glendale.length;
Glendale[tmpLen] = createMarker(tmpLatLng,"
",iconRd);
Glendale[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("Arizona Automotive Institute",'Glendale=' + Glendale.length);
tmpLatLng=new GLatLng(33.56763099999999866,-112.105981999999997);
tmpLen=Phoenix.length;
Phoenix[tmpLen] = createMarker(tmpLatLng,"",iconGr);
Phoenix[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("Art Institute Of Phoenix",'Phoenix=' + Phoenix.length);
tmpLatLng=new GLatLng(33.44720099999999973,-112.073166000000000);
tmpLen=Phoenix.length;
Phoenix[tmpLen] = createMarker(tmpLatLng,"",iconRd);
Phoenix[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("Bryman School",'Phoenix=' + Phoenix.length);
tmpLatLng=new GLatLng(33.29188500000000061,-111.794362000000006);
tmpLen=Chandler.length;
Chandler[tmpLen] = createMarker(tmpLatLng,"",iconGr);
Chandler[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("Chandler/gilbert Community College",'Chandler=' + Chandler.length);
tmpLatLng=new GLatLng(33.478841,-112.340913);
tmpLen=Avondale.length;
Avondale[tmpLen] = createMarker(tmpLatLng,"",iconGr);
Avondale[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("Estrella Mountain Community College",'Avondale=' + Avondale.length);
tmpLatLng=new GLatLng(33.58026799999999667,-112.113836000000006);
tmpLen=Phoenix.length;
Phoenix[tmpLen] = createMarker(tmpLatLng,"",iconRd);
Phoenix[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("Everest College-phoenix",'Phoenix=' + Phoenix.length);
tmpLatLng=new GLatLng(33.44927500000000009,-111.995001000000002);
tmpLen=Phoenix.length;
Phoenix[tmpLen] = createMarker(tmpLatLng,"",iconGr);
Phoenix[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("Gateway Community College",'Phoenix=' + Phoenix.length);
tmpLatLng=new GLatLng(33.56743999999999772,-112.188331000000005);
tmpLen=Glendale.length;
Glendale[tmpLen] = createMarker(tmpLatLng,"",iconGr);
Glendale[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("Glendale Community College",'Glendale=' + Glendale.length);
tmpLatLng=new GLatLng(33.49475000000000335,-112.049294000000003);
tmpLen=Phoenix.length;
Phoenix[tmpLen] = createMarker(tmpLatLng,"",iconRd);
Phoenix[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("High-tech Institute-phoenix",'Phoenix=' + Phoenix.length);
tmpLatLng=new GLatLng(33.52479000000000297,-112.151218000000000);
tmpLen=Phoenix.length;
Phoenix[tmpLen] = createMarker(tmpLatLng,"",iconRd);
Phoenix[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("International Institute Of Americas",'Phoenix=' + Phoenix.length);
tmpLatLng=new GLatLng(33.39687299999999936,-111.788343999999995);
tmpLen=Mesa.length;
Mesa[tmpLen] = createMarker(tmpLatLng,"",iconRd);
Mesa[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("International Institute Of Americas",'Mesa=' + Mesa.length);
tmpLatLng=new GLatLng(33.49555699999999802,-112.220653999999996);
tmpLen=Phoenix.length;
Phoenix[tmpLen] = createMarker(tmpLatLng,"",iconRd);
Phoenix[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("International Institute Of The Americas",'Phoenix=' + Phoenix.length);
tmpLatLng=new GLatLng(33.44084500000000304,-111.926499000000006);
tmpLen=Tempe.length;
Tempe[tmpLen] = createMarker(tmpLatLng,"",iconRd);
Tempe[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("Lamson College",'Tempe=' + Tempe.length);
tmpLatLng=new GLatLng(33.60479699999999780,-112.117264000000005);
tmpLen=Phoenix.length;
Phoenix[tmpLen] = createMarker(tmpLatLng,"",iconRd);
Phoenix[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("Long Technical College",'Phoenix=' + Phoenix.length);
tmpLatLng=new GLatLng(33.39303900000000169,-111.870264000000005);
tmpLen=Mesa.length;
Mesa[tmpLen] = createMarker(tmpLatLng,"",iconGr);
Mesa[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("Mesa Community College",'Mesa=' + Mesa.length);
tmpLatLng=new GLatLng(33.65293400000000190,-112.013052999999999);
tmpLen=Phoenix.length;
Phoenix[tmpLen] = createMarker(tmpLatLng,"",iconGr);
Phoenix[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("Paradise Valley Community College",'Phoenix=' + Phoenix.length);
tmpLatLng=new GLatLng(33.48064099999999854,-112.088274999999995);
tmpLen=Phoenix.length;
Phoenix[tmpLen] = createMarker(tmpLatLng,"",iconGr);
Phoenix[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("Phoenix College",'Phoenix=' + Phoenix.length);
tmpLatLng=new GLatLng(33.44824400000000252,-111.990033999999994);
tmpLen=Phoenix.length;
Phoenix[tmpLen] = createMarker(tmpLatLng,"",iconRd);
Phoenix[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("Refrigeration School Inc",'Phoenix=' + Phoenix.length);
tmpLatLng=new GLatLng(33.34896299999999769,-111.951910999999995);
tmpLen=Tempe.length;
Tempe[tmpLen] = createMarker(tmpLatLng,"",iconRd);
Tempe[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("Remington College-tempe Campus",'Tempe=' + Tempe.length);
tmpLatLng=new GLatLng(33.41375699999999682,-111.975632000000004);
tmpLen=Tempe.length;
Tempe[tmpLen] = createMarker(tmpLatLng,"",iconGr);
Tempe[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("Rio Salado College",'Tempe=' + Tempe.length);
tmpLatLng=new GLatLng(33.50924400000000247,-111.880566999999999);
tmpLen=Scottsdale.length;
Scottsdale[tmpLen] = createMarker(tmpLatLng,"",iconGr);
Scottsdale[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("Scottsdale Community College",'Scottsdale=' + Scottsdale.length);
tmpLatLng=new GLatLng(33.50205299999999653,-111.906160999999997);
tmpLen=Scottsdale.length;
Scottsdale[tmpLen] = createMarker(tmpLatLng,"",iconRd);
Scottsdale[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("Scottsdale Culinary Institute",'Scottsdale=' + Scottsdale.length);
tmpLatLng=new GLatLng(33.38265499999999974,-112.030410000000003);
tmpLen=Phoenix.length;
Phoenix[tmpLen] = createMarker(tmpLatLng,"",iconGr);
Phoenix[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("South Mountain Community College",'Phoenix=' + Phoenix.length);
tmpLatLng=new GLatLng(33.49107500000000214,-112.125218000000003);
tmpLen=Avondale.length;
Avondale[tmpLen] = createMarker(tmpLatLng,"",iconRd);
Avondale[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("Universal Technical Institute Of Arizona Inc",'Avondale=' + Avondale.length);
map.removeOverlays(Avondale);
map.removeOverlays(Chandler);
map.removeOverlays(Glendale);
map.removeOverlays(Mesa);
map.removeOverlays(Phoenix);
map.removeOverlays(Scottsdale);
map.removeOverlays(Tempe);
setTimeout(function(){map.addOverlays(Avondale)},1000);
setTimeout(function(){map.addOverlays(Chandler)},1000);
setTimeout(function(){map.addOverlays(Glendale)},1000);
setTimeout(function(){map.addOverlays(Mesa)},1000);
setTimeout(function(){map.addOverlays(Phoenix)},1000);
setTimeout(function(){map.addOverlays(Scottsdale)},1000);
setTimeout(function(){map.addOverlays(Tempe)},1000);
maxLng = -111.788343999999995;
maxLat = 33.65293400000000190;
minLng = -112.340913;
minLat = 33.29188500000000061;
reCenterMap();
}
// 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(Avondale);
map.removeOverlays(Chandler);
map.removeOverlays(Glendale);
map.removeOverlays(Mesa);
map.removeOverlays(Phoenix);
map.removeOverlays(Scottsdale);
map.removeOverlays(Tempe);
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(Glendale);map.removeOverlays(Avondale);
map.removeOverlays(Chandler);
map.removeOverlays(Glendale);
map.removeOverlays(Mesa);
map.removeOverlays(Phoenix);
map.removeOverlays(Scottsdale);
map.removeOverlays(Tempe);
map.addOverlays(Avondale);
centerByArray(Avondale, false, false);
cntMarker += Avondale.length;
map.addOverlays(Chandler);
centerByArray(Chandler, false, false);
cntMarker += Chandler.length;
map.addOverlays(Glendale);
centerByArray(Glendale, false, false);
cntMarker += Glendale.length;
map.addOverlays(Mesa);
centerByArray(Mesa, false, false);
cntMarker += Mesa.length;
map.addOverlays(Phoenix);
centerByArray(Phoenix, false, false);
cntMarker += Phoenix.length;
map.addOverlays(Scottsdale);
centerByArray(Scottsdale, false, false);
cntMarker += Scottsdale.length;
map.addOverlays(Tempe);
centerByArray(Tempe, false, false);
cntMarker += Tempe.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;
}