function addMarkers(){ mySelect = document.getElementById('selection'); Wakefield = [];Kingston = [];Narragansett = [];West_Kingston = [];Exeter = [];Westerly = [];North_Kingstown = [];mySelect.options[mySelect.options.length] = new Option("Exeter schools",'all=Exeter'); mySelect.options[mySelect.options.length] = new Option("Kingston schools",'all=Kingston'); mySelect.options[mySelect.options.length] = new Option("Narragansett schools",'all=Narragansett'); mySelect.options[mySelect.options.length] = new Option("North Kingstown schools",'all=North_Kingstown'); mySelect.options[mySelect.options.length] = new Option("Wakefield schools",'all=Wakefield'); mySelect.options[mySelect.options.length] = new Option("West Kingston schools",'all=West_Kingston'); mySelect.options[mySelect.options.length] = new Option("Westerly schools",'all=Westerly'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Wakefield[Wakefield.length] = createMarker(new GPoint(-71.50211200,41.43717800),"
A Place To Grow Inc.
12 High Street
Wakefield, RI 02879
Co-ed school, NS-PK
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("A Place To Grow Inc.",'Wakefield=' + Wakefield.length); Wakefield[Wakefield.length] = createMarker(new GPoint(-71.51807700,41.42989700),"
Cane Child Development Center
281 Post Road
Wakefield, RI 02879
Co-ed school, PK-K
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Cane Child Development Center",'Wakefield=' + Wakefield.length); Kingston[Kingston.length] = createMarker(new GPoint(-71.53001400,41.48173800),"
Child Development Center At Univ Of Rhode Island
10 Lower College Road
Kingston, RI 02881
Co-ed school, PK-K
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Child Development Center At Univ Of Rhode Island",'Kingston=' + Kingston.length); Kingston[Kingston.length] = createMarker(new GPoint(-71.54044800,41.48304900),"
First Step At Kingston
25 W Independence Way
Kingston, RI 02881
Co-ed school, NS-PK
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("First Step At Kingston",'Kingston=' + Kingston.length); Narragansett[Narragansett.length] = createMarker(new GPoint(-71.45898600,41.43114000),"
Growing Children Of Ri
1 Pier Market Place
Narragansett, RI 02882
Co-ed school, PK-KG
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Growing Children Of Ri",'Narragansett=' + Narragansett.length); Wakefield[Wakefield.length] = createMarker(new GPoint(-71.52639900,41.46293700),"
Growing Children Of Ri
1175 South Road
Wakefield, RI 02879
Co-ed school, PK-K
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Growing Children Of Ri",'Wakefield=' + Wakefield.length); West_Kingston[West_Kingston.length] = createMarker(new GPoint(-71.64146900,41.49994200),"
Meadowbrook Waldorf School
300 Kingstown Rd.
West Kingston, RI 02892
Co-ed school, PK-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Meadowbrook Waldorf School",'West_Kingston=' + West_Kingston.length); Exeter[Exeter.length] = createMarker(new GPoint(-71.70257500,41.55755200),"
Nuweetooun School
390 Summit Road
Exeter, RI 02822
Co-ed school, K-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Nuweetooun School",'Exeter=' + Exeter.length); Kingston[Kingston.length] = createMarker(new GPoint(-71.51669100,41.49606500),"
The Potter Hill School
537 Old North Road
Kingston, RI 02881
Co-ed school, PK-5
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("The Potter Hill School",'Kingston=' + Kingston.length); Exeter[Exeter.length] = createMarker(new GPoint(-71.52297400,41.54488500),"
Quest Montessori School
54 Exeter Road
Exeter, RI 02822
Co-ed school, 1-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Quest Montessori School",'Exeter=' + Exeter.length); Westerly[Westerly.length] = createMarker(new GPoint(-71.82871700,41.37326300),"
St. Pius X Elementary School
32 Elm Street
Westerly, RI 02891
Co-ed school, PK-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("St. Pius X Elementary School",'Westerly=' + Westerly.length); North_Kingstown[North_Kingstown.length] = createMarker(new GPoint(-71.46822700,41.54306700),"
South County Montessori School
1239 Tower Hill Road
North Kingstown, RI 02852
Co-ed school, PK-3
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("South County Montessori School",'North_Kingstown=' + North_Kingstown.length); North_Kingstown[North_Kingstown.length] = createMarker(new GPoint(-71.45030600,41.60644000),"
Sunshine Child Development Center
11 Iafrate Way
North Kingstown, RI 02852
Co-ed school, PK-K
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("Sunshine Child Development Center",'North_Kingstown=' + North_Kingstown.length); North_Kingstown[North_Kingstown.length] = createMarker(new GPoint(-71.47168300,41.61482500),"
West Bay Christian Academy (elementary)
475 School Street
North Kingstown, RI 02852
Co-ed school, K-8
[ View School Profile ]
",iconGr); mySelect.options[mySelect.options.length] = new Option("West Bay Christian Academy (elementary)",'North_Kingstown=' + North_Kingstown.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/////1/' + showArray); map.removeOverlays(Exeter); map.removeOverlays(Kingston); map.removeOverlays(Narragansett); map.removeOverlays(North_Kingstown); map.removeOverlays(Wakefield); map.removeOverlays(West_Kingston); map.removeOverlays(Westerly); 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(Wakefield);map.removeOverlays(Exeter); map.removeOverlays(Kingston); map.removeOverlays(Narragansett); map.removeOverlays(North_Kingstown); map.removeOverlays(Wakefield); map.removeOverlays(West_Kingston); map.removeOverlays(Westerly); map.addOverlays(Exeter); centerByArray(Exeter, false, false); cntMarker += Exeter.length; map.addOverlays(Kingston); centerByArray(Kingston, false, false); cntMarker += Kingston.length; map.addOverlays(Narragansett); centerByArray(Narragansett, false, false); cntMarker += Narragansett.length; map.addOverlays(North_Kingstown); centerByArray(North_Kingstown, false, false); cntMarker += North_Kingstown.length; map.addOverlays(Wakefield); centerByArray(Wakefield, false, false); cntMarker += Wakefield.length; map.addOverlays(West_Kingston); centerByArray(West_Kingston, false, false); cntMarker += West_Kingston.length; map.addOverlays(Westerly); centerByArray(Westerly, false, false); cntMarker += Westerly.length; centerByArray(Wakefield,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=1&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; }