function addMarkers(){
mySelect = document.getElementById('selection');
Conway = [];Myrtle_Beach = [];Galivants_Ferry = [];Loris = [];Longs = [];Surfside_Beach = [];North_Myrtle_Beach = [];Garden_City = [];mySelect.options[mySelect.options.length] = new Option("Conway schools",'all=Conway');
mySelect.options[mySelect.options.length] = new Option("Galivants Ferry schools",'all=Galivants_Ferry');
mySelect.options[mySelect.options.length] = new Option("Garden City schools",'all=Garden_City');
mySelect.options[mySelect.options.length] = new Option("Longs schools",'all=Longs');
mySelect.options[mySelect.options.length] = new Option("Loris schools",'all=Loris');
mySelect.options[mySelect.options.length] = new Option("Myrtle Beach schools",'all=Myrtle_Beach');
mySelect.options[mySelect.options.length] = new Option("North Myrtle Beach schools",'all=North_Myrtle_Beach');
mySelect.options[mySelect.options.length] = new Option("Surfside Beach schools",'all=Surfside_Beach');
mySelect.options[mySelect.options.length] = new Option("---------------------------",'');
Conway[Conway.length] = createMarker(new GPoint(-79.00325600,33.85687700),"
",iconGr);
mySelect.options[mySelect.options.length] = new Option("A Touch Of Christ Christian School",'Conway=' + Conway.length);
Myrtle_Beach[Myrtle_Beach.length] = createMarker(new GPoint(-78.89510000,33.69990000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Chabad Academy",'Myrtle_Beach=' + Myrtle_Beach.length);
Myrtle_Beach[Myrtle_Beach.length] = createMarker(new GPoint(-78.93495200,33.71167000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Christian Academy",'Myrtle_Beach=' + Myrtle_Beach.length);
Galivants_Ferry[Galivants_Ferry.length] = createMarker(new GPoint(-79.16901600,34.07506800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Christian Fellowship Academy",'Galivants_Ferry=' + Galivants_Ferry.length);
Conway[Conway.length] = createMarker(new GPoint(-79.05063400,33.83460500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Conway Christian School",'Conway=' + Conway.length);
Loris[Loris.length] = createMarker(new GPoint(-78.88912200,34.05340200),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("East Carolina Academy",'Loris=' + Loris.length);
Longs[Longs.length] = createMarker(new GPoint(-78.76682900,33.86001000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Faith Christian Academy",'Longs=' + Longs.length);
Surfside_Beach[Surfside_Beach.length] = createMarker(new GPoint(-78.96747600,33.62248000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("First Baptist Weeschool",'Surfside_Beach=' + Surfside_Beach.length);
Loris[Loris.length] = createMarker(new GPoint(-78.89650000,34.04480000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Grace Christian School",'Loris=' + Loris.length);
Surfside_Beach[Surfside_Beach.length] = createMarker(new GPoint(-78.99630400,33.61785800),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Learning Tree (the)",'Surfside_Beach=' + Surfside_Beach.length);
Myrtle_Beach[Myrtle_Beach.length] = createMarker(new GPoint(-78.88690000,33.68880000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Life Christian Academy",'Myrtle_Beach=' + Myrtle_Beach.length);
North_Myrtle_Beach[North_Myrtle_Beach.length] = createMarker(new GPoint(-78.66775500,33.83039300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("The Lords Children",'North_Myrtle_Beach=' + North_Myrtle_Beach.length);
Longs[Longs.length] = createMarker(new GPoint(-78.73835900,33.85932000),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("North Myrtle Beach Christian School",'Longs=' + Longs.length);
Myrtle_Beach[Myrtle_Beach.length] = createMarker(new GPoint(-78.74715700,33.79633300),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("Risen Christ Lutheran School",'Myrtle_Beach=' + Myrtle_Beach.length);
Myrtle_Beach[Myrtle_Beach.length] = createMarker(new GPoint(-78.85809900,33.71419900),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Andrews Catholic School",'Myrtle_Beach=' + Myrtle_Beach.length);
Garden_City[Garden_City.length] = createMarker(new GPoint(-79.00383900,33.58851500),"",iconGr);
mySelect.options[mySelect.options.length] = new Option("St. Michael Catholic School",'Garden_City=' + Garden_City.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/////3/' + showArray);
map.removeOverlays(Conway);
map.removeOverlays(Galivants_Ferry);
map.removeOverlays(Garden_City);
map.removeOverlays(Longs);
map.removeOverlays(Loris);
map.removeOverlays(Myrtle_Beach);
map.removeOverlays(North_Myrtle_Beach);
map.removeOverlays(Surfside_Beach);
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(Conway);map.removeOverlays(Conway);
map.removeOverlays(Galivants_Ferry);
map.removeOverlays(Garden_City);
map.removeOverlays(Longs);
map.removeOverlays(Loris);
map.removeOverlays(Myrtle_Beach);
map.removeOverlays(North_Myrtle_Beach);
map.removeOverlays(Surfside_Beach);
map.addOverlays(Conway);
centerByArray(Conway, false, false);
cntMarker += Conway.length;
map.addOverlays(Galivants_Ferry);
centerByArray(Galivants_Ferry, false, false);
cntMarker += Galivants_Ferry.length;
map.addOverlays(Garden_City);
centerByArray(Garden_City, false, false);
cntMarker += Garden_City.length;
map.addOverlays(Longs);
centerByArray(Longs, false, false);
cntMarker += Longs.length;
map.addOverlays(Loris);
centerByArray(Loris, false, false);
cntMarker += Loris.length;
map.addOverlays(Myrtle_Beach);
centerByArray(Myrtle_Beach, false, false);
cntMarker += Myrtle_Beach.length;
map.addOverlays(North_Myrtle_Beach);
centerByArray(North_Myrtle_Beach, false, false);
cntMarker += North_Myrtle_Beach.length;
map.addOverlays(Surfside_Beach);
centerByArray(Surfside_Beach, false, false);
cntMarker += Surfside_Beach.length;
centerByArray(Conway,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=3&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;
}