function addMarkers(){
mySelect = document.getElementById('selection');
Pearl_City = [];Kahului = [];Honolulu = [];Kamuela = [];Kaneohe = [];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("Kamuela schools",'all=Kamuela');
mySelect.options[mySelect.options.length] = new Option("Kaneohe schools",'all=Kaneohe');
mySelect.options[mySelect.options.length] = new Option("Pearl City schools",'all=Pearl_City');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
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);
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.90253800,21.36516200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Christian Academy",'Honolulu=' + Honolulu.length);
Kamuela[Kamuela.length] = createMarker(new GPoint(-155.70078400,20.02930500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Hawaii Preparatory Academy",'Kamuela=' + Kamuela.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.73464500,21.28576300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Honolulu Waldorf School",'Honolulu=' + Honolulu.length);
Honolulu[Honolulu.length] = createMarker(new GPoint(-157.83497800,21.30612200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Playmate Kindergarten, Day Car",'Honolulu=' + Honolulu.length);
Honolulu[Honolulu.length] = createMarker(new GPoint(-157.85644500,21.31025500),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("St. Andrews Priory School",'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);
Honolulu[Honolulu.length] = createMarker(new GPoint(-157.82500000,21.29160000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Varsity International 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);
map.removeOverlays(Honolulu);
map.removeOverlays(Kahului);
map.removeOverlays(Kamuela);
map.removeOverlays(Kaneohe);
map.removeOverlays(Pearl_City);
setTimeout(function(){map.addOverlays(Honolulu)},1000);
setTimeout(function(){map.addOverlays(Kahului)},1000);
setTimeout(function(){map.addOverlays(Kamuela)},1000);
setTimeout(function(){map.addOverlays(Kaneohe)},1000);
setTimeout(function(){map.addOverlays(Pearl_City)},1000);
maxLng = -155.70078400;
maxLat = 21.41791300;
minLng = -157.96152600;
minLat = 20.02930500;
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(Kahului);
map.removeOverlays(Kamuela);
map.removeOverlays(Kaneohe);
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(Pearl_City);map.removeOverlays(Honolulu);
map.removeOverlays(Kahului);
map.removeOverlays(Kamuela);
map.removeOverlays(Kaneohe);
map.removeOverlays(Pearl_City);
map.addOverlays(Honolulu);
centerByArray(Honolulu, false, false);
cntMarker += Honolulu.length;
map.addOverlays(Kahului);
centerByArray(Kahului, false, false);
cntMarker += Kahului.length;
map.addOverlays(Kamuela);
centerByArray(Kamuela, false, false);
cntMarker += Kamuela.length;
map.addOverlays(Kaneohe);
centerByArray(Kaneohe, false, false);
cntMarker += Kaneohe.length;
map.addOverlays(Pearl_City);
centerByArray(Pearl_City, false, false);
cntMarker += Pearl_City.length;
centerByArray(Pearl_City,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///8087,8113,8177,8207,8104,8087,8109,8113,8167,8177,8197,8086,8104,8212,8085,/all');
//window.open('/map.php?type=2&schools=8087,8113,8177,8207,8104,8087,8109,8113,8167,8177,8197,8086,8104,8212,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;
}