function addMarkers(){
mySelect = document.getElementById('selection');
Glendale = [];Yuma = [];Phoenix = [];Coolidge = [];Chandler = [];Douglas = [];Flagstaff = [];Thatcher = [];Avondale = [];Mesa = [];Tucson = [];Tempe = [];Kingman = [];Holbrook = [];Scottsdale = [];Prescott = [];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("Coolidge Schools",'all=Coolidge');
mySelect.options[mySelect.options.length] = new Option("Douglas Schools",'all=Douglas');
mySelect.options[mySelect.options.length] = new Option("Flagstaff Schools",'all=Flagstaff');
mySelect.options[mySelect.options.length] = new Option("Glendale Schools",'all=Glendale');
mySelect.options[mySelect.options.length] = new Option("Holbrook Schools",'all=Holbrook');
mySelect.options[mySelect.options.length] = new Option("Kingman Schools",'all=Kingman');
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("Prescott Schools",'all=Prescott');
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("Thatcher Schools",'all=Thatcher');
mySelect.options[mySelect.options.length] = new Option("Tucson Schools",'all=Tucson');
mySelect.options[mySelect.options.length] = new Option("Yuma Schools",'all=Yuma');
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(32.70667199999999752,-114.495530999999999);
tmpLen=Yuma.length;
Yuma[tmpLen] = createMarker(tmpLatLng,"",iconGr);
Yuma[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("Arizona Western College",'Yuma=' + Yuma.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(32.95464700000000135,-111.652838000000002);
tmpLen=Coolidge.length;
Coolidge[tmpLen] = createMarker(tmpLatLng,"",iconGr);
Coolidge[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("Central Arizona College",'Coolidge=' + Coolidge.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(31.36419700000000077,-109.696599000000006);
tmpLen=Douglas.length;
Douglas[tmpLen] = createMarker(tmpLatLng,"",iconGr);
Douglas[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("Cochise College",'Douglas=' + Douglas.length);
tmpLatLng=new GLatLng(35.17955200000000104,-111.648410999999995);
tmpLen=Flagstaff.length;
Flagstaff[tmpLen] = createMarker(tmpLatLng,"",iconGr);
Flagstaff[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("Coconino County Community College",'Flagstaff=' + Flagstaff.length);
tmpLatLng=new GLatLng(32.84301299999999912,-109.762872000000001);
tmpLen=Thatcher.length;
Thatcher[tmpLen] = createMarker(tmpLatLng,"",iconGr);
Thatcher[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("Eastern Arizona College",'Thatcher=' + Thatcher.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(32.20677599999999785,-110.875527000000005);
tmpLen=Tucson.length;
Tucson[tmpLen] = createMarker(tmpLatLng,"",iconRd);
Tucson[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("International Institute Of Americas",'Tucson=' + Tucson.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(32.29760000000000275,-110.995924999999999);
tmpLen=Tucson.length;
Tucson[tmpLen] = createMarker(tmpLatLng,"",iconRd);
Tucson[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("Itt Technical Institute-tucson",'Tucson=' + Tucson.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(35.26833200000000090,-114.030158999999997);
tmpLen=Kingman.length;
Kingman[tmpLen] = createMarker(tmpLatLng,"",iconGr);
Kingman[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("Mohave Community College",'Kingman=' + Kingman.length);
tmpLatLng=new GLatLng(34.90700700000000011,-110.159958000000003);
tmpLen=Holbrook.length;
Holbrook[tmpLen] = createMarker(tmpLatLng,"",iconGr);
Holbrook[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("Northland Pioneer College",'Holbrook=' + Holbrook.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(32.22497599999999806,-111.011320999999995);
tmpLen=Tucson.length;
Tucson[tmpLen] = createMarker(tmpLatLng,"",iconGr);
Tucson[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("Pima Community College",'Tucson=' + Tucson.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);
tmpLatLng=new GLatLng(34.54495399999999705,-112.455392000000003);
tmpLen=Prescott.length;
Prescott[tmpLen] = createMarker(tmpLatLng,"",iconGr);
Prescott[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("Yavapai College",'Prescott=' + Prescott.length);
map.removeOverlays(Avondale);
map.removeOverlays(Chandler);
map.removeOverlays(Coolidge);
map.removeOverlays(Douglas);
map.removeOverlays(Flagstaff);
map.removeOverlays(Glendale);
map.removeOverlays(Holbrook);
map.removeOverlays(Kingman);
map.removeOverlays(Mesa);
map.removeOverlays(Phoenix);
map.removeOverlays(Prescott);
map.removeOverlays(Scottsdale);
map.removeOverlays(Tempe);
map.removeOverlays(Thatcher);
map.removeOverlays(Tucson);
map.removeOverlays(Yuma);
setTimeout(function(){map.addOverlays(Avondale)},1000);
setTimeout(function(){map.addOverlays(Chandler)},1000);
setTimeout(function(){map.addOverlays(Coolidge)},1000);
setTimeout(function(){map.addOverlays(Douglas)},1000);
setTimeout(function(){map.addOverlays(Flagstaff)},1000);
setTimeout(function(){map.addOverlays(Glendale)},1000);
setTimeout(function(){map.addOverlays(Holbrook)},1000);
setTimeout(function(){map.addOverlays(Kingman)},1000);
setTimeout(function(){map.addOverlays(Mesa)},1000);
setTimeout(function(){map.addOverlays(Phoenix)},1000);
setTimeout(function(){map.addOverlays(Prescott)},1000);
setTimeout(function(){map.addOverlays(Scottsdale)},1000);
setTimeout(function(){map.addOverlays(Tempe)},1000);
setTimeout(function(){map.addOverlays(Thatcher)},1000);
setTimeout(function(){map.addOverlays(Tucson)},1000);
setTimeout(function(){map.addOverlays(Yuma)},1000);
getPoly("","state","","AZ");}
// 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(Coolidge);
map.removeOverlays(Douglas);
map.removeOverlays(Flagstaff);
map.removeOverlays(Glendale);
map.removeOverlays(Holbrook);
map.removeOverlays(Kingman);
map.removeOverlays(Mesa);
map.removeOverlays(Phoenix);
map.removeOverlays(Prescott);
map.removeOverlays(Scottsdale);
map.removeOverlays(Tempe);
map.removeOverlays(Thatcher);
map.removeOverlays(Tucson);
map.removeOverlays(Yuma);
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(Coolidge);
map.removeOverlays(Douglas);
map.removeOverlays(Flagstaff);
map.removeOverlays(Glendale);
map.removeOverlays(Holbrook);
map.removeOverlays(Kingman);
map.removeOverlays(Mesa);
map.removeOverlays(Phoenix);
map.removeOverlays(Prescott);
map.removeOverlays(Scottsdale);
map.removeOverlays(Tempe);
map.removeOverlays(Thatcher);
map.removeOverlays(Tucson);
map.removeOverlays(Yuma);
map.addOverlays(Avondale);
centerByArray(Avondale, false, false);
cntMarker += Avondale.length;
map.addOverlays(Chandler);
centerByArray(Chandler, false, false);
cntMarker += Chandler.length;
map.addOverlays(Coolidge);
centerByArray(Coolidge, false, false);
cntMarker += Coolidge.length;
map.addOverlays(Douglas);
centerByArray(Douglas, false, false);
cntMarker += Douglas.length;
map.addOverlays(Flagstaff);
centerByArray(Flagstaff, false, false);
cntMarker += Flagstaff.length;
map.addOverlays(Glendale);
centerByArray(Glendale, false, false);
cntMarker += Glendale.length;
map.addOverlays(Holbrook);
centerByArray(Holbrook, false, false);
cntMarker += Holbrook.length;
map.addOverlays(Kingman);
centerByArray(Kingman, false, false);
cntMarker += Kingman.length;
map.addOverlays(Mesa);
centerByArray(Mesa, false, false);
cntMarker += Mesa.length;
map.addOverlays(Phoenix);
centerByArray(Phoenix, false, false);
cntMarker += Phoenix.length;
map.addOverlays(Prescott);
centerByArray(Prescott, false, false);
cntMarker += Prescott.length;
map.addOverlays(Scottsdale);
centerByArray(Scottsdale, false, false);
cntMarker += Scottsdale.length;
map.addOverlays(Tempe);
centerByArray(Tempe, false, false);
cntMarker += Tempe.length;
map.addOverlays(Thatcher);
centerByArray(Thatcher, false, false);
cntMarker += Thatcher.length;
map.addOverlays(Tucson);
centerByArray(Tucson, false, false);
cntMarker += Tucson.length;
map.addOverlays(Yuma);
centerByArray(Yuma, false, false);
cntMarker += Yuma.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;
}