function addMarkers(){
mySelect = document.getElementById('selection');
Honolulu = [];Pearl_City = [];Kailua_Kona = [];Kamuela = [];Pahoa = [];Kihei = [];Makawao = [];Mililani = [];mySelect.options[mySelect.options.length] = new Option("Honolulu schools",'all=Honolulu');
mySelect.options[mySelect.options.length] = new Option("Kailua Kona schools",'all=Kailua_Kona');
mySelect.options[mySelect.options.length] = new Option("Kamuela schools",'all=Kamuela');
mySelect.options[mySelect.options.length] = new Option("Kihei schools",'all=Kihei');
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("Pahoa schools",'all=Pahoa');
mySelect.options[mySelect.options.length] = new Option("Pearl City schools",'all=Pearl_City');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Honolulu[Honolulu.length] = createMarker(new GPoint(-157.74973100,21.27840800),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Calvary By The Sea Montessori School",'Honolulu=' + Honolulu.length);
Pearl_City[Pearl_City.length] = createMarker(new GPoint(-157.96152600,21.41569100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Children's House",'Pearl_City=' + Pearl_City.length);
Kailua_Kona[Kailua_Kona.length] = createMarker(new GPoint(-155.98591700,19.67513800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Hawaii Montessori School At Kona",'Kailua_Kona=' + Kailua_Kona.length);
Kamuela[Kamuela.length] = createMarker(new GPoint(-155.66049000,20.02504600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Hawai'i Montessori Schools - Kamuela",'Kamuela=' + Kamuela.length);
Honolulu[Honolulu.length] = createMarker(new GPoint(-157.85780300,21.30339600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Kawaiaha'o Church School",'Honolulu=' + Honolulu.length);
Honolulu[Honolulu.length] = createMarker(new GPoint(-157.80898900,21.28800100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("L Robert Allen Montessori",'Honolulu=' + Honolulu.length);
Honolulu[Honolulu.length] = createMarker(new GPoint(-157.84125300,21.30484800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Lokahi Montessori School",'Honolulu=' + Honolulu.length);
Honolulu[Honolulu.length] = createMarker(new GPoint(-157.83624800,21.30865900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Montessori Community School",'Honolulu=' + Honolulu.length);
Pahoa[Pahoa.length] = createMarker(new GPoint(-154.92220000,19.47960000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Montessori Country School",'Pahoa=' + Pahoa.length);
Kihei[Kihei.length] = createMarker(new GPoint(-156.44640000,20.73080000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Montessori Hale O Keiki Inc",'Kihei=' + Kihei.length);
Makawao[Makawao.length] = createMarker(new GPoint(-156.32263400,20.86950300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Montessori School Of Maui",'Makawao=' + Makawao.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);
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.92888000,21.33892000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Star Of The Sea Early Learning Center",'Honolulu=' + Honolulu.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);
Kamuela[Kamuela.length] = createMarker(new GPoint(-155.70020000,19.96150000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Waimea Community Montessori School",'Kamuela=' + Kamuela.length);
map.removeOverlays(Honolulu);
map.removeOverlays(Kailua_Kona);
map.removeOverlays(Kamuela);
map.removeOverlays(Kihei);
map.removeOverlays(Makawao);
map.removeOverlays(Mililani);
map.removeOverlays(Pahoa);
map.removeOverlays(Pearl_City);
setTimeout(function(){map.addOverlays(Honolulu)},1000);
setTimeout(function(){map.addOverlays(Kailua_Kona)},1000);
setTimeout(function(){map.addOverlays(Kamuela)},1000);
setTimeout(function(){map.addOverlays(Kihei)},1000);
setTimeout(function(){map.addOverlays(Makawao)},1000);
setTimeout(function(){map.addOverlays(Mililani)},1000);
setTimeout(function(){map.addOverlays(Pahoa)},1000);
setTimeout(function(){map.addOverlays(Pearl_City)},1000);
maxLng = -154.92220000;
maxLat = 21.45799900;
minLng = -158.01452300;
minLat = 19.47960000;
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(Honolulu);
map.removeOverlays(Kailua_Kona);
map.removeOverlays(Kamuela);
map.removeOverlays(Kihei);
map.removeOverlays(Makawao);
map.removeOverlays(Mililani);
map.removeOverlays(Pahoa);
map.removeOverlays(Pearl_City);
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(Honolulu);
map.removeOverlays(Kailua_Kona);
map.removeOverlays(Kamuela);
map.removeOverlays(Kihei);
map.removeOverlays(Makawao);
map.removeOverlays(Mililani);
map.removeOverlays(Pahoa);
map.removeOverlays(Pearl_City);
map.addOverlays(Honolulu);
centerByArray(Honolulu, false, false);
cntMarker += Honolulu.length;
map.addOverlays(Kailua_Kona);
centerByArray(Kailua_Kona, false, false);
cntMarker += Kailua_Kona.length;
map.addOverlays(Kamuela);
centerByArray(Kamuela, false, false);
cntMarker += Kamuela.length;
map.addOverlays(Kihei);
centerByArray(Kihei, false, false);
cntMarker += Kihei.length;
map.addOverlays(Makawao);
centerByArray(Makawao, false, false);
cntMarker += Makawao.length;
map.addOverlays(Mililani);
centerByArray(Mililani, false, false);
cntMarker += Mililani.length;
map.addOverlays(Pahoa);
centerByArray(Pahoa, false, false);
cntMarker += Pahoa.length;
map.addOverlays(Pearl_City);
centerByArray(Pearl_City, false, false);
cntMarker += Pearl_City.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///8082,8126,8134,8140,8155,8196,8200,34560,34748,34747,8209,8157,8158,8188,8156,8085,/all');
//window.open('/map.php?type=2&schools=8082,8126,8134,8140,8155,8196,8200,34560,34748,34747,8209,8157,8158,8188,8156,8085,&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;
}