Advertisement
startwithr

Multiple Polylines Help

Aug 20th, 2012
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.38 KB | None | 0 0
  1. <?php
  2. define('INCLUDE_CHECK',true);
  3. include_once 'connect.php';
  4. session_name('******');
  5. session_set_cookie_params(2*7*24*60*60);
  6. session_start();
  7.  
  8. ?>
  9.  
  10. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  11. <html xmlns="http://www.w3.org/1999/xhtml">
  12.  
  13. <head>
  14. <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
  15. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  16. <title>Registered users only! | Tutorialzine demo</title>
  17.  
  18. <link rel="stylesheet" type="text/css" href="demo.css" media="screen" />
  19. <link type="text/css" href="css/main.css" rel="stylesheet" />
  20. <link type="text/css" href="css/searchMeme.css" rel="stylesheet" />
  21. <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?key=*********&sensor=false&libraries=geometry"></script>
  22. <script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>
  23. <script type="text/javascript" src="js/jquery-ui-1.8.21.custom.min.js"></script>
  24. <script type="text/javascript" src="js/main.js"></script>
  25. <script type="text/javascript" src="js/jquery.searchMeme.js" ></script>
  26.  
  27.  
  28. </head>
  29.  
  30. <body>
  31.  
  32. <div id="main">
  33. <div class="registered-contant">
  34. <div class="container tutorial-info">
  35. <?php
  36. if($_SESSION['id']){
  37. echo '<h3>Hello, '.$_SESSION['usr'].'. You are registered and logged in! <a href="?logoff">Log off</a></h3>';
  38. echo '<h3>Click here to upload a new Log File <a href="?upload">UPLOAD</a></h3>';
  39. if(isset($_GET['logoff']))
  40. {
  41. $_SESSION = array();
  42. session_destroy();
  43. header("Location: index.php");
  44. exit;
  45. }
  46. if(isset($_GET['upload']))
  47. {
  48. header("Location: upload.php");
  49. }
  50. }
  51. else echo '<h3>Please, <a href="index.php">login</a> and come back later!</h3>';
  52. ?>
  53.  
  54.  
  55.  
  56. </div>
  57.  
  58. </div>
  59. <script type="text/javascript">
  60. //<![CDATA[
  61.  
  62. function load() {
  63.  
  64. geocoder = new google.maps.Geocoder();
  65. var myOptions = {
  66. zoom: 3,
  67. center: new google.maps.LatLng(54.312195845815246, -4.45948481875007),
  68. mapTypeId: google.maps.MapTypeId.ROADMAP, //TERRAIN,
  69. minZoom: 3,
  70. streetViewControl: false,
  71. zoomControl: true,
  72. mapTypeControl: true,
  73. mapTypeControlOptions: {
  74. style: google.maps.MapTypeControlStyle.HORIZONTAL_BAR,
  75. position: google.maps.ControlPosition.TOP_RIGHT
  76. },
  77. navigationControl: true,
  78. navigationControlOptions: {
  79. style: google.maps.NavigationControlStyle.ZOOM_PAN,
  80. position: google.maps.ControlPosition.TOP_LEFT
  81. },
  82. scaleControl: true,
  83. scaleControlOptions: {
  84. position: google.maps.ControlPosition.BOTTOM_LEFT
  85. }
  86. }
  87.  
  88. var map = new google.maps.Map(document.getElementById('map'), myOptions);
  89. var infoWindow = new google.maps.InfoWindow;
  90.  
  91. // Change this depending on the name of your PHP file
  92. downloadUrl("output-xml.php", function(data)
  93. {
  94. var points=[];
  95. var markerbgn=[];
  96. var markerend=[];
  97. var xml = data.responseXML;
  98. var markers = xml.documentElement.getElementsByTagName("marker");
  99. for (var i = 0; i < markers.length; i++)
  100. {
  101. var date = markers[i].getAttribute("date");
  102. var dateBgn = markers[0].getAttribute("date");
  103. var time = markers[i].getAttribute("time");
  104. var timebgn = markers[0].getAttribute("time");
  105. var timeend = markers[markers.length-1].getAttribute("time");
  106. var type = markers[i].getAttribute("usid");
  107.  
  108. if (dateBgn == date)
  109. {
  110. points[i] = new google.maps.LatLng(
  111. parseFloat(markers[i].getAttribute("lat")),
  112. parseFloat(markers[i].getAttribute("lng")));
  113. }
  114.  
  115.  
  116. var html1 = "<b>" + date + "</b> <br/>" + timebgn + "</b> <br/>" + "Start Point";
  117. var html2 = "<b>" + date + "</b> <br/>" + timeend + "</b> <br/>" + "End Point";
  118. var content2 = "<b>" + "User: " + type + "</b> <br/>" + date + "</b> <br/>" + "User Route";
  119.  
  120. var encoded_path = google.maps.geometry.encoding.encodePath(points);
  121. console.log(encoded_path);
  122.  
  123. }
  124.  
  125. var decoded_path = google.maps.geometry.encoding.decodePath(encoded_path);
  126.  
  127. // Polyline
  128. var polyOptions = {
  129. path: decoded_path,
  130. map: map,
  131. clickable: true,
  132. strokeColor: "#FF0000",
  133. strokeOpacity: 1.0,
  134. strokeWeight: 2
  135. }
  136.  
  137. //line text
  138. var info = decoded_path;
  139.  
  140. // Polyline
  141. var polyline = new google.maps.Polyline(polyOptions);
  142. polyline.setMap(map);
  143. createInfoWindow(polyline, map, infoWindow, content2);
  144.  
  145.  
  146. if(decoded_path.length!=0)
  147. {
  148. markerbgn = new google.maps.Marker({
  149. map: map,
  150. position: decoded_path[0],
  151. draggable: false,
  152. visible: true
  153. });
  154. markerend = new google.maps.Marker({
  155. map: map,
  156. position: points[decoded_path.length-1],
  157. draggable: false,
  158. visible: true
  159. });
  160.  
  161. bindInfoWindow(markerbgn, map, infoWindow, html1);
  162. bindInfoWindow(markerend, map, infoWindow, html2);
  163. }
  164.  
  165.  
  166. });
  167. }
  168.  
  169.  
  170.  
  171. function bindInfoWindow(markerbgn, map, infoWindow, html1) {
  172. google.maps.event.addListener(markerbgn, 'click', function() {
  173. map.setZoom(14);
  174. map.setCenter(markerbgn.getPosition());
  175. infoWindow.setContent(html1);
  176. infoWindow.open(map, markerbgn);
  177. });
  178. google.maps.event.addListener(markerbgn,"mouseover", function() {
  179. infoWindow.setContent(html1);
  180. infoWindow.open(map, markerbgn);
  181. });
  182. }
  183.  
  184. function bindInfoWindow(markerend, map, infoWindow, html2) {
  185. google.maps.event.addListener(markerend, 'click', function() {
  186. map.setZoom(14);
  187. map.setCenter(markerend.getPosition());
  188. infoWindow.setContent(html2);
  189. infoWindow.open(map, markerend);
  190. });
  191. google.maps.event.addListener(markerend,"mouseover", function() {
  192. infoWindow.setContent(html2);
  193. infoWindow.open(map, markerend);
  194. });
  195. }
  196.  
  197. function createInfoWindow(polyline, map, infoWindow, content2) {
  198. google.maps.event.addListener(polyline, 'click', function(event) {
  199. infoWindow.content = content2;
  200. infoWindow.position = event.latLng;
  201. infoWindow.open(map);
  202. });
  203. }
  204.  
  205. function downloadUrl(url, callback) {
  206. var request = window.ActiveXObject ?
  207. new ActiveXObject('Microsoft.XMLHTTP') :
  208. new XMLHttpRequest;
  209.  
  210. request.onreadystatechange = function() {
  211. if (request.readyState == 4) {
  212. request.onreadystatechange = doNothing;
  213. callback(request, request.status);
  214. }
  215. };
  216.  
  217. request.open('GET', url, true);
  218. request.send(null);
  219. }
  220.  
  221. function doNothing() {}
  222.  
  223. //]]></script>
  224.  
  225. <script type="text/javascript">
  226. $(document).ready(function () {
  227. var search = $('input').searchMeme({ onSearch: function (searchText) {
  228. setTimeout(function () {
  229. search.searchMeme({ searchComplete: true });
  230. alert('Search completed.');
  231. }, 3000);
  232. }
  233. , buttonPlacement: 'left', button: 'orange'
  234. });
  235. });
  236. </script>
  237.  
  238. </head>
  239.  
  240. <input type="text" class="search" id="address"/>
  241. <body onload="load()">
  242. <div id="map" style="position: absolute; left: 0px; top: 0px; width: 100%; height: 100%; z-index: 0;"></div><br/>
  243. </body>
  244.  
  245. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement