Advertisement
Guest User

Untitled

a guest
Apr 24th, 2014
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.52 KB | None | 0 0
  1. var title=[];
  2. var markerDisplay = [];
  3. var iconDisplay = [];
  4. var panelAddresses = [];
  5. var zipGroup = 1;
  6. var infowindow;
  7. var marker;
  8. var markers = [];
  9. var map;
  10. var prevnIndex = 1;
  11. var geoLoc = [[0,0],[32.2457184,-110.85640139999998]
  12. ,[32.246458,-110.8582007]
  13. ,[32.3224437,-111.00827270000002]
  14. ,[32.247539,-110.92618199999998]
  15. ,[32.2257361,-110.85321369999997]
  16. ,[32.2638195,-110.89144929999998]
  17. ,[32.313664,-111.01083]
  18. ,[32.313664,-111.01083]
  19. ,[32.344373,-111.01081899999997]
  20. ,[32.235073,-110.83515899999998]
  21. ,[32.2586974,-110.89205820000001]
  22. ,[32.2485879,-110.88064029999998]
  23. ,[32.2432085,-110.87005019999998]
  24. ,[32.2381581,-110.85689350000001]
  25. ,[32.2258746,-110.85299429999998]
  26. ,[32.249105,-110.87909100000002]
  27. ,[32.264106,-110.89633400000002]
  28. ,[32.24041,-110.85727259999999]
  29. ,[32.248571,-110.88324799999998]
  30. ,[32.2461598,-110.85703910000001]
  31. ,[32.241707,-110.93604399999998]
  32. ,[32.2381581,-110.85689350000001]
  33. ,[32.235073,-110.83515899999998]
  34. ,[31.8557023,-110.97441500000002]
  35. ,[32.314228,-111.01089999999999]
  36. ,[32.2385679,-110.8582381]
  37. ,[32.224974,-110.85333100000003]
  38. ,[32.3180573,-111.01086370000002]
  39. ,[32.2509671,-110.8352984]
  40. ,[32.24041,-110.85727259999999]
  41. ,[32.264085,-110.89645999999999]
  42. ,[32.3387729,-111.0472153]
  43. ,[32.224996,-110.85387700000001]
  44. ,[32.3186531,-111.01102330000003]
  45. ,[32.3358583,-111.03179410000001]
  46. ,[32.2724941,-110.9771265]
  47. ,[32.322515,-111.013375]
  48. ,[32.3960367,-110.96033080000001]
  49. ,[32.428912,-110.9500051]
  50. ,[32.13428500000001,-110.99491]
  51. ,[32.2576229,-110.88258100000002]
  52. ,[32.34111,-111.01158700000002]
  53. ,[32.2509671,-110.8352984]
  54. ,[32.24041,-110.85727259999999]
  55. ,[32.2261052,-111.0012089]
  56. ,[32.2505613,-110.8581221]
  57. ,[32.205767,-110.79347899999999]
  58. ,[32.2419153,-110.85927149999998]
  59. ,[32.251126,-110.834792]
  60. ,[32.3224437,-111.00827270000002]
  61. ,[32.2495664,-110.88038819999997]
  62. ,[31.886166,-110.995948]
  63. ,[32.342049,-111.010829]
  64. ,[32.2458201,-110.85734580000002]
  65. ,[32.24041,-110.85727259999999] ];
  66.  
  67. function zipCoder() {
  68. try {
  69. var addresses = "85716";
  70. var address = "85716";
  71. var prevZip = "";
  72. var panelDisplay = "";
  73. var prevAddress;
  74. var docsList="";
  75. var doctors="";
  76. var docsArray="";
  77.  
  78.  
  79. address = document.getElementById('officeList_id').innerHTML;
  80. docsList = document.getElementById('docsList_id').innerHTML;
  81.  
  82. if (address == undefined || address == null || address == "") {
  83. return;
  84. } else {
  85. addresses = address.split("?");
  86.  
  87. if (docsList != undefined && docsList != null && docsList != "") {
  88. docsArray = docsList.split("?");
  89. }
  90.  
  91.  
  92. if (addresses != undefined && addresses != null && addresses != "") {
  93.  
  94.  
  95. var infowindow;
  96. for (var i = 0; i < addresses.length; i++) {
  97. address = addresses[i].split("^");
  98. if (address != undefined && address != null && address != "") {
  99. if (docsArray != undefined && docsArray != null && docsArray != "") {
  100. doctors = docsArray[i].split("!");
  101. }
  102. panelDisplay += "<div style='width:250px; height: 240;'> <div id='id_imageOffice' class ='mainProviderMaph3'>" + address[0] + "</div>";
  103. panelDisplay += "<div class='providerMapData1'>" + "Location:" + "</div>";
  104. panelDisplay += "<div id = 'id_officeLoc' name = 'officeLocation' class='providerMapData1 providerMapData2'>" + address[1] + "</div>";
  105. panelDisplay += "<div id = 'id_officeLoc2' name = 'officeLocation2' class='providerMapData1 providerMapData2'>" + address[2] + " " + address[3] + "&nbsp " + address[4] + "</div>" ;
  106. panelDisplay += "<div id = 'id_officeLoc3' name = 'officeLocation3' class='providerMapData1 providerMapData2'>" + address[5] + "</div>" ;
  107. panelDisplay += "<div class='providerMapData1'>" + "Hours:" + "</div>";
  108. panelDisplay += "<div id = 'id_officeLoc4' name = 'officeLocation4' class='providerMapData1 providerMapData2'>" + address[6] + "</div>";
  109. panelDisplay += "<div class='providerMapData1'>" + "Providers:" + "</div>";
  110.  
  111. if (doctors != undefined && doctors != null && doctors != "") {
  112. var docs;
  113. for (var j = 0; j < doctors.length; j++) {
  114. docs = doctors[j].split("^");
  115. panelDisplay += "<div id = 'id_officeLoc5' name = 'officeLocation5' class='providerMapData1 providerMapData2'> <a style='text-decoration: underline; color: #0000FF;' onclick='providerBio(" + """ + docs[0] + """ + ", " + """ + docs[1] + """ + ")'>" + docs[0] + " " + docs[1] + "</a></div>" ;
  116. }
  117. }
  118.  
  119. panelDisplay += "</div>";
  120. title[zipGroup] = address[0];
  121. panelAddresses[zipGroup] = address[1] + ", " + address[4];
  122. markerDisplay[zipGroup] = panelDisplay;
  123. iconDisplay[zipGroup] = zipGroup;
  124. zipGroup = zipGroup + 1;
  125.  
  126. panelDisplay = "";
  127.  
  128. }
  129. }
  130. }
  131.  
  132.  
  133. // if (zipGroup > 1) {
  134. // zipGroup = 1;
  135.  
  136. delayGeoCode();
  137. // }
  138. }
  139.  
  140. document.getElementById('officeList_id').innerHTML = "";
  141. document.getElementById('docsList_id').innerHTML = "";
  142. }
  143. catch (err) {
  144. alert(err.message);
  145. }
  146.  
  147. }
  148.  
  149. function delayGeoCode() {
  150.  
  151. for (var i = 1; i < zipGroup; i++) {
  152. var myLatlng = new google.maps.LatLng(geoLoc[i][0],geoLoc[i][1]);
  153.  
  154. marker = new MarkerWithLabel({
  155. position: myLatlng,
  156. map: map,
  157. title: title[i],
  158. labelContent: iconDisplay[i],
  159. labelAnchor: new google.maps.Point(7, 35),
  160. labelClass: "labels", // the CSS class for the label
  161. labelInBackground: false
  162. });
  163.  
  164. (function (data, marker) {
  165. google.maps.event.addListener(marker, 'click', function () {
  166. if (!infowindow) {
  167. infowindow = new google.maps.InfoWindow();
  168. }
  169. infowindow.setContent(data);
  170. infowindow.open(map, marker);
  171. });
  172. markers.push(marker);
  173. })(markerDisplay[i], marker);
  174. }
  175. }
  176.  
  177. function addressResolved(results, status)
  178. {
  179. return function (results, status) {
  180. if (status == google.maps.GeocoderStatus.OK) {
  181. // document.getElementById('geocodeList_id').innerHTML = document.getElementById('geocodeList_id').innerHTML + "<br />" + ",[" + results[0].geometry.location.lat() + "," + results[0].geometry.location.lng() + "]";
  182. marker = new MarkerWithLabel({
  183. position: results[0].geometry.location,
  184. map: map,
  185. title: title[zipGroup],
  186. labelContent: iconDisplay[zipGroup],
  187. labelAnchor: new google.maps.Point(7, 35),
  188. labelClass: "labels", // the CSS class for the label
  189. labelInBackground: false
  190. });
  191.  
  192. (function (data, marker) {
  193. google.maps.event.addListener(marker, 'click', function () {
  194. if (!infowindow) {
  195. infowindow = new google.maps.InfoWindow();
  196. }
  197. infowindow.setContent(data);
  198. infowindow.open(map, marker);
  199. showOffice(marker.getTitle());
  200. });
  201. markers.push(marker);
  202. })(markerDisplay[zipGroup], marker);
  203.  
  204. zipGroup = zipGroup + 1;
  205. } else {
  206. //alert("Geocode was not successful for the following reason: " + status);
  207. }
  208. window.setTimeout(delayGeoCode, 50);
  209. };
  210. }
  211.  
  212.  
  213. // Removes the markers from the map, but keeps them in the array.
  214.  
  215. // Shows any markers currently in the array.
  216. function showMarkers(nIndex) {
  217. if (markers[prevnIndex].getAnimation() != null) {
  218. markers[prevnIndex].setAnimation(null);
  219. markers[prevnIndex].setZIndex(prevnIndex);
  220. }
  221. markers[nIndex].setZIndex(google.maps.Marker.MAX_ZINDEX + 1);
  222. markers[nIndex].setAnimation(google.maps.Animation.BOUNCE);
  223. map.setCenter(markers[nIndex].getPosition());
  224. map.setZoom(12);
  225. prevnIndex = nIndex;
  226. }
  227.  
  228.  
  229. function initializeMap() {
  230. geoCoder = new google.maps.Geocoder();
  231. var loc = [];
  232. var address = ""
  233. var addresses = "85716";
  234. var address = "85716";
  235. var prevZip = "";
  236. var panelDisplay = "";
  237. var zoomLevel = 4;
  238. zoomLevel = 10;
  239. address = "";
  240.  
  241. if (address == undefined || address == null || address == "") {
  242. address = "85716";
  243. } else {
  244. addresses = address.split("?");
  245. if (addresses != undefined && addresses != null && addresses != "") {
  246. address = addresses[0].split("^");
  247. var infowindow;
  248. address = address[5];
  249. }
  250. }
  251. address = "United States, " + address;
  252. var lat = '';
  253. var lng = '';
  254. geoCoder.geocode({ 'address': address }, function (results, status) {
  255. if (status == google.maps.GeocoderStatus.OK) {
  256. lat = results[0].geometry.location.lat();
  257. lng = results[0].geometry.location.lng();
  258.  
  259. var options =
  260. {
  261. zoom: Number(zoomLevel),
  262. center: new google.maps.LatLng(lat, lng),
  263. mapTypeId: google.maps.MapTypeId.ROADMAP,
  264. mapTypeControl: true,
  265. mapTypeControlOptions:
  266. {
  267. poistion: google.maps.ControlPosition.TOP_RIGHT
  268. },
  269. navigationControl: true,
  270. navigationControlOptions: {
  271. style: google.maps.NavigationControlStyle.ZOOM_PAN
  272. },
  273. scaleControl: true,
  274. draggable: true,
  275. draggableCursor: 'move'
  276. };
  277. map = new google.maps.Map(document.getElementById('id_mapPanel'), options);
  278.  
  279. zipCoder();
  280. } else {
  281. alert("Geocode was not successful for the following reason: " + status);
  282. }
  283. });
  284. }
  285.  
  286. window.onload = initializeMap;
  287.  
  288.  
  289. function showOffice(title){
  290. document.getElementById('id_OfficeName').value = title;
  291. form1.submit();
  292.  
  293. }
  294.  
  295. function providerBio(first, last){
  296. var windowFeatures = "status=0, toolbar=0, location=0, menubar=0, directories=0,scrollbars=1, left=0, height=405, width=810";
  297.  
  298. window.open("providerPortrait.php?first=" + first + "&last=" + last, "", "width=930, height=465",windowFeatures);
  299. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement