function addMarkers(){
mySelect = document.getElementById('selection');
Woonsocket = [];Pawtucket = [];Providence = [];Cranston = [];North_Providence = [];Smithfield = [];East_Providence = [];Riverside = [];Lincoln = [];Johnston = [];mySelect.options[mySelect.options.length] = new Option("Cranston schools",'all=Cranston');
mySelect.options[mySelect.options.length] = new Option("East Providence schools",'all=East_Providence');
mySelect.options[mySelect.options.length] = new Option("Johnston schools",'all=Johnston');
mySelect.options[mySelect.options.length] = new Option("Lincoln schools",'all=Lincoln');
mySelect.options[mySelect.options.length] = new Option("North Providence schools",'all=North_Providence');
mySelect.options[mySelect.options.length] = new Option("Pawtucket schools",'all=Pawtucket');
mySelect.options[mySelect.options.length] = new Option("Providence schools",'all=Providence');
mySelect.options[mySelect.options.length] = new Option("Riverside schools",'all=Riverside');
mySelect.options[mySelect.options.length] = new Option("Smithfield schools",'all=Smithfield');
mySelect.options[mySelect.options.length] = new Option("Woonsocket schools",'all=Woonsocket');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Woonsocket[Woonsocket.length] = createMarker(new GPoint(-71.52097800,41.98663700),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Arc Of Northern R I",'Woonsocket=' + Woonsocket.length);
Pawtucket[Pawtucket.length] = createMarker(new GPoint(-71.41354700,41.86465600),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Bishop Francis P Keough High School",'Pawtucket=' + Pawtucket.length);
Providence[Providence.length] = createMarker(new GPoint(-71.44210800,41.81638500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Center For Individualized Training & Educ",'Providence=' + Providence.length);
Cranston[Cranston.length] = createMarker(new GPoint(-71.42223900,41.79071500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Elmwood Community School",'Cranston=' + Cranston.length);
Providence[Providence.length] = createMarker(new GPoint(-71.39699400,41.82172900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("French-american School Of Ri",'Providence=' + Providence.length);
North_Providence[North_Providence.length] = createMarker(new GPoint(-71.46484000,41.84965900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("George N Hunt Campus School",'North_Providence=' + North_Providence.length);
Providence[Providence.length] = createMarker(new GPoint(-71.39994300,41.84053700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Groden Center Inc",'Providence=' + Providence.length);
Woonsocket[Woonsocket.length] = createMarker(new GPoint(-71.48467800,42.00342500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Hillside Alternative Program",'Woonsocket=' + Woonsocket.length);
Providence[Providence.length] = createMarker(new GPoint(-71.44532600,41.84162400),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("La Salle Academy",'Providence=' + Providence.length);
Providence[Providence.length] = createMarker(new GPoint(-71.38382400,41.83255700),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("Lincoln School",'Providence=' + Providence.length);
Smithfield[Smithfield.length] = createMarker(new GPoint(-71.51646500,41.91316000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Masters Regional Academy",'Smithfield=' + Smithfield.length);
East_Providence[East_Providence.length] = createMarker(new GPoint(-71.35589500,41.81580100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Meeting Street School",'East_Providence=' + East_Providence.length);
Providence[Providence.length] = createMarker(new GPoint(-71.39741800,41.83250700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Moses Brown School",'Providence=' + Providence.length);
Woonsocket[Woonsocket.length] = createMarker(new GPoint(-71.50097900,41.99465200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Mount St Charles Academy",'Woonsocket=' + Woonsocket.length);
Providence[Providence.length] = createMarker(new GPoint(-71.39450000,41.83730000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Nafi Alternatives",'Providence=' + Providence.length);
Providence[Providence.length] = createMarker(new GPoint(-71.39927000,41.84084700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Providence Center School",'Providence=' + Providence.length);
East_Providence[East_Providence.length] = createMarker(new GPoint(-71.35586000,41.81611100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Providence Country Day School",'East_Providence=' + East_Providence.length);
Riverside[Riverside.length] = createMarker(new GPoint(-71.36515700,41.79098200),"",iconRd);
mySelect.options[mySelect.options.length] = new Option("St. Mary Academy-bay View",'Riverside=' + Riverside.length);
Pawtucket[Pawtucket.length] = createMarker(new GPoint(-71.37658400,41.87696100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Raphael Academy",'Pawtucket=' + Pawtucket.length);
Providence[Providence.length] = createMarker(new GPoint(-71.38518500,41.83471100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("School One",'Providence=' + Providence.length);
Lincoln[Lincoln.length] = createMarker(new GPoint(-71.41590500,41.91290700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Spurwink School Ii",'Lincoln=' + Lincoln.length);
Providence[Providence.length] = createMarker(new GPoint(-71.41257100,41.81349900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Tavares Education Center",'Providence=' + Providence.length);
Pawtucket[Pawtucket.length] = createMarker(new GPoint(-71.39140600,41.88169600),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Tides School",'Pawtucket=' + Pawtucket.length);
Johnston[Johnston.length] = createMarker(new GPoint(-71.51216700,41.82748900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Trinity Christian Academy",'Johnston=' + Johnston.length);
Cranston[Cranston.length] = createMarker(new GPoint(-71.43697900,41.77587100),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Valley Community School",'Cranston=' + Cranston.length);
Pawtucket[Pawtucket.length] = createMarker(new GPoint(-71.38221600,41.88018700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Valley Community School And Valley Day Program",'Pawtucket=' + Pawtucket.length);
Woonsocket[Woonsocket.length] = createMarker(new GPoint(-71.51200900,42.01409000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Viola M. Berard School",'Woonsocket=' + Woonsocket.length);
Providence[Providence.length] = createMarker(new GPoint(-71.43512600,41.85691800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Vocational Resources",'Providence=' + Providence.length);
Providence[Providence.length] = createMarker(new GPoint(-71.39817100,41.82910700),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Wheeler School",'Providence=' + Providence.length);
Providence[Providence.length] = createMarker(new GPoint(-71.39817200,41.82911000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Wheeler School",'Providence=' + Providence.length);
} // 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/////2/' + showArray);
map.removeOverlays(Cranston);
map.removeOverlays(East_Providence);
map.removeOverlays(Johnston);
map.removeOverlays(Lincoln);
map.removeOverlays(North_Providence);
map.removeOverlays(Pawtucket);
map.removeOverlays(Providence);
map.removeOverlays(Riverside);
map.removeOverlays(Smithfield);
map.removeOverlays(Woonsocket);
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(Woonsocket);map.removeOverlays(Cranston);
map.removeOverlays(East_Providence);
map.removeOverlays(Johnston);
map.removeOverlays(Lincoln);
map.removeOverlays(North_Providence);
map.removeOverlays(Pawtucket);
map.removeOverlays(Providence);
map.removeOverlays(Riverside);
map.removeOverlays(Smithfield);
map.removeOverlays(Woonsocket);
map.addOverlays(Cranston);
centerByArray(Cranston, false, false);
cntMarker += Cranston.length;
map.addOverlays(East_Providence);
centerByArray(East_Providence, false, false);
cntMarker += East_Providence.length;
map.addOverlays(Johnston);
centerByArray(Johnston, false, false);
cntMarker += Johnston.length;
map.addOverlays(Lincoln);
centerByArray(Lincoln, false, false);
cntMarker += Lincoln.length;
map.addOverlays(North_Providence);
centerByArray(North_Providence, false, false);
cntMarker += North_Providence.length;
map.addOverlays(Pawtucket);
centerByArray(Pawtucket, false, false);
cntMarker += Pawtucket.length;
map.addOverlays(Providence);
centerByArray(Providence, false, false);
cntMarker += Providence.length;
map.addOverlays(Riverside);
centerByArray(Riverside, false, false);
cntMarker += Riverside.length;
map.addOverlays(Smithfield);
centerByArray(Smithfield, false, false);
cntMarker += Smithfield.length;
map.addOverlays(Woonsocket);
centerByArray(Woonsocket, false, false);
cntMarker += Woonsocket.length;
centerByArray(Woonsocket,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=1&schools=&school_level=2&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;
}