function addMarkers(){
mySelect = document.getElementById('selection');
Honolulu = [];Paia = [];Aiea = [];Hilo = [];Kahului = [];Kailua = [];Kailua_Kona = [];Waipahu = [];Holualoa = [];Hoolehua = [];Haleiwa = [];Kaneohe = [];mySelect.options[mySelect.options.length] = new Option("Aiea schools",'all=Aiea');
mySelect.options[mySelect.options.length] = new Option("Haleiwa schools",'all=Haleiwa');
mySelect.options[mySelect.options.length] = new Option("Hilo schools",'all=Hilo');
mySelect.options[mySelect.options.length] = new Option("Holualoa schools",'all=Holualoa');
mySelect.options[mySelect.options.length] = new Option("Honolulu schools",'all=Honolulu');
mySelect.options[mySelect.options.length] = new Option("Hoolehua schools",'all=Hoolehua');
mySelect.options[mySelect.options.length] = new Option("Kahului schools",'all=Kahului');
mySelect.options[mySelect.options.length] = new Option("Kailua schools",'all=Kailua');
mySelect.options[mySelect.options.length] = new Option("Kailua Kona schools",'all=Kailua_Kona');
mySelect.options[mySelect.options.length] = new Option("Kaneohe schools",'all=Kaneohe');
mySelect.options[mySelect.options.length] = new Option("Paia schools",'all=Paia');
mySelect.options[mySelect.options.length] = new Option("Waipahu schools",'all=Waipahu');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Honolulu[Honolulu.length] = createMarker(new GPoint(-157.83404600,21.29838500),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Central Union Preschool And Ki",'Honolulu=' + Honolulu.length);
Honolulu[Honolulu.length] = createMarker(new GPoint(-157.90253800,21.36516200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Christian Academy",'Honolulu=' + Honolulu.length);
Paia[Paia.length] = createMarker(new GPoint(-156.37179000,20.90329500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Doris Todd Memorial Christian School",'Paia=' + Paia.length);
Honolulu[Honolulu.length] = createMarker(new GPoint(-157.85847000,21.32535600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Good Shepherd Preschool",'Honolulu=' + Honolulu.length);
Aiea[Aiea.length] = createMarker(new GPoint(-157.91386600,21.37224000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Grace Christian Academy",'Aiea=' + Aiea.length);
Hilo[Hilo.length] = createMarker(new GPoint(-155.08854100,19.72204900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Haili Christian School",'Hilo=' + Hilo.length);
Hilo[Hilo.length] = createMarker(new GPoint(-155.10597100,19.67644100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Hale Aloha Nazarene School",'Hilo=' + Hilo.length);
Kahului[Kahului.length] = createMarker(new GPoint(-156.45904400,20.87411400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Ka'ahumanu Hou Christian School",'Kahului=' + Kahului.length);
Kailua[Kailua.length] = createMarker(new GPoint(-157.74480000,21.40500000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Kailua Christian Academy",'Kailua=' + Kailua.length);
Honolulu[Honolulu.length] = createMarker(new GPoint(-157.79847100,21.28084300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Kaimuki Christian School",'Honolulu=' + Honolulu.length);
Kailua_Kona[Kailua_Kona.length] = createMarker(new GPoint(-155.73190000,19.92210000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Kona Christian Academy",'Kailua_Kona=' + Kailua_Kona.length);
Waipahu[Waipahu.length] = createMarker(new GPoint(-158.00028200,21.39341400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lanakila Baptist Elementary School",'Waipahu=' + Waipahu.length);
Holualoa[Holualoa.length] = createMarker(new GPoint(-155.96948600,19.67930300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Makua Lani Christian School",'Holualoa=' + Holualoa.length);
Kahului[Kahului.length] = createMarker(new GPoint(-156.46435000,20.88512800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Maui Adventist School",'Kahului=' + Kahului.length);
Hoolehua[Hoolehua.length] = createMarker(new GPoint(-157.09150000,21.16210000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Molokai Christian Academy",'Hoolehua=' + Hoolehua.length);
Waipahu[Waipahu.length] = createMarker(new GPoint(-157.99889200,21.41124600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Pearl Harbor Christian Academy",'Waipahu=' + Waipahu.length);
Haleiwa[Haleiwa.length] = createMarker(new GPoint(-158.05885300,21.65559700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sunset Beach Christian School",'Haleiwa=' + Haleiwa.length);
Kailua[Kailua.length] = createMarker(new GPoint(-157.76390900,21.37570900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Trinity Christian School",'Kailua=' + Kailua.length);
Kailua_Kona[Kailua_Kona.length] = createMarker(new GPoint(-155.98647400,19.63104000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("University Of The Nations Preschool",'Kailua_Kona=' + Kailua_Kona.length);
Honolulu[Honolulu.length] = createMarker(new GPoint(-157.85256300,21.32546800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Waolani Judd Nazarene School",'Honolulu=' + Honolulu.length);
Kaneohe[Kaneohe.length] = createMarker(new GPoint(-157.80648100,21.41791300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Windward Nazarene Academy",'Kaneohe=' + Kaneohe.length);
Honolulu[Honolulu.length] = createMarker(new GPoint(-157.85873800,21.30325100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Word Of Life Academy",'Honolulu=' + Honolulu.length);
map.removeOverlays(Aiea);
map.removeOverlays(Haleiwa);
map.removeOverlays(Hilo);
map.removeOverlays(Holualoa);
map.removeOverlays(Honolulu);
map.removeOverlays(Hoolehua);
map.removeOverlays(Kahului);
map.removeOverlays(Kailua);
map.removeOverlays(Kailua_Kona);
map.removeOverlays(Kaneohe);
map.removeOverlays(Paia);
map.removeOverlays(Waipahu);
setTimeout(function(){map.addOverlays(Aiea)},1000);
setTimeout(function(){map.addOverlays(Haleiwa)},1000);
setTimeout(function(){map.addOverlays(Hilo)},1000);
setTimeout(function(){map.addOverlays(Holualoa)},1000);
setTimeout(function(){map.addOverlays(Honolulu)},1000);
setTimeout(function(){map.addOverlays(Hoolehua)},1000);
setTimeout(function(){map.addOverlays(Kahului)},1000);
setTimeout(function(){map.addOverlays(Kailua)},1000);
setTimeout(function(){map.addOverlays(Kailua_Kona)},1000);
setTimeout(function(){map.addOverlays(Kaneohe)},1000);
setTimeout(function(){map.addOverlays(Paia)},1000);
setTimeout(function(){map.addOverlays(Waipahu)},1000);
maxLng = -155.08854100;
maxLat = 21.65559700;
minLng = -158.05885300;
minLat = 19.63104000;
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(Aiea);
map.removeOverlays(Haleiwa);
map.removeOverlays(Hilo);
map.removeOverlays(Holualoa);
map.removeOverlays(Honolulu);
map.removeOverlays(Hoolehua);
map.removeOverlays(Kahului);
map.removeOverlays(Kailua);
map.removeOverlays(Kailua_Kona);
map.removeOverlays(Kaneohe);
map.removeOverlays(Paia);
map.removeOverlays(Waipahu);
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(Honolulu);map.removeOverlays(Aiea);
map.removeOverlays(Haleiwa);
map.removeOverlays(Hilo);
map.removeOverlays(Holualoa);
map.removeOverlays(Honolulu);
map.removeOverlays(Hoolehua);
map.removeOverlays(Kahului);
map.removeOverlays(Kailua);
map.removeOverlays(Kailua_Kona);
map.removeOverlays(Kaneohe);
map.removeOverlays(Paia);
map.removeOverlays(Waipahu);
map.addOverlays(Aiea);
centerByArray(Aiea, false, false);
cntMarker += Aiea.length;
map.addOverlays(Haleiwa);
centerByArray(Haleiwa, false, false);
cntMarker += Haleiwa.length;
map.addOverlays(Hilo);
centerByArray(Hilo, false, false);
cntMarker += Hilo.length;
map.addOverlays(Holualoa);
centerByArray(Holualoa, false, false);
cntMarker += Holualoa.length;
map.addOverlays(Honolulu);
centerByArray(Honolulu, false, false);
cntMarker += Honolulu.length;
map.addOverlays(Hoolehua);
centerByArray(Hoolehua, false, false);
cntMarker += Hoolehua.length;
map.addOverlays(Kahului);
centerByArray(Kahului, false, false);
cntMarker += Kahului.length;
map.addOverlays(Kailua);
centerByArray(Kailua, false, false);
cntMarker += Kailua.length;
map.addOverlays(Kailua_Kona);
centerByArray(Kailua_Kona, false, false);
cntMarker += Kailua_Kona.length;
map.addOverlays(Kaneohe);
centerByArray(Kaneohe, false, false);
cntMarker += Kaneohe.length;
map.addOverlays(Paia);
centerByArray(Paia, false, false);
cntMarker += Paia.length;
map.addOverlays(Waipahu);
centerByArray(Waipahu, false, false);
cntMarker += Waipahu.length;
centerByArray(Honolulu,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///8096,8143,8087,8213,8153,8118,8120,8096,8202,8097,8098,8084,8087,35021,8121,8210,8213,8153,8118,8149,8120,8204,8129,34748,8212,8091,8136,33506,/all');
//window.open('/map.php?type=2&schools=8096,8143,8087,8213,8153,8118,8120,8096,8202,8097,8098,8084,8087,35021,8121,8210,8213,8153,8118,8149,8120,8204,8129,34748,8212,8091,8136,33506,&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;
}