function addMarkers() { mySelect = document.getElementById('selection'); Moncks_Corner = [];Goose_Creek = [];Huger = [];Ladson = [];Cross = [];Hanahan = [];St_Stephen = [];Ridgeville = [];Summerville = [];mySelect.options[mySelect.options.length] = new Option("Cross schools",'all=Cross'); mySelect.options[mySelect.options.length] = new Option("Goose Creek schools",'all=Goose_Creek'); mySelect.options[mySelect.options.length] = new Option("Hanahan schools",'all=Hanahan'); mySelect.options[mySelect.options.length] = new Option("Huger schools",'all=Huger'); mySelect.options[mySelect.options.length] = new Option("Ladson schools",'all=Ladson'); mySelect.options[mySelect.options.length] = new Option("Moncks Corner schools",'all=Moncks_Corner'); mySelect.options[mySelect.options.length] = new Option("Ridgeville schools",'all=Ridgeville'); mySelect.options[mySelect.options.length] = new Option("St Stephen schools",'all=St_Stephen'); mySelect.options[mySelect.options.length] = new Option("Summerville schools",'all=Summerville'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); Moncks_Corner[Moncks_Corner.length] = createMarker(new GPoint(-80.05429077,33.20594788),"
",iconRd); mySelect.options[mySelect.options.length] = new Option("Berkeley Elementary School",'Moncks_Corner=' + Moncks_Corner.length); Moncks_Corner[Moncks_Corner.length] = createMarker(new GPoint(-80.02739716,33.20096970),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Berkeley High School",'Moncks_Corner=' + Moncks_Corner.length); Moncks_Corner[Moncks_Corner.length] = createMarker(new GPoint(-79.99664307,33.20051575),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Berkeley Middle School",'Moncks_Corner=' + Moncks_Corner.length); Moncks_Corner[Moncks_Corner.length] = createMarker(new GPoint(-79.89726257,33.26709366),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Bonner Elementary School",'Moncks_Corner=' + Moncks_Corner.length); Goose_Creek[Goose_Creek.length] = createMarker(new GPoint(-80.02895355,33.02434921),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Boulder Bluff Elementary School",'Goose_Creek=' + Goose_Creek.length); Huger[Huger.length] = createMarker(new GPoint(-79.85047913,33.01530838),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Cainhoy Elementary Middle School",'Huger=' + Huger.length); Ladson[Ladson.length] = createMarker(new GPoint(-80.09127808,33.01526642),"",iconRd); mySelect.options[mySelect.options.length] = new Option("College Park Elementary School",'Ladson=' + Ladson.length); Ladson[Ladson.length] = createMarker(new GPoint(-80.08876038,33.01836777),"",iconBl); mySelect.options[mySelect.options.length] = new Option("College Park Middle School",'Ladson=' + Ladson.length); Cross[Cross.length] = createMarker(new GPoint(-80.16666412,33.30036545),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Cross Elementary School",'Cross=' + Cross.length); Cross[Cross.length] = createMarker(new GPoint(-80.16362000,33.35206985),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Cross High School",'Cross=' + Cross.length); Goose_Creek[Goose_Creek.length] = createMarker(new GPoint(-80.07450867,33.03898239),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Devon Forest Elementary School",'Goose_Creek=' + Goose_Creek.length); Goose_Creek[Goose_Creek.length] = createMarker(new GPoint(-80.01730347,32.97211075),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Goose Creek High School",'Goose_Creek=' + Goose_Creek.length); Goose_Creek[Goose_Creek.length] = createMarker(new GPoint(-80.02760315,32.99649811),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Goose Creek Primary",'Goose_Creek=' + Goose_Creek.length); Hanahan[Hanahan.length] = createMarker(new GPoint(-80.02998352,32.93658447),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Hanahan Elementary School",'Hanahan=' + Hanahan.length); Hanahan[Hanahan.length] = createMarker(new GPoint(-80.04588100,32.96497200),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Hanahan High School",'Hanahan=' + Hanahan.length); Hanahan[Hanahan.length] = createMarker(new GPoint(-79.99347687,32.90804672),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Hanahan Middle School",'Hanahan=' + Hanahan.length); Goose_Creek[Goose_Creek.length] = createMarker(new GPoint(-80.02901459,32.97971725),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Howe Hall Elememtary School",'Goose_Creek=' + Goose_Creek.length); St_Stephen[St_Stephen.length] = createMarker(new GPoint(-79.95810699,33.35953903),"",iconRd); mySelect.options[mySelect.options.length] = new Option("J K Gourdin Elementary School",'St_Stephen=' + St_Stephen.length); Ridgeville[Ridgeville.length] = createMarker(new GPoint(-80.31511688,33.09542847),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Macdougall Youth Correctional Center",'Ridgeville=' + Ridgeville.length); Moncks_Corner[Moncks_Corner.length] = createMarker(new GPoint(-79.89640045,33.26630783),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Macedonia Middle School",'Moncks_Corner=' + Moncks_Corner.length); Goose_Creek[Goose_Creek.length] = createMarker(new GPoint(-79.97716522,32.96785355),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Marrington Elementary School",'Goose_Creek=' + Goose_Creek.length); Goose_Creek[Goose_Creek.length] = createMarker(new GPoint(-79.97716522,32.96791840),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Marrington Middle School",'Goose_Creek=' + Goose_Creek.length); Goose_Creek[Goose_Creek.length] = createMarker(new GPoint(-79.98644257,32.97504044),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Menriv Park Elementary School",'Goose_Creek=' + Goose_Creek.length); Summerville[Summerville.length] = createMarker(new GPoint(-80.10937500,33.03429794),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Sangaree Intermediate",'Summerville=' + Summerville.length); Ladson[Ladson.length] = createMarker(new GPoint(-80.10751300,33.02673400),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Sangaree Middle School",'Ladson=' + Ladson.length); Goose_Creek[Goose_Creek.length] = createMarker(new GPoint(-80.01424408,32.97570801),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Sedgefield Intermediate",'Goose_Creek=' + Goose_Creek.length); Goose_Creek[Goose_Creek.length] = createMarker(new GPoint(-80.03278351,32.98069000),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Sedgefield Middle School",'Goose_Creek=' + Goose_Creek.length); St_Stephen[St_Stephen.length] = createMarker(new GPoint(-79.91480255,33.38679886),"",iconRd); mySelect.options[mySelect.options.length] = new Option("St Stephen Elementary School",'St_Stephen=' + St_Stephen.length); St_Stephen[St_Stephen.length] = createMarker(new GPoint(-79.93319702,33.40628052),"",iconBl); mySelect.options[mySelect.options.length] = new Option("St Stephen Middle School",'St_Stephen=' + St_Stephen.length); St_Stephen[St_Stephen.length] = createMarker(new GPoint(-79.91779327,33.32717133),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Timberland High School",'St_Stephen=' + St_Stephen.length); Goose_Creek[Goose_Creek.length] = createMarker(new GPoint(-80.04701233,33.00317764),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Westview Intermediate",'Goose_Creek=' + Goose_Creek.length); Goose_Creek[Goose_Creek.length] = createMarker(new GPoint(-80.04690552,33.00291443),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Westview Middle School",'Goose_Creek=' + Goose_Creek.length); Goose_Creek[Goose_Creek.length] = createMarker(new GPoint(-80.04664612,33.00333786),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Westview Primary",'Goose_Creek=' + Goose_Creek.length); Moncks_Corner[Moncks_Corner.length] = createMarker(new GPoint(-80.04993439,33.15197372),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Whitesville Elementary School",'Moncks_Corner=' + Moncks_Corner.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,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) { 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(Cross); map.removeOverlays(Goose_Creek); map.removeOverlays(Hanahan); map.removeOverlays(Huger); map.removeOverlays(Ladson); map.removeOverlays(Moncks_Corner); map.removeOverlays(Ridgeville); map.removeOverlays(St_Stephen); map.removeOverlays(Summerville); 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(Moncks_Corner);map.removeOverlays(Cross); map.removeOverlays(Goose_Creek); map.removeOverlays(Hanahan); map.removeOverlays(Huger); map.removeOverlays(Ladson); map.removeOverlays(Moncks_Corner); map.removeOverlays(Ridgeville); map.removeOverlays(St_Stephen); map.removeOverlays(Summerville); map.addOverlays(Cross); centerByArray(Cross, false, false); cntMarker += Cross.length; map.addOverlays(Goose_Creek); centerByArray(Goose_Creek, false, false); cntMarker += Goose_Creek.length; map.addOverlays(Hanahan); centerByArray(Hanahan, false, false); cntMarker += Hanahan.length; map.addOverlays(Huger); centerByArray(Huger, false, false); cntMarker += Huger.length; map.addOverlays(Ladson); centerByArray(Ladson, false, false); cntMarker += Ladson.length; map.addOverlays(Moncks_Corner); centerByArray(Moncks_Corner, false, false); cntMarker += Moncks_Corner.length; map.addOverlays(Ridgeville); centerByArray(Ridgeville, false, false); cntMarker += Ridgeville.length; map.addOverlays(St_Stephen); centerByArray(St_Stephen, false, false); cntMarker += St_Stephen.length; map.addOverlays(Summerville); centerByArray(Summerville, false, false); cntMarker += Summerville.length; centerByArray(Moncks_Corner,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'); } }