function addMarkers() { mySelect = document.getElementById('selection'); China_Grove = [];Salisbury = [];Cleveland = [];Landis = [];Faith = [];Granite_Quarry = [];Kannapolis = [];Gold_Hill = [];Mount_Ulla = [];Spencer = [];Rockwell = [];Woodleaf = [];mySelect.options[mySelect.options.length] = new Option("China Grove schools",'all=China_Grove'); mySelect.options[mySelect.options.length] = new Option("Cleveland schools",'all=Cleveland'); mySelect.options[mySelect.options.length] = new Option("Faith schools",'all=Faith'); mySelect.options[mySelect.options.length] = new Option("Gold Hill schools",'all=Gold_Hill'); mySelect.options[mySelect.options.length] = new Option("Granite Quarry schools",'all=Granite_Quarry'); mySelect.options[mySelect.options.length] = new Option("Kannapolis schools",'all=Kannapolis'); mySelect.options[mySelect.options.length] = new Option("Landis schools",'all=Landis'); mySelect.options[mySelect.options.length] = new Option("Mount Ulla schools",'all=Mount_Ulla'); mySelect.options[mySelect.options.length] = new Option("Rockwell schools",'all=Rockwell'); mySelect.options[mySelect.options.length] = new Option("Salisbury schools",'all=Salisbury'); mySelect.options[mySelect.options.length] = new Option("Spencer schools",'all=Spencer'); mySelect.options[mySelect.options.length] = new Option("Woodleaf schools",'all=Woodleaf'); mySelect.options[mySelect.options.length] = new Option("---------------------------",''); China_Grove[China_Grove.length] = createMarker(new GPoint(-80.54244232,35.52484894),"
",iconRd); mySelect.options[mySelect.options.length] = new Option("Bostian Elementary School",'China_Grove=' + China_Grove.length); Salisbury[Salisbury.length] = createMarker(new GPoint(-80.47391510,35.68873596),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Carroll T Overton Elementary School",'Salisbury=' + Salisbury.length); Salisbury[Salisbury.length] = createMarker(new GPoint(-82.72666200,38.81347000),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Charles C Erwin Middle School",'Salisbury=' + Salisbury.length); China_Grove[China_Grove.length] = createMarker(new GPoint(-80.58448029,35.56783676),"",iconRd); mySelect.options[mySelect.options.length] = new Option("China Grove Elementary School",'China_Grove=' + China_Grove.length); China_Grove[China_Grove.length] = createMarker(new GPoint(-80.56953430,35.57596207),"",iconBl); mySelect.options[mySelect.options.length] = new Option("China Grove Middle School",'China_Grove=' + China_Grove.length); Cleveland[Cleveland.length] = createMarker(new GPoint(-80.68200684,35.72968292),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Cleveland Elementary School",'Cleveland=' + Cleveland.length); Landis[Landis.length] = createMarker(new GPoint(-80.61460114,35.54549408),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Corriher Lipe Middle School",'Landis=' + Landis.length); Salisbury[Salisbury.length] = createMarker(new GPoint(-80.42434692,35.67137909),"",iconRd); mySelect.options[mySelect.options.length] = new Option("E Hanford Dole Elementary School",'Salisbury=' + Salisbury.length); Salisbury[Salisbury.length] = createMarker(new GPoint(-82.85874900,38.86041800),"",iconGr); mySelect.options[mySelect.options.length] = new Option("East Rowan High School",'Salisbury=' + Salisbury.length); China_Grove[China_Grove.length] = createMarker(new GPoint(-80.66616821,35.53321075),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Enochville Elementary School",'China_Grove=' + China_Grove.length); Faith[Faith.length] = createMarker(new GPoint(-80.50550079,35.65140152),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Faith Elementary School",'Faith=' + Faith.length); Granite_Quarry[Granite_Quarry.length] = createMarker(new GPoint(-80.44689941,35.61220169),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Granite Quarry Elementary School",'Granite_Quarry=' + Granite_Quarry.length); Salisbury[Salisbury.length] = createMarker(new GPoint(-80.50299835,35.70419693),"",iconRd); mySelect.options[mySelect.options.length] = new Option("H D Isenberg Elementary School",'Salisbury=' + Salisbury.length); Salisbury[Salisbury.length] = createMarker(new GPoint(-80.45722198,35.67700958),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Henderson Independent High School",'Salisbury=' + Salisbury.length); Salisbury[Salisbury.length] = createMarker(new GPoint(-80.55950928,35.70001602),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Hurley Elementary School",'Salisbury=' + Salisbury.length); Kannapolis[Kannapolis.length] = createMarker(new GPoint(-80.60192871,35.50476456),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Jackson Park Elementary School",'Kannapolis=' + Kannapolis.length); Salisbury[Salisbury.length] = createMarker(new GPoint(-80.57286835,35.61553574),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Knollwood Elementary School",'Salisbury=' + Salisbury.length); Salisbury[Salisbury.length] = createMarker(new GPoint(-80.47777557,35.68485260),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Knox Middle School",'Salisbury=' + Salisbury.length); Landis[Landis.length] = createMarker(new GPoint(-80.61774445,35.55301285),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Landis Elementary School",'Landis=' + Landis.length); China_Grove[China_Grove.length] = createMarker(new GPoint(-80.65435600,35.60024600),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Millbridge Elementary School",'China_Grove=' + China_Grove.length); Gold_Hill[Gold_Hill.length] = createMarker(new GPoint(-80.33579254,35.58047485),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Morgan Elementary School",'Gold_Hill=' + Gold_Hill.length); Mount_Ulla[Mount_Ulla.length] = createMarker(new GPoint(-80.71814728,35.66586304),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Mount Ulla Elementary School",'Mount_Ulla=' + Mount_Ulla.length); Spencer[Spencer.length] = createMarker(new GPoint(-80.42787170,35.70109558),"",iconRd); mySelect.options[mySelect.options.length] = new Option("North Rowan Elementary School",'Spencer=' + Spencer.length); Spencer[Spencer.length] = createMarker(new GPoint(-80.42836761,35.69603729),"",iconGr); mySelect.options[mySelect.options.length] = new Option("North Rowan High School",'Spencer=' + Spencer.length); Spencer[Spencer.length] = createMarker(new GPoint(-80.42485046,35.69958115),"",iconBl); mySelect.options[mySelect.options.length] = new Option("North Rowan Middle School",'Spencer=' + Spencer.length); Rockwell[Rockwell.length] = createMarker(new GPoint(-80.41426849,35.55582428),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Rockwell Elementary School",'Rockwell=' + Rockwell.length); Salisbury[Salisbury.length] = createMarker(new GPoint(-80.53211212,35.63871384),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Rowan Academy",'Salisbury=' + Salisbury.length); Salisbury[Salisbury.length] = createMarker(new GPoint(-80.48326874,35.66383743),"",iconGr); mySelect.options[mySelect.options.length] = new Option("Salisbury High School",'Salisbury=' + Salisbury.length); China_Grove[China_Grove.length] = createMarker(new GPoint(-80.61116791,35.57434464),"",iconGr); mySelect.options[mySelect.options.length] = new Option("South Rowan High School",'China_Grove=' + China_Grove.length); Salisbury[Salisbury.length] = createMarker(new GPoint(-80.50906372,35.60681915),"",iconBl); mySelect.options[mySelect.options.length] = new Option("Southeast Middle School",'Salisbury=' + Salisbury.length); Mount_Ulla[Mount_Ulla.length] = createMarker(new GPoint(-80.64236450,35.70052719),"",iconGr); mySelect.options[mySelect.options.length] = new Option("West Rowan High School",'Mount_Ulla=' + Mount_Ulla.length); Salisbury[Salisbury.length] = createMarker(new GPoint(-80.58491516,35.71533585),"",iconBl); mySelect.options[mySelect.options.length] = new Option("West Rowan Middle School",'Salisbury=' + Salisbury.length); Woodleaf[Woodleaf.length] = createMarker(new GPoint(-80.58984375,35.77050781),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Woodleaf Elementary School",'Woodleaf=' + Woodleaf.length); Kannapolis[Kannapolis.length] = createMarker(new GPoint(-80.61986542,35.50804138),"",iconRd); mySelect.options[mySelect.options.length] = new Option("Woodrow Wilson Elementary School",'Kannapolis=' + Kannapolis.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(China_Grove); map.removeOverlays(Cleveland); map.removeOverlays(Faith); map.removeOverlays(Gold_Hill); map.removeOverlays(Granite_Quarry); map.removeOverlays(Kannapolis); map.removeOverlays(Landis); map.removeOverlays(Mount_Ulla); map.removeOverlays(Rockwell); map.removeOverlays(Salisbury); map.removeOverlays(Spencer); map.removeOverlays(Woodleaf); 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(China_Grove);map.removeOverlays(China_Grove); map.removeOverlays(Cleveland); map.removeOverlays(Faith); map.removeOverlays(Gold_Hill); map.removeOverlays(Granite_Quarry); map.removeOverlays(Kannapolis); map.removeOverlays(Landis); map.removeOverlays(Mount_Ulla); map.removeOverlays(Rockwell); map.removeOverlays(Salisbury); map.removeOverlays(Spencer); map.removeOverlays(Woodleaf); map.addOverlays(China_Grove); centerByArray(China_Grove, false, false); cntMarker += China_Grove.length; map.addOverlays(Cleveland); centerByArray(Cleveland, false, false); cntMarker += Cleveland.length; map.addOverlays(Faith); centerByArray(Faith, false, false); cntMarker += Faith.length; map.addOverlays(Gold_Hill); centerByArray(Gold_Hill, false, false); cntMarker += Gold_Hill.length; map.addOverlays(Granite_Quarry); centerByArray(Granite_Quarry, false, false); cntMarker += Granite_Quarry.length; map.addOverlays(Kannapolis); centerByArray(Kannapolis, false, false); cntMarker += Kannapolis.length; map.addOverlays(Landis); centerByArray(Landis, false, false); cntMarker += Landis.length; map.addOverlays(Mount_Ulla); centerByArray(Mount_Ulla, false, false); cntMarker += Mount_Ulla.length; map.addOverlays(Rockwell); centerByArray(Rockwell, false, false); cntMarker += Rockwell.length; map.addOverlays(Salisbury); centerByArray(Salisbury, false, false); cntMarker += Salisbury.length; map.addOverlays(Spencer); centerByArray(Spencer, false, false); cntMarker += Spencer.length; map.addOverlays(Woodleaf); centerByArray(Woodleaf, false, false); cntMarker += Woodleaf.length; centerByArray(China_Grove,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'); } }