function addMarkers(){ mySelect = document.getElementById('selection'); Portland = [];Bangor = [];Auburn = [];Lewiston = [];Fairfield = [];Presque_Isle = [];South_Portland = [];Calais = [];Wells = [];mySelect.options[mySelect.options.length] = new Option("Auburn Schools",'all=Auburn'); mySelect.options[mySelect.options.length] = new Option("Bangor Schools",'all=Bangor'); mySelect.options[mySelect.options.length] = new Option("Calais Schools",'all=Calais'); mySelect.options[mySelect.options.length] = new Option("Fairfield Schools",'all=Fairfield'); mySelect.options[mySelect.options.length] = new Option("Lewiston Schools",'all=Lewiston'); mySelect.options[mySelect.options.length] = new Option("Portland Schools",'all=Portland'); mySelect.options[mySelect.options.length] = new Option("Presque Isle Schools",'all=Presque_Isle'); mySelect.options[mySelect.options.length] = new Option("South Portland Schools",'all=South_Portland'); mySelect.options[mySelect.options.length] = new Option("Wells Schools",'all=Wells'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); var tmpLatLng=0; var tmpLen=0; tmpLatLng=new GLatLng(43.68768699999999682,-70.2720149999999961); tmpLen=Portland.length; Portland[tmpLen] = createMarker(tmpLatLng,"
Andover College
901 Washington Ave
Portland, ME 04103

[ View School Profile ]
",iconRd); Portland[tmpLen].point = tmpLatLng; mySelect.options[mySelect.options.length] = new Option("Andover College",'Portland=' + Portland.length); tmpLatLng=new GLatLng(44.78482999999999947,-68.7797500000000070); tmpLen=Bangor.length; Bangor[tmpLen] = createMarker(tmpLatLng,"
Beal College
99 Farm Road
Bangor, ME 04401

[ View School Profile ]
",iconRd); Bangor[tmpLen].point = tmpLatLng; mySelect.options[mySelect.options.length] = new Option("Beal College",'Bangor=' + Bangor.length); tmpLatLng=new GLatLng(44.12835900000000322,-70.2283719999999931); tmpLen=Auburn.length; Auburn[tmpLen] = createMarker(tmpLatLng,"
Central Maine Community College
1250 Turner St
Auburn, ME 04210

[ View School Profile ]
",iconGr); Auburn[tmpLen].point = tmpLatLng; mySelect.options[mySelect.options.length] = new Option("Central Maine Community College",'Auburn=' + Auburn.length); tmpLatLng=new GLatLng(44.10032900000000211,-70.2177760000000006); tmpLen=Lewiston.length; Lewiston[tmpLen] = createMarker(tmpLatLng,"
Central Maine Medical Center College Of Nursing And Health Professions
70 Middle Street
Lewiston, ME 04240

[ View School Profile ]
",iconRd); Lewiston[tmpLen].point = tmpLatLng; mySelect.options[mySelect.options.length] = new Option("Central Maine Medical Center College Of Nursing And Health Professions",'Lewiston=' + Lewiston.length); tmpLatLng=new GLatLng(44.83396100000000217,-68.7422090000000025); tmpLen=Bangor.length; Bangor[tmpLen] = createMarker(tmpLatLng,"
Eastern Maine Community College
354 Hogan Rd
Bangor, ME 04401

[ View School Profile ]
",iconGr); Bangor[tmpLen].point = tmpLatLng; mySelect.options[mySelect.options.length] = new Option("Eastern Maine Community College",'Bangor=' + Bangor.length); tmpLatLng=new GLatLng(44.59366599999999891,-69.6136699999999990); tmpLen=Fairfield.length; Fairfield[tmpLen] = createMarker(tmpLatLng,"
Kennebec Valley Community College
92 Western Ave
Fairfield, ME 04937

[ View School Profile ]
",iconGr); Fairfield[tmpLen].point = tmpLatLng; mySelect.options[mySelect.options.length] = new Option("Kennebec Valley Community College",'Fairfield=' + Fairfield.length); tmpLatLng=new GLatLng(44.04382499999999822,-70.2683420000000040); tmpLen=Auburn.length; Auburn[tmpLen] = createMarker(tmpLatLng,"
Mid-state College
88 E Hardscrabble Rd
Auburn, ME 04210

[ View School Profile ]
",iconRd); Auburn[tmpLen].point = tmpLatLng; mySelect.options[mySelect.options.length] = new Option("Mid-state College",'Auburn=' + Auburn.length); tmpLatLng=new GLatLng(44.82580000000000097,-68.7915660000000031); tmpLen=Bangor.length; Bangor[tmpLen] = createMarker(tmpLatLng,"
New England School Of Communications
1 College Circle
Bangor, ME 04401

[ View School Profile ]
",iconRd); Bangor[tmpLen].point = tmpLatLng; mySelect.options[mySelect.options.length] = new Option("New England School Of Communications",'Bangor=' + Bangor.length); tmpLatLng=new GLatLng(46.69611400000000145,-68.0335220000000049); tmpLen=Presque_Isle.length; Presque_Isle[tmpLen] = createMarker(tmpLatLng,"
Northern Maine Community College
33 Edgemont Dr
Presque Isle, ME 04769

[ View School Profile ]
",iconGr); Presque_Isle[tmpLen].point = tmpLatLng; mySelect.options[mySelect.options.length] = new Option("Northern Maine Community College",'Presque_Isle=' + Presque_Isle.length); tmpLatLng=new GLatLng(43.65030699999999797,-70.2276870000000030); tmpLen=South_Portland.length; South_Portland[tmpLen] = createMarker(tmpLatLng,"
Southern Maine Community College
2 Fort Road
South Portland, ME 04106

[ View School Profile ]
",iconGr); South_Portland[tmpLen].point = tmpLatLng; mySelect.options[mySelect.options.length] = new Option("Southern Maine Community College",'South_Portland=' + South_Portland.length); tmpLatLng=new GLatLng(45.19069999999999964,-67.2836000000000069); tmpLen=Calais.length; Calais[tmpLen] = createMarker(tmpLatLng,"
Wasington County Community College
One College Drive
Calais, ME 04619

[ View School Profile ]
",iconGr); Calais[tmpLen].point = tmpLatLng; mySelect.options[mySelect.options.length] = new Option("Wasington County Community College",'Calais=' + Calais.length); tmpLatLng=new GLatLng(43.31022800000000216,-70.5964010000000001); tmpLen=Wells.length; Wells[tmpLen] = createMarker(tmpLatLng,"
York County Community College
112 College Drive
Wells, ME 04090

[ View School Profile ]
",iconGr); Wells[tmpLen].point = tmpLatLng; mySelect.options[mySelect.options.length] = new Option("York County Community College",'Wells=' + Wells.length); map.removeOverlays(Auburn); map.removeOverlays(Bangor); map.removeOverlays(Calais); map.removeOverlays(Fairfield); map.removeOverlays(Lewiston); map.removeOverlays(Portland); map.removeOverlays(Presque_Isle); map.removeOverlays(South_Portland); map.removeOverlays(Wells); setTimeout(function(){map.addOverlays(Auburn)},1000); setTimeout(function(){map.addOverlays(Bangor)},1000); setTimeout(function(){map.addOverlays(Calais)},1000); setTimeout(function(){map.addOverlays(Fairfield)},1000); setTimeout(function(){map.addOverlays(Lewiston)},1000); setTimeout(function(){map.addOverlays(Portland)},1000); setTimeout(function(){map.addOverlays(Presque_Isle)},1000); setTimeout(function(){map.addOverlays(South_Portland)},1000); setTimeout(function(){map.addOverlays(Wells)},1000); getPoly("","state","","ME");} // 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(Auburn); map.removeOverlays(Bangor); map.removeOverlays(Calais); map.removeOverlays(Fairfield); map.removeOverlays(Lewiston); map.removeOverlays(Portland); map.removeOverlays(Presque_Isle); map.removeOverlays(South_Portland); map.removeOverlays(Wells); 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(Portland);map.removeOverlays(Auburn); map.removeOverlays(Bangor); map.removeOverlays(Calais); map.removeOverlays(Fairfield); map.removeOverlays(Lewiston); map.removeOverlays(Portland); map.removeOverlays(Presque_Isle); map.removeOverlays(South_Portland); map.removeOverlays(Wells); map.addOverlays(Auburn); centerByArray(Auburn, false, false); cntMarker += Auburn.length; map.addOverlays(Bangor); centerByArray(Bangor, false, false); cntMarker += Bangor.length; map.addOverlays(Calais); centerByArray(Calais, false, false); cntMarker += Calais.length; map.addOverlays(Fairfield); centerByArray(Fairfield, false, false); cntMarker += Fairfield.length; map.addOverlays(Lewiston); centerByArray(Lewiston, false, false); cntMarker += Lewiston.length; map.addOverlays(Portland); centerByArray(Portland, false, false); cntMarker += Portland.length; map.addOverlays(Presque_Isle); centerByArray(Presque_Isle, false, false); cntMarker += Presque_Isle.length; map.addOverlays(South_Portland); centerByArray(South_Portland, false, false); cntMarker += South_Portland.length; map.addOverlays(Wells); centerByArray(Wells, false, false); cntMarker += Wells.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; }