function addMarkers(){
mySelect = document.getElementById('selection');
Glendive = [];Kalispell = [];Miles_City = [];Billings = [];Great_Falls = [];Butte = [];Helena = [];mySelect.options[mySelect.options.length] = new Option("Billings Schools",'all=Billings');
mySelect.options[mySelect.options.length] = new Option("Butte Schools",'all=Butte');
mySelect.options[mySelect.options.length] = new Option("Glendive Schools",'all=Glendive');
mySelect.options[mySelect.options.length] = new Option("Great Falls Schools",'all=Great_Falls');
mySelect.options[mySelect.options.length] = new Option("Helena Schools",'all=Helena');
mySelect.options[mySelect.options.length] = new Option("Kalispell Schools",'all=Kalispell');
mySelect.options[mySelect.options.length] = new Option("Miles City Schools",'all=Miles_City');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
var tmpLatLng=0;
var tmpLen=0;
tmpLatLng=new GLatLng(47.08462500000000261,-104.722780999999997);
tmpLen=Glendive.length;
Glendive[tmpLen] = createMarker(tmpLatLng,"
",iconGr);
Glendive[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("Dawson Community College",'Glendive=' + Glendive.length);
tmpLatLng=new GLatLng(48.22602400000000244,-114.325867999999999);
tmpLen=Kalispell.length;
Kalispell[tmpLen] = createMarker(tmpLatLng,"",iconGr);
Kalispell[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("Flathead Valley Community College",'Kalispell=' + Kalispell.length);
tmpLatLng=new GLatLng(46.40454700000000087,-105.826593000000002);
tmpLen=Miles_City.length;
Miles_City[tmpLen] = createMarker(tmpLatLng,"",iconGr);
Miles_City[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("Miles Community College",'Miles_City=' + Miles_City.length);
tmpLatLng=new GLatLng(45.76967499999999944,-108.612542000000004);
tmpLen=Billings.length;
Billings[tmpLen] = createMarker(tmpLatLng,"",iconGr);
Billings[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("Montana State Univ Billings College Of Technology",'Billings=' + Billings.length);
tmpLatLng=new GLatLng(47.48763100000000037,-111.271833999999998);
tmpLen=Great_Falls.length;
Great_Falls[tmpLen] = createMarker(tmpLatLng,"",iconGr);
Great_Falls[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("Montana State University-college Of Technology-gre",'Great_Falls=' + Great_Falls.length);
tmpLatLng=new GLatLng(45.92211400000000054,-112.508979999999993);
tmpLen=Butte.length;
Butte[tmpLen] = createMarker(tmpLatLng,"",iconGr);
Butte[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("Montana Tech-college Of Technology",'Butte=' + Butte.length);
tmpLatLng=new GLatLng(46.59448700000000087,-112.016622999999995);
tmpLen=Helena.length;
Helena[tmpLen] = createMarker(tmpLatLng,"",iconGr);
Helena[tmpLen].point = tmpLatLng;
mySelect.options[mySelect.options.length] = new Option("University Of Montana- Helena College Of Technology",'Helena=' + Helena.length);
map.removeOverlays(Billings);
map.removeOverlays(Butte);
map.removeOverlays(Glendive);
map.removeOverlays(Great_Falls);
map.removeOverlays(Helena);
map.removeOverlays(Kalispell);
map.removeOverlays(Miles_City);
setTimeout(function(){map.addOverlays(Billings)},1000);
setTimeout(function(){map.addOverlays(Butte)},1000);
setTimeout(function(){map.addOverlays(Glendive)},1000);
setTimeout(function(){map.addOverlays(Great_Falls)},1000);
setTimeout(function(){map.addOverlays(Helena)},1000);
setTimeout(function(){map.addOverlays(Kalispell)},1000);
setTimeout(function(){map.addOverlays(Miles_City)},1000);
getPoly("","state","","MT");}
// End addStateMarkers JavaScript Function
//open all when map is defined
function openAll() {
if (map) {
selectChange("all");
} else {
setTimeout("openAll()",200);
}
}
// 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].point.x;
var markLat = myArray[i].point.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].point.x;
maxLat = myArray[0].point.y;
minLng = myArray[0].point.x;
minLat = myArray[0].point.y;
}
// Recenter map based on global max/mins
function reCenterMap(){
//alert('#' + minLat + '#' + minLng + '#' + maxLat + '#' + maxLng);
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,10);
/*
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) {
if (selection.options) {
var _openNewWindow=true;
var myVal = selection.options[selection.selectedIndex].value;
} else {
var _openNewWindow=false;
var myVal=selection;
}
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('schools-by-distance') == -1)
window.open(location.href + '/map/all');
else
window.open('/search////all');
map.removeOverlays(Billings);
map.removeOverlays(Butte);
map.removeOverlays(Glendive);
map.removeOverlays(Great_Falls);
map.removeOverlays(Helena);
map.removeOverlays(Kalispell);
map.removeOverlays(Miles_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(Glendive);map.removeOverlays(Billings);
map.removeOverlays(Butte);
map.removeOverlays(Glendive);
map.removeOverlays(Great_Falls);
map.removeOverlays(Helena);
map.removeOverlays(Kalispell);
map.removeOverlays(Miles_City);
map.addOverlays(Billings);
centerByArray(Billings, false, false);
cntMarker += Billings.length;
map.addOverlays(Butte);
centerByArray(Butte, false, false);
cntMarker += Butte.length;
map.addOverlays(Glendive);
centerByArray(Glendive, false, false);
cntMarker += Glendive.length;
map.addOverlays(Great_Falls);
centerByArray(Great_Falls, false, false);
cntMarker += Great_Falls.length;
map.addOverlays(Helena);
centerByArray(Helena, false, false);
cntMarker += Helena.length;
map.addOverlays(Kalispell);
centerByArray(Kalispell, false, false);
cntMarker += Kalispell.length;
map.addOverlays(Miles_City);
centerByArray(Miles_City, false, false);
cntMarker += Miles_City.length;
reCenterMap();
//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');
}
}
function createMarker(point, label, icon){
var marker = new GMarker(point, icon);
var html = label;
GEvent.addListener(marker, "click", function() { marker.openInfoWindowHtml(html); });
return marker;
}