CarDrivingTrack.cshtml 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  2. <html>
  3. <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
  4. <title>轨迹回放</title>
  5. <link rel="stylesheet" href="http://cache.amap.com/lbs/static/main.css" />
  6. <script src="http://webapi.amap.com/maps?v=1.3&key=fa36ec6323075f37020083ceffe8eb24"></script>
  7. <script src="/source/js/jquery-1.8.3.min.js"></script>
  8. <script type="text/javascript" src="/source/My97DatePicker/WdatePicker.js"></script>
  9. <link rel="stylesheet" href="/source/css/dxt.css" />
  10. <style>
  11. #mapContainer {
  12. height: 88%;
  13. width: 98%;
  14. margin: 5px auto;
  15. position: relative;
  16. border: 2px solid rgb(255,255,255)
  17. }
  18. </style>
  19. <body class="bg">
  20. <div class="main_layout">
  21. <!-- 标题 -->
  22. <div class="title">
  23. <form>
  24. <label>任务时间:</label> <input id="d4311" class="Wdate" type="text" onFocus="WdatePicker({maxDate:'#F{$dp.$D(\'d4312\')||\'2020-10-01\'}',isShowClear:false,readOnly:true})" />
  25. <input type="button" value="搜索">
  26. </form>
  27. </div>
  28. <!-- 地图 -->
  29. <div id="mapContainer"></div>
  30. </div>
  31. <script>
  32. var map;
  33. $(function () {
  34. init();
  35. getAjax();
  36. //绑定事件
  37. $(".title input[type='button']").click(submitSerch);
  38. });
  39. var submitSerch = function () {
  40. var reg = /^([0-9]|[\-])*$/;
  41. var start = $("#d4311").val().trim();
  42. var end = $("#d4312").val().trim();
  43. var name = $(".name").val().trim();
  44. var ehr = $(".ehr").val().trim();
  45. if (start || end || name || ehr) {
  46. getAjax(start, end, name, ehr);
  47. }
  48. };
  49. function getAjax(start, end, name, ehr) {
  50. $.ajax({
  51. url: "/taskTrajectory/selectTaskTrajectoryInfo",
  52. type: "get",
  53. dataType: "json",
  54. data: {
  55. "account": "15614141414",
  56. "taskTime": "2017-09-21"
  57. },
  58. success: function (data) {
  59. //初始化请求
  60. if (data != null && data.status == 0) {
  61. var result = data.result;
  62. if (result.length == 0) {
  63. alert("抱歉,您当前没有访调轨迹!");
  64. }
  65. //清楚显示
  66. map.clearMap();
  67. line(result);
  68. addMarker(result);
  69. } else {
  70. alert("您没有访调记录");
  71. }
  72. },
  73. });
  74. }
  75. function init() {
  76. //创建地图对象
  77. map = new AMap.Map("mapContainer", {
  78. resizeEnable: true,
  79. zoom: 12,
  80. mapStyle: "light"
  81. });
  82. //加载缩放条事件
  83. map.plugin(["AMap.ToolBar"], function () {
  84. toolBar = new AMap.ToolBar();
  85. map.addControl(toolBar);
  86. });
  87. }
  88. function line(data) {
  89. var lineArr = new Array();
  90. $.each(data, function (index, value) {
  91. var array = (value.position).split(",");
  92. lineArr.push(new AMap.LngLat(parseFloat(array[1]), parseFloat(array[0])));
  93. });
  94. // 绘制轨迹
  95. var polyline = new AMap.Polyline({
  96. map: map,
  97. path: lineArr,
  98. strokeColor: "rgb(104,180,255)", //线颜色
  99. strokeOpacity: 1, //线透明度
  100. strokeWeight: 2, //线宽
  101. strokeStyle: "solid", //线样式
  102. geodesic: true
  103. });
  104. map.setFitView();
  105. }
  106. function addMarker(data) {
  107. $.each(data, function (index, value) {
  108. var array = (value.position).split(",");
  109. var p0 = parseFloat(array[1]);
  110. var p1 = parseFloat(array[0]);
  111. var action = "AMAP_ANIMATION_DROP";
  112. var point = new AMap.LngLat(p0, p1);
  113. var marker = new AMap.Marker({
  114. id: index,
  115. map: map,
  116. position: point,
  117. icon: "/source/img/flag.png",
  118. autoRotation: true,
  119. animation: action
  120. });
  121. createInfoWindow(value, marker);
  122. });
  123. }
  124. function createInfoWindow(value, marker) {
  125. var info = [];
  126. /* info.push("<a href='/emplpyer/task/get/"+value.id+"' target='main' ><div style='font-weight:bold;color:#000;font-family:'微软雅黑';text-align:center;font-size:'><div><img src='http://wiscc6911.qnoddns.org.cn:8400/file/web/download/10143.jpg' width='80' height='80'> "); */
  127. info.push("任务: " + value.taskName + "");
  128. info.push("时间 : " + value.taskTime + "");
  129. info.push("地址 :" + value.taskAddress + "</div></div></a>");
  130. var iw = new AMap.InfoWindow({
  131. content: info.join("<br>"),
  132. offset: new AMap.Pixel(0, -25),
  133. isCustom: false,
  134. autoMove: true
  135. });
  136. AMap.event.addListener(marker, "mouseover", function (e) {
  137. iw.open(map, marker.getPosition());
  138. });
  139. }
  140. </script>
  141. </body>
  142. </html>