function addMarkers(){
mySelect = document.getElementById('selection');
Boise = [];Coeur_Dalene = [];Idaho_Falls = [];Pocatello = [];Post_Falls = [];Moscow = [];Nampa = [];Lewiston = [];Twin_Falls = [];Rupert = [];Grangeville = [];Cottonwood = [];mySelect.options[mySelect.options.length] = new Option("Boise schools",'all=Boise');
mySelect.options[mySelect.options.length] = new Option("Coeur Dalene schools",'all=Coeur_Dalene');
mySelect.options[mySelect.options.length] = new Option("Cottonwood schools",'all=Cottonwood');
mySelect.options[mySelect.options.length] = new Option("Grangeville schools",'all=Grangeville');
mySelect.options[mySelect.options.length] = new Option("Idaho Falls schools",'all=Idaho_Falls');
mySelect.options[mySelect.options.length] = new Option("Lewiston schools",'all=Lewiston');
mySelect.options[mySelect.options.length] = new Option("Moscow schools",'all=Moscow');
mySelect.options[mySelect.options.length] = new Option("Nampa schools",'all=Nampa');
mySelect.options[mySelect.options.length] = new Option("Pocatello schools",'all=Pocatello');
mySelect.options[mySelect.options.length] = new Option("Post Falls schools",'all=Post_Falls');
mySelect.options[mySelect.options.length] = new Option("Rupert schools",'all=Rupert');
mySelect.options[mySelect.options.length] = new Option("Twin Falls schools",'all=Twin_Falls');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Boise[Boise.length] = createMarker(new GPoint(-116.26911100,43.60423900),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Bishop Kelly High School",'Boise=' + Boise.length);
Coeur_Dalene[Coeur_Dalene.length] = createMarker(new GPoint(-116.82457100,47.72113700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Holy Family Catholic School",'Coeur_Dalene=' + Coeur_Dalene.length);
Idaho_Falls[Idaho_Falls.length] = createMarker(new GPoint(-112.03210200,43.48993700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Holy Rosary Elementary School",'Idaho_Falls=' + Idaho_Falls.length);
Pocatello[Pocatello.length] = createMarker(new GPoint(-112.44515200,42.87129800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Holy Spirit Catholic School",'Pocatello=' + Pocatello.length);
Post_Falls[Post_Falls.length] = createMarker(new GPoint(-116.94805900,47.71153000),"",iconBl);
mySelect.options[mySelect.options.length] = new Option("Immaculate Conception Academy",'Post_Falls=' + Post_Falls.length);
Boise[Boise.length] = createMarker(new GPoint(-116.23005900,43.59683400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sacred Heart School",'Boise=' + Boise.length);
Boise[Boise.length] = createMarker(new GPoint(-116.19816600,43.62178400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Josephs Elementary School",'Boise=' + Boise.length);
Moscow[Moscow.length] = createMarker(new GPoint(-116.99097400,46.73592000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Mary S School",'Moscow=' + Moscow.length);
Boise[Boise.length] = createMarker(new GPoint(-116.22208800,43.63133900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Marys School",'Boise=' + Boise.length);
Nampa[Nampa.length] = createMarker(new GPoint(-116.56338400,43.57102900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Pauls Catholic School",'Nampa=' + Nampa.length);
Lewiston[Lewiston.length] = createMarker(new GPoint(-117.02413700,46.41573700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Stanislaus Tri-parish School",'Lewiston=' + Lewiston.length);
Twin_Falls[Twin_Falls.length] = createMarker(new GPoint(-114.46482500,42.55898200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Edwards Catholic School",'Twin_Falls=' + Twin_Falls.length);
Boise[Boise.length] = createMarker(new GPoint(-116.27583700,43.62651100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Marks Elementary School",'Boise=' + Boise.length);
Rupert[Rupert.length] = createMarker(new GPoint(-113.64030000,42.68670000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Nicholas School",'Rupert=' + Rupert.length);
Moscow[Moscow.length] = createMarker(new GPoint(-116.99209900,46.73663900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St Rose's Kindergarten Center",'Moscow=' + Moscow.length);
Grangeville[Grangeville.length] = createMarker(new GPoint(-116.12709600,45.92485300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Sts Peter & Paul School",'Grangeville=' + Grangeville.length);
Cottonwood[Cottonwood.length] = createMarker(new GPoint(-116.36867900,45.99816000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Summit Academy",'Cottonwood=' + Cottonwood.length);
map.removeOverlays(Boise);
map.removeOverlays(Coeur_Dalene);
map.removeOverlays(Cottonwood);
map.removeOverlays(Grangeville);
map.removeOverlays(Idaho_Falls);
map.removeOverlays(Lewiston);
map.removeOverlays(Moscow);
map.removeOverlays(Nampa);
map.removeOverlays(Pocatello);
map.removeOverlays(Post_Falls);
map.removeOverlays(Rupert);
map.removeOverlays(Twin_Falls);
setTimeout(function(){map.addOverlays(Boise)},1000);
setTimeout(function(){map.addOverlays(Coeur_Dalene)},1000);
setTimeout(function(){map.addOverlays(Cottonwood)},1000);
setTimeout(function(){map.addOverlays(Grangeville)},1000);
setTimeout(function(){map.addOverlays(Idaho_Falls)},1000);
setTimeout(function(){map.addOverlays(Lewiston)},1000);
setTimeout(function(){map.addOverlays(Moscow)},1000);
setTimeout(function(){map.addOverlays(Nampa)},1000);
setTimeout(function(){map.addOverlays(Pocatello)},1000);
setTimeout(function(){map.addOverlays(Post_Falls)},1000);
setTimeout(function(){map.addOverlays(Rupert)},1000);
setTimeout(function(){map.addOverlays(Twin_Falls)},1000);
maxLng = -112.03210200;
maxLat = 47.72113700;
minLng = -117.02413700;
minLat = 42.55898200;
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(Boise);
map.removeOverlays(Coeur_Dalene);
map.removeOverlays(Cottonwood);
map.removeOverlays(Grangeville);
map.removeOverlays(Idaho_Falls);
map.removeOverlays(Lewiston);
map.removeOverlays(Moscow);
map.removeOverlays(Nampa);
map.removeOverlays(Pocatello);
map.removeOverlays(Post_Falls);
map.removeOverlays(Rupert);
map.removeOverlays(Twin_Falls);
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(Boise);map.removeOverlays(Boise);
map.removeOverlays(Coeur_Dalene);
map.removeOverlays(Cottonwood);
map.removeOverlays(Grangeville);
map.removeOverlays(Idaho_Falls);
map.removeOverlays(Lewiston);
map.removeOverlays(Moscow);
map.removeOverlays(Nampa);
map.removeOverlays(Pocatello);
map.removeOverlays(Post_Falls);
map.removeOverlays(Rupert);
map.removeOverlays(Twin_Falls);
map.addOverlays(Boise);
centerByArray(Boise, false, false);
cntMarker += Boise.length;
map.addOverlays(Coeur_Dalene);
centerByArray(Coeur_Dalene, false, false);
cntMarker += Coeur_Dalene.length;
map.addOverlays(Cottonwood);
centerByArray(Cottonwood, false, false);
cntMarker += Cottonwood.length;
map.addOverlays(Grangeville);
centerByArray(Grangeville, false, false);
cntMarker += Grangeville.length;
map.addOverlays(Idaho_Falls);
centerByArray(Idaho_Falls, false, false);
cntMarker += Idaho_Falls.length;
map.addOverlays(Lewiston);
centerByArray(Lewiston, false, false);
cntMarker += Lewiston.length;
map.addOverlays(Moscow);
centerByArray(Moscow, false, false);
cntMarker += Moscow.length;
map.addOverlays(Nampa);
centerByArray(Nampa, false, false);
cntMarker += Nampa.length;
map.addOverlays(Pocatello);
centerByArray(Pocatello, false, false);
cntMarker += Pocatello.length;
map.addOverlays(Post_Falls);
centerByArray(Post_Falls, false, false);
cntMarker += Post_Falls.length;
map.addOverlays(Rupert);
centerByArray(Rupert, false, false);
cntMarker += Rupert.length;
map.addOverlays(Twin_Falls);
centerByArray(Twin_Falls, false, false);
cntMarker += Twin_Falls.length;
centerByArray(Boise,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///8218,32348,31176,8279,8291,8294,8292,8251,32348,8300,8252,8298,8293,8297,8296,8289,31176,8295,8290,/all');
//window.open('/map.php?type=2&schools=8218,32348,31176,8279,8291,8294,8292,8251,32348,8300,8252,8298,8293,8297,8296,8289,31176,8295,8290,&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;
}