function addMarkers(){
mySelect = document.getElementById('selection');
Honolulu = [];Kahului = [];Ewa_Beach = [];Waipahu = [];Lahaina = [];Wailuku = [];Kailua = [];Kapaa = [];Aiea = [];Mililani = [];Hilo = [];Makawao = [];Waialua = [];Kaneohe = [];Kekaha = [];mySelect.options[mySelect.options.length] = new Option("Aiea schools",'all=Aiea');
mySelect.options[mySelect.options.length] = new Option("Ewa Beach schools",'all=Ewa_Beach');
mySelect.options[mySelect.options.length] = new Option("Hilo schools",'all=Hilo');
mySelect.options[mySelect.options.length] = new Option("Honolulu schools",'all=Honolulu');
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("Kaneohe schools",'all=Kaneohe');
mySelect.options[mySelect.options.length] = new Option("Kapaa schools",'all=Kapaa');
mySelect.options[mySelect.options.length] = new Option("Kekaha schools",'all=Kekaha');
mySelect.options[mySelect.options.length] = new Option("Lahaina schools",'all=Lahaina');
mySelect.options[mySelect.options.length] = new Option("Makawao schools",'all=Makawao');
mySelect.options[mySelect.options.length] = new Option("Mililani schools",'all=Mililani');
mySelect.options[mySelect.options.length] = new Option("Waialua schools",'all=Waialua');
mySelect.options[mySelect.options.length] = new Option("Wailuku schools",'all=Wailuku');
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.85431400,21.31828500),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Cathedral Catholic Academy",'Honolulu=' + Honolulu.length);
Kahului[Kahului.length] = createMarker(new GPoint(-156.46640200,20.88494600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Christ The King School",'Kahului=' + Kahului.length);
Honolulu[Honolulu.length] = createMarker(new GPoint(-157.86851600,21.33070700),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Damien Memorial School",'Honolulu=' + Honolulu.length);
Honolulu[Honolulu.length] = createMarker(new GPoint(-157.93049100,21.33792500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Holy Family Catholic Academy",'Honolulu=' + Honolulu.length);
Honolulu[Honolulu.length] = createMarker(new GPoint(-157.72875000,21.28356900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Holy Trinity School",'Honolulu=' + Honolulu.length);
Honolulu[Honolulu.length] = createMarker(new GPoint(-157.83053800,21.30052700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Maryknoll School",'Honolulu=' + Honolulu.length);
Honolulu[Honolulu.length] = createMarker(new GPoint(-157.83057100,21.30052000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Maryknoll School",'Honolulu=' + Honolulu.length);
Ewa_Beach[Ewa_Beach.length] = createMarker(new GPoint(-158.00636200,21.31653800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Our Lady Of Perpetual Help School",'Ewa_Beach=' + Ewa_Beach.length);
Waipahu[Waipahu.length] = createMarker(new GPoint(-157.99350100,21.40986900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Rosary Preschool & Kindergarte",'Waipahu=' + Waipahu.length);
Lahaina[Lahaina.length] = createMarker(new GPoint(-156.67599300,20.87548000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sacred Hearts School And Early Learning Center",'Lahaina=' + Lahaina.length);
Wailuku[Wailuku.length] = createMarker(new GPoint(-156.49572600,20.89197000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Anthony Jr/sr High School",'Wailuku=' + Wailuku.length);
Kailua[Kailua.length] = createMarker(new GPoint(-157.73919500,21.40040900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Anthony School",'Kailua=' + Kailua.length);
Kapaa[Kapaa.length] = createMarker(new GPoint(-159.31676600,22.09205100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Catherine School",'Kapaa=' + Kapaa.length);
Aiea[Aiea.length] = createMarker(new GPoint(-157.93003600,21.37649400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Elizabeth Elementary School",'Aiea=' + Aiea.length);
Honolulu[Honolulu.length] = createMarker(new GPoint(-157.81230600,21.30440700),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("St. Francis School",'Honolulu=' + Honolulu.length);
Kailua[Kailua.length] = createMarker(new GPoint(-157.72866900,21.37956500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. John Vianney Parish School",'Kailua=' + Kailua.length);
Mililani[Mililani.length] = createMarker(new GPoint(-158.01452300,21.45799900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. John's Catholic Preschool",'Mililani=' + Mililani.length);
Waipahu[Waipahu.length] = createMarker(new GPoint(-158.00834000,21.38300600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Joseph Elementary School",'Waipahu=' + Waipahu.length);
Hilo[Hilo.length] = createMarker(new GPoint(-155.08379300,19.71384000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Joseph Jr/sr High School",'Hilo=' + Hilo.length);
Makawao[Makawao.length] = createMarker(new GPoint(-156.30844800,20.85635000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Joseph School",'Makawao=' + Makawao.length);
Honolulu[Honolulu.length] = createMarker(new GPoint(-157.80895200,21.28798300),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("St. Louis School",'Honolulu=' + Honolulu.length);
Waialua[Waialua.length] = createMarker(new GPoint(-158.12085100,21.56873700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Michaels Elementary School",'Waialua=' + Waialua.length);
Honolulu[Honolulu.length] = createMarker(new GPoint(-157.91402700,21.34671900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Philomena Early Learning Center",'Honolulu=' + Honolulu.length);
Honolulu[Honolulu.length] = createMarker(new GPoint(-157.86101400,21.32371200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Theresa Catholic School",'Honolulu=' + Honolulu.length);
Kaneohe[Kaneohe.length] = createMarker(new GPoint(-157.80566800,21.42154300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Anns School",'Kaneohe=' + Kaneohe.length);
Wailuku[Wailuku.length] = createMarker(new GPoint(-156.50620000,20.88820000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Anthony Grade School",'Wailuku=' + Wailuku.length);
Honolulu[Honolulu.length] = createMarker(new GPoint(-157.88217000,21.33045500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Anthony School-honolulu",'Honolulu=' + Honolulu.length);
Kekaha[Kekaha.length] = createMarker(new GPoint(-159.72890000,22.02010000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Theresa School",'Kekaha=' + Kekaha.length);
Honolulu[Honolulu.length] = createMarker(new GPoint(-157.92888000,21.33892000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Star Of The Sea Early Learning Center",'Honolulu=' + Honolulu.length);
Honolulu[Honolulu.length] = createMarker(new GPoint(-157.78103300,21.28026300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Star Of The Sea School",'Honolulu=' + Honolulu.length);
map.removeOverlays(Aiea);
map.removeOverlays(Ewa_Beach);
map.removeOverlays(Hilo);
map.removeOverlays(Honolulu);
map.removeOverlays(Kahului);
map.removeOverlays(Kailua);
map.removeOverlays(Kaneohe);
map.removeOverlays(Kapaa);
map.removeOverlays(Kekaha);
map.removeOverlays(Lahaina);
map.removeOverlays(Makawao);
map.removeOverlays(Mililani);
map.removeOverlays(Waialua);
map.removeOverlays(Wailuku);
map.removeOverlays(Waipahu);
setTimeout(function(){map.addOverlays(Aiea)},1000);
setTimeout(function(){map.addOverlays(Ewa_Beach)},1000);
setTimeout(function(){map.addOverlays(Hilo)},1000);
setTimeout(function(){map.addOverlays(Honolulu)},1000);
setTimeout(function(){map.addOverlays(Kahului)},1000);
setTimeout(function(){map.addOverlays(Kailua)},1000);
setTimeout(function(){map.addOverlays(Kaneohe)},1000);
setTimeout(function(){map.addOverlays(Kapaa)},1000);
setTimeout(function(){map.addOverlays(Kekaha)},1000);
setTimeout(function(){map.addOverlays(Lahaina)},1000);
setTimeout(function(){map.addOverlays(Makawao)},1000);
setTimeout(function(){map.addOverlays(Mililani)},1000);
setTimeout(function(){map.addOverlays(Waialua)},1000);
setTimeout(function(){map.addOverlays(Wailuku)},1000);
setTimeout(function(){map.addOverlays(Waipahu)},1000);
maxLng = -155.08379300;
maxLat = 22.09205100;
minLng = -159.72890000;
minLat = 19.71384000;
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(Ewa_Beach);
map.removeOverlays(Hilo);
map.removeOverlays(Honolulu);
map.removeOverlays(Kahului);
map.removeOverlays(Kailua);
map.removeOverlays(Kaneohe);
map.removeOverlays(Kapaa);
map.removeOverlays(Kekaha);
map.removeOverlays(Lahaina);
map.removeOverlays(Makawao);
map.removeOverlays(Mililani);
map.removeOverlays(Waialua);
map.removeOverlays(Wailuku);
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(Ewa_Beach);
map.removeOverlays(Hilo);
map.removeOverlays(Honolulu);
map.removeOverlays(Kahului);
map.removeOverlays(Kailua);
map.removeOverlays(Kaneohe);
map.removeOverlays(Kapaa);
map.removeOverlays(Kekaha);
map.removeOverlays(Lahaina);
map.removeOverlays(Makawao);
map.removeOverlays(Mililani);
map.removeOverlays(Waialua);
map.removeOverlays(Wailuku);
map.removeOverlays(Waipahu);
map.addOverlays(Aiea);
centerByArray(Aiea, false, false);
cntMarker += Aiea.length;
map.addOverlays(Ewa_Beach);
centerByArray(Ewa_Beach, false, false);
cntMarker += Ewa_Beach.length;
map.addOverlays(Hilo);
centerByArray(Hilo, false, false);
cntMarker += Hilo.length;
map.addOverlays(Honolulu);
centerByArray(Honolulu, false, false);
cntMarker += Honolulu.length;
map.addOverlays(Kahului);
centerByArray(Kahului, false, false);
cntMarker += Kahului.length;
map.addOverlays(Kailua);
centerByArray(Kailua, false, false);
cntMarker += Kailua.length;
map.addOverlays(Kaneohe);
centerByArray(Kaneohe, false, false);
cntMarker += Kaneohe.length;
map.addOverlays(Kapaa);
centerByArray(Kapaa, false, false);
cntMarker += Kapaa.length;
map.addOverlays(Kekaha);
centerByArray(Kekaha, false, false);
cntMarker += Kekaha.length;
map.addOverlays(Lahaina);
centerByArray(Lahaina, false, false);
cntMarker += Lahaina.length;
map.addOverlays(Makawao);
centerByArray(Makawao, false, false);
cntMarker += Makawao.length;
map.addOverlays(Mililani);
centerByArray(Mililani, false, false);
cntMarker += Mililani.length;
map.addOverlays(Waialua);
centerByArray(Waialua, false, false);
cntMarker += Waialua.length;
map.addOverlays(Wailuku);
centerByArray(Wailuku, false, false);
cntMarker += Wailuku.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///8191,8090,8147,8148,8173,8174,8180,8185,8162,8083,8090,8109,8111,8148,8173,8174,8196,8197,8182,8200,8201,8086,8181,8187,8178,8183,8198,8172,8192,8188,8194,8179,8170,8190,/all');
//window.open('/map.php?type=2&schools=8191,8090,8147,8148,8173,8174,8180,8185,8162,8083,8090,8109,8111,8148,8173,8174,8196,8197,8182,8200,8201,8086,8181,8187,8178,8183,8198,8172,8192,8188,8194,8179,8170,8190,&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;
}