function addMarkers(){
mySelect = document.getElementById('selection');
Anoka = [];Apple_Valley = [];Bloomington = [];Burnsville = [];Chanhassen = [];Cottage_Grove = [];Duluth = [];Edina = [];Excelsior = [];Golden_Valley = [];Little_Canada = [];Minneapolis = [];North_Mankato = [];Oakdale = [];Roseville = [];Saint_Louis_Park = [];Saint_Paul = [];St_Paul = [];Winona = [];Woodbury = [];mySelect.options[mySelect.options.length] = new Option("Anoka schools",'all=Anoka');
mySelect.options[mySelect.options.length] = new Option("Apple Valley schools",'all=Apple_Valley');
mySelect.options[mySelect.options.length] = new Option("Bloomington schools",'all=Bloomington');
mySelect.options[mySelect.options.length] = new Option("Burnsville schools",'all=Burnsville');
mySelect.options[mySelect.options.length] = new Option("Chanhassen schools",'all=Chanhassen');
mySelect.options[mySelect.options.length] = new Option("Cottage Grove schools",'all=Cottage_Grove');
mySelect.options[mySelect.options.length] = new Option("Duluth schools",'all=Duluth');
mySelect.options[mySelect.options.length] = new Option("Edina schools",'all=Edina');
mySelect.options[mySelect.options.length] = new Option("Excelsior schools",'all=Excelsior');
mySelect.options[mySelect.options.length] = new Option("Golden Valley schools",'all=Golden_Valley');
mySelect.options[mySelect.options.length] = new Option("Little Canada schools",'all=Little_Canada');
mySelect.options[mySelect.options.length] = new Option("Minneapolis schools",'all=Minneapolis');
mySelect.options[mySelect.options.length] = new Option("North Mankato schools",'all=North_Mankato');
mySelect.options[mySelect.options.length] = new Option("Oakdale schools",'all=Oakdale');
mySelect.options[mySelect.options.length] = new Option("Roseville schools",'all=Roseville');
mySelect.options[mySelect.options.length] = new Option("Saint Louis Park schools",'all=Saint_Louis_Park');
mySelect.options[mySelect.options.length] = new Option("Saint Paul schools",'all=Saint_Paul');
mySelect.options[mySelect.options.length] = new Option("St Paul schools",'all=St_Paul');
mySelect.options[mySelect.options.length] = new Option("Winona schools",'all=Winona');
mySelect.options[mySelect.options.length] = new Option("Woodbury schools",'all=Woodbury');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Anoka[Anoka.length] = createMarker(new GPoint(-93.40306600,45.20185900),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mt Olive Christian Preschool & Kindergarten",'Anoka=' + Anoka.length);
Apple_Valley[Apple_Valley.length] = createMarker(new GPoint(-93.18699800,44.75479100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Heritage Lutheran School",'Apple_Valley=' + Apple_Valley.length);
Bloomington[Bloomington.length] = createMarker(new GPoint(-93.32969900,44.80466900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Tlc Early Learning Center",'Bloomington=' + Bloomington.length);
Burnsville[Burnsville.length] = createMarker(new GPoint(-93.27248400,44.74104600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Berean Education Center",'Burnsville=' + Burnsville.length);
Burnsville[Burnsville.length] = createMarker(new GPoint(-93.23132900,44.80171200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("River Hills Early Childhood Ct",'Burnsville=' + Burnsville.length);
Chanhassen[Chanhassen.length] = createMarker(new GPoint(-93.55841400,44.85269000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Children Of Tomorrow",'Chanhassen=' + Chanhassen.length);
Cottage_Grove[Cottage_Grove.length] = createMarker(new GPoint(-92.93533100,44.81737400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Kinder Care Learning Center",'Cottage_Grove=' + Cottage_Grove.length);
Duluth[Duluth.length] = createMarker(new GPoint(-92.10306700,46.80673900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Summit School/educational Frontiers",'Duluth=' + Duluth.length);
Edina[Edina.length] = createMarker(new GPoint(-93.32955300,44.87648000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Kinderberry Hill",'Edina=' + Edina.length);
Excelsior[Excelsior.length] = createMarker(new GPoint(-93.56608800,44.90178100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Minnetonka Montessori",'Excelsior=' + Excelsior.length);
Golden_Valley[Golden_Valley.length] = createMarker(new GPoint(-93.37552400,44.98665000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Calvary Prekindergarten And Kindergarten",'Golden_Valley=' + Golden_Valley.length);
Little_Canada[Little_Canada.length] = createMarker(new GPoint(-93.08264700,45.02089500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Childrens Discovery Academy",'Little_Canada=' + Little_Canada.length);
Minneapolis[Minneapolis.length] = createMarker(new GPoint(-93.27812300,44.93882400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Zoe Academy",'Minneapolis=' + Minneapolis.length);
North_Mankato[North_Mankato.length] = createMarker(new GPoint(-94.05250800,44.17036200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Peter Pan Preschool",'North_Mankato=' + North_Mankato.length);
Oakdale[Oakdale.length] = createMarker(new GPoint(-92.98460500,44.96222500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Daidea Child Development Center",'Oakdale=' + Oakdale.length);
Roseville[Roseville.length] = createMarker(new GPoint(-93.14640800,45.01261400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Kinderberry Hill Child Development Center I",'Roseville=' + Roseville.length);
Saint_Louis_Park[Saint_Louis_Park.length] = createMarker(new GPoint(-93.39347100,44.95510600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Westwood Early Childhood Center",'Saint_Louis_Park=' + Saint_Louis_Park.length);
Saint_Paul[Saint_Paul.length] = createMarker(new GPoint(-93.18514200,44.92696300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("College Of St. Catherine Early Childhood Center",'Saint_Paul=' + Saint_Paul.length);
St_Paul[St_Paul.length] = createMarker(new GPoint(-93.18067200,44.91804300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Wholechild Inc",'St_Paul=' + St_Paul.length);
Winona[Winona.length] = createMarker(new GPoint(-91.67259200,44.05298700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Marys Primary School",'Winona=' + Winona.length);
Woodbury[Woodbury.length] = createMarker(new GPoint(-92.95638200,44.92349500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Woodbury Lutheran Preschool And Kindergarten",'Woodbury=' + Woodbury.length);
map.removeOverlays(Anoka);
map.removeOverlays(Apple_Valley);
map.removeOverlays(Bloomington);
map.removeOverlays(Burnsville);
map.removeOverlays(Chanhassen);
map.removeOverlays(Cottage_Grove);
map.removeOverlays(Duluth);
map.removeOverlays(Edina);
map.removeOverlays(Excelsior);
map.removeOverlays(Golden_Valley);
map.removeOverlays(Little_Canada);
map.removeOverlays(Minneapolis);
map.removeOverlays(North_Mankato);
map.removeOverlays(Oakdale);
map.removeOverlays(Roseville);
map.removeOverlays(Saint_Louis_Park);
map.removeOverlays(Saint_Paul);
map.removeOverlays(St_Paul);
map.removeOverlays(Winona);
map.removeOverlays(Woodbury);
setTimeout(function(){map.addOverlays(Anoka)},1000);
setTimeout(function(){map.addOverlays(Apple_Valley)},1000);
setTimeout(function(){map.addOverlays(Bloomington)},1000);
setTimeout(function(){map.addOverlays(Burnsville)},1000);
setTimeout(function(){map.addOverlays(Chanhassen)},1000);
setTimeout(function(){map.addOverlays(Cottage_Grove)},1000);
setTimeout(function(){map.addOverlays(Duluth)},1000);
setTimeout(function(){map.addOverlays(Edina)},1000);
setTimeout(function(){map.addOverlays(Excelsior)},1000);
setTimeout(function(){map.addOverlays(Golden_Valley)},1000);
setTimeout(function(){map.addOverlays(Little_Canada)},1000);
setTimeout(function(){map.addOverlays(Minneapolis)},1000);
setTimeout(function(){map.addOverlays(North_Mankato)},1000);
setTimeout(function(){map.addOverlays(Oakdale)},1000);
setTimeout(function(){map.addOverlays(Roseville)},1000);
setTimeout(function(){map.addOverlays(Saint_Louis_Park)},1000);
setTimeout(function(){map.addOverlays(Saint_Paul)},1000);
setTimeout(function(){map.addOverlays(St_Paul)},1000);
setTimeout(function(){map.addOverlays(Winona)},1000);
setTimeout(function(){map.addOverlays(Woodbury)},1000);
maxLng = -91.67259200;
maxLat = 46.80673900;
minLng = -94.05250800;
minLat = 44.05298700;
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(Anoka);
map.removeOverlays(Apple_Valley);
map.removeOverlays(Bloomington);
map.removeOverlays(Burnsville);
map.removeOverlays(Chanhassen);
map.removeOverlays(Cottage_Grove);
map.removeOverlays(Duluth);
map.removeOverlays(Edina);
map.removeOverlays(Excelsior);
map.removeOverlays(Golden_Valley);
map.removeOverlays(Little_Canada);
map.removeOverlays(Minneapolis);
map.removeOverlays(North_Mankato);
map.removeOverlays(Oakdale);
map.removeOverlays(Roseville);
map.removeOverlays(Saint_Louis_Park);
map.removeOverlays(Saint_Paul);
map.removeOverlays(St_Paul);
map.removeOverlays(Winona);
map.removeOverlays(Woodbury);
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(Anoka);map.removeOverlays(Anoka);
map.removeOverlays(Apple_Valley);
map.removeOverlays(Bloomington);
map.removeOverlays(Burnsville);
map.removeOverlays(Chanhassen);
map.removeOverlays(Cottage_Grove);
map.removeOverlays(Duluth);
map.removeOverlays(Edina);
map.removeOverlays(Excelsior);
map.removeOverlays(Golden_Valley);
map.removeOverlays(Little_Canada);
map.removeOverlays(Minneapolis);
map.removeOverlays(North_Mankato);
map.removeOverlays(Oakdale);
map.removeOverlays(Roseville);
map.removeOverlays(Saint_Louis_Park);
map.removeOverlays(Saint_Paul);
map.removeOverlays(St_Paul);
map.removeOverlays(Winona);
map.removeOverlays(Woodbury);
map.addOverlays(Anoka);
centerByArray(Anoka, false, false);
cntMarker += Anoka.length;
map.addOverlays(Apple_Valley);
centerByArray(Apple_Valley, false, false);
cntMarker += Apple_Valley.length;
map.addOverlays(Bloomington);
centerByArray(Bloomington, false, false);
cntMarker += Bloomington.length;
map.addOverlays(Burnsville);
centerByArray(Burnsville, false, false);
cntMarker += Burnsville.length;
map.addOverlays(Chanhassen);
centerByArray(Chanhassen, false, false);
cntMarker += Chanhassen.length;
map.addOverlays(Cottage_Grove);
centerByArray(Cottage_Grove, false, false);
cntMarker += Cottage_Grove.length;
map.addOverlays(Duluth);
centerByArray(Duluth, false, false);
cntMarker += Duluth.length;
map.addOverlays(Edina);
centerByArray(Edina, false, false);
cntMarker += Edina.length;
map.addOverlays(Excelsior);
centerByArray(Excelsior, false, false);
cntMarker += Excelsior.length;
map.addOverlays(Golden_Valley);
centerByArray(Golden_Valley, false, false);
cntMarker += Golden_Valley.length;
map.addOverlays(Little_Canada);
centerByArray(Little_Canada, false, false);
cntMarker += Little_Canada.length;
map.addOverlays(Minneapolis);
centerByArray(Minneapolis, false, false);
cntMarker += Minneapolis.length;
map.addOverlays(North_Mankato);
centerByArray(North_Mankato, false, false);
cntMarker += North_Mankato.length;
map.addOverlays(Oakdale);
centerByArray(Oakdale, false, false);
cntMarker += Oakdale.length;
map.addOverlays(Roseville);
centerByArray(Roseville, false, false);
cntMarker += Roseville.length;
map.addOverlays(Saint_Louis_Park);
centerByArray(Saint_Louis_Park, false, false);
cntMarker += Saint_Louis_Park.length;
map.addOverlays(Saint_Paul);
centerByArray(Saint_Paul, false, false);
cntMarker += Saint_Paul.length;
map.addOverlays(St_Paul);
centerByArray(St_Paul, false, false);
cntMarker += St_Paul.length;
map.addOverlays(Winona);
centerByArray(Winona, false, false);
cntMarker += Winona.length;
map.addOverlays(Woodbury);
centerByArray(Woodbury, false, false);
cntMarker += Woodbury.length;
centerByArray(Anoka,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////all');
//window.open('/map.php?type=2&schools=&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;
}