projectPointSet.jsp 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  1. <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
  2. <%@include file="/context/mytags.jsp"%>
  3. <t:base type="jquery,easyui,tools,DatePicker"></t:base>
  4. <script src = "plug-in/tools/jquery.tips.js"></script>
  5. <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=Cq7aZVbka0L3UXDLgkKFoiFqnZAwPdS4"></script>
  6. <body style="overflow-y: hidden" scroll="no">
  7. <style type="text/css">
  8. body{font-size:13px;margin:0px}
  9. #container{width:100%;height:88%;}
  10. .label{margin-left:20px;font-weight:bold;font-size:14px}
  11. .lng-lat{
  12. margin: 0 0 30px 0px;
  13. }
  14. .lng-lat .item{
  15. margin: 10px;
  16. }
  17. .angle{
  18. display: inline-block;
  19. width: 0px;
  20. height: 0px;
  21. position: absolute;
  22. bottom:-60px;
  23. border: 14px solid;
  24. left: 15px;
  25. bottom: -25px;
  26. opacity: 0.8;
  27. border-color: #333333 transparent transparent transparent;
  28. }
  29. .datagrid-btable .datagrid-cell{text-overflow:ellipsis;white-space: nowrap;}
  30. </style>
  31. <div id="main_list" class="easyui-layout" fit="true">
  32. <div style="margin:10px">搜&ensp;&ensp;&ensp;&ensp;索: <input type="text" id="suggestId" size="30" value="百度" style="width:300px;" /></div>
  33. <div class="lng-lat">
  34. <div class="item">
  35. 当前经度:
  36. <input type="text" id="jing" type=""/>
  37. </div>
  38. <div class="item">
  39. 当前纬度:
  40. <input type="text" id="wei" />
  41. <span style="display:-moz-inline-box;display:inline-block;float: right;margin-right: 10px;" >
  42. &ensp;&ensp;&ensp;&ensp;集约化项目分类:
  43. <t:dictSelect field="intensiveProjectType" type="radio" typeGroupCode="intensiveProjectType" defaultVal="qpshuiwusuo" hasLabel="false" title="发送时间类型" ></t:dictSelect>
  44. &ensp;&ensp;&ensp;&ensp;项目名称:
  45. <input type="text" id="name" class="text" />
  46. <a href="#" class="easyui-linkbutton l-btn" iconcls="icon-add" style="margin-left: 50px;" onclick="addPoint()" id="">
  47. <span>保存此点位</span>
  48. </a>
  49. <a href="#" class="easyui-linkbutton l-btn" iconcls="icon-view" onclick="showAllPoint()" id="upexport">
  50. <span>显示全部项目点位</span>
  51. </a>
  52. </span>
  53. </div>
  54. </div>
  55. <div id="container"></div>
  56. </div>
  57. </body>
  58. <script type="text/javascript">
  59. $(function(){
  60. /* var newtitle = '【' +'${schedule.carname}' + '】' + '${schedule.start}' + '~' +'${schedule.end}'+' 作业途径点位列表'; //
  61. $("#detailList").datagrid({title:newtitle}); */
  62. /* if($("#tasktype").val().length == 0)
  63. document.getElementById("tasktype").readonly=false; */
  64. });
  65. function addPoint(){
  66. if(!$('#jing').val()){
  67. tip('请先在地图上选择位置,然后再添加到路径点');
  68. return;
  69. }
  70. if (!$('#name').val())
  71. {
  72. tip('请输入项目名称,请重新录入');
  73. return;
  74. }
  75. $.ajax({
  76. url:"intensiveController.do?doAddFromMap",
  77. data:{name:$('#name').val(),
  78. lng:$('#jing').val(),
  79. lat:$('#wei').val(),
  80. intensiveProjectType:$('input:radio[name="intensiveProjectType"]:checked').val()
  81. },
  82. type:"Post",
  83. dataType:"json",
  84. success:function(data){
  85. if(data.success){
  86. tip(data.msg);
  87. /* $("#detailList").datagrid('reload'); */
  88. $('#name').val('');
  89. }else{
  90. $.messager.alert('提示信息',data.msg);
  91. }
  92. }});
  93. /* //添加完刷新表格
  94. $('#detailList').datagrid({
  95. queryParams:{scheduleid:$('#scheduleid').val()}
  96. });
  97. $("#detailList").datagrid('reload'); */
  98. }
  99. var myLabels = [];
  100. function showAllPoint(){
  101. $.ajax({
  102. url:"intensiveController.do?all",
  103. data:{
  104. },
  105. type:"Post",
  106. dataType:"json",
  107. success:function(data){
  108. if(data.status=="success"){
  109. map.clearOverlays();
  110. var point = new BMap.Point(data.details[0]['lng'],data.details[0]['lat']);
  111. map.centerAndZoom(point,13);
  112. myLabels = [];
  113. for(var i =0; i < data.details.length;i++){
  114. var maker = addMarker(new BMap.Point(data.details[i]['lng'], data.details[i]['lat']),data.details[i]['intensiveProjectType']);
  115. addInfoWindow(maker, data.details[i]['name'],data.details[i]['intensiveProjectType']);
  116. }
  117. }else{
  118. $.messager.alert('提示信息',"未查询到项目位置信息");
  119. }
  120. }});
  121. }
  122. //添加信息窗口
  123. function addInfoWindow(marker, content,type) {
  124. var offsetSize = new BMap.Size(0, 0);
  125. var labelStyle = {
  126. color: "#fff",
  127. backgroundColor: "0.05",
  128. border: "0"
  129. };
  130. //不同数字长度需要设置不同的样式。
  131. /* switch((number + '').length) {
  132. case 1:
  133. labelStyle.fontSize = "14px";
  134. offsetSize = new BMap.Size(4, 2);
  135. break;
  136. case 2:
  137. labelStyle.fontSize = "12px";
  138. offsetSize = new BMap.Size(2, 4);
  139. break;
  140. case 3:
  141. labelStyle.fontSize = "10px";
  142. offsetSize = new BMap.Size(-2, 4);
  143. break;
  144. default:
  145. break;
  146. } */
  147. var label = new BMap.Label('');
  148. label.setStyle(labelStyle);
  149. marker.setLabel(label);
  150. var label = new window.BMap.Label(content, { offset: new BMap.Size(20, -10) });
  151. marker.setLabel(label);
  152. }
  153. //添加标注
  154. function addMarker(point,type) {
  155. var imageoffsetValue = 10;
  156. if(type == 'qpgonganju')//青浦公安局
  157. imageoffsetValue = 11;
  158. if(type == 'qpshuiwuxitong')//青浦水务系统
  159. imageoffsetValue = 10;
  160. if(type == 'qpshuiwusuo')//青浦税务所
  161. imageoffsetValue = 12;
  162. var myIcon;
  163. myIcon = new BMap.Icon("http://api.map.baidu.com/img/markers.png", new BMap.Size(23, 25), {
  164. offset: new BMap.Size(10, 25), // 指定定位位置
  165. imageOffset: new BMap.Size(0, 0 - imageoffsetValue * 25) // 设置图片偏移
  166. });
  167. if(type == 'qpmain')//青浦主要项目
  168. {
  169. myIcon = new BMap.Icon(
  170.         "images/location.png",//"images/location.png",
  171.         new BMap.Size(48,48), // 视窗大小
  172.         {
  173. anchor:new BMap.Size(24,48),
  174.           imageSize: new BMap.Size(48,48), // 引用图片实际大小
  175.           imageOffset:new BMap.Size(0,0) // 图片相对视窗的偏移
  176.         }
  177.      );
  178. }else if(type == 'songjiang'){//松江
  179. myIcon = new BMap.Icon(
  180.         "images/location-lowblue.png",//"images/location.png",
  181.         new BMap.Size(24,24), // 视窗大小
  182.         {
  183. anchor:new BMap.Size(12,24),
  184.           imageSize: new BMap.Size(24,24), // 引用图片实际大小
  185.           imageOffset:new BMap.Size(0,0) // 图片相对视窗的偏移
  186.         }
  187.      );
  188. }
  189. var marker = new BMap.Marker(point,{icon:myIcon});
  190. map.addOverlay(marker);
  191. return marker;
  192. }
  193. function deletePoine(){
  194. $.ajax({
  195. url:"carScheduleDetailController.do?doDelByPoint",
  196. data:{scheduleid:$('#scheduleid').val(),
  197. lng:$('#jing').val(),
  198. lat:$('#wei').val()},
  199. type:"Post",
  200. dataType:"json",
  201. success:function(data){
  202. if(data.status=="success"){
  203. }else{
  204. $.messager.alert('提示信息',"添加到路径点失败");
  205. }
  206. }});
  207. }
  208. function showPoint(lng,lat,address){
  209. //清除地图上的marker
  210. map.clearOverlays();
  211. var marker = new BMap.Marker(new BMap.Point(lng, lat));
  212. var myLabel = setLabelStyle(address);
  213. marker.addEventListener("mouseover", function() {
  214. marker.setLabel(myLabel) //鼠标移入maker显示文字标签
  215. });
  216. marker.addEventListener("mouseout", function (e) {
  217. map.removeOverlay(marker.getLabel()) //鼠标移除maker隐藏文字标签
  218. });
  219. map.addOverlay(marker);
  220. }
  221. function setLabelStyle(content) {
  222. //左偏移 右偏移
  223. var offsetSize = new BMap.Size(0, 0);
  224. var labelStyle = {
  225. color: "#fff",
  226. backgroundColor: "#333333",
  227. border: "0",
  228. fontSize : "14px",
  229. width:"200px",
  230. opacity:"0.8",
  231. verticalAlign:"center",
  232. borderRadius: "2px",
  233. whiteSpace:"normal",
  234. wordWrap:"break-word",
  235. padding:"7px",
  236. };
  237. //用于设置样式
  238. var spanA="<span class='angle'><span>";
  239. //不同数字长度需要设置不同的样式。
  240. var num=parseInt(content.length/10)
  241. switch(num) {
  242. case 0:
  243. offsetSize = new BMap.Size(-20, -40);
  244. break;
  245. case 1:
  246. offsetSize = new BMap.Size(-20, -40);
  247. break;
  248. case 2:
  249. offsetSize = new BMap.Size(-20, -60);
  250. break;
  251. case 3:
  252. offsetSize = new BMap.Size(-20, -80);
  253. break;
  254. default:
  255. break;
  256. }
  257. var label = new BMap.Label(content+spanA, {
  258. offset: offsetSize
  259. });
  260. label.setStyle(labelStyle);
  261. return label;
  262. }
  263. var lng = document.getElementById('jing');
  264. var lat = document.getElementById('wei');
  265. var map = new BMap.Map("container");
  266. var point = new BMap.Point(121.130254,31.156433);
  267. var myGeo = new BMap.Geocoder();// 将地址解析结果显示在地图上,并调整地图视野
  268. map.centerAndZoom(point,13);
  269. map.enableScrollWheelZoom();
  270. map.addControl(new BMap.NavigationControl()); //缩放按钮
  271. var ac = new BMap.Autocomplete( //建立一个自动完成的对象
  272. {"input" : "suggestId"
  273. ,"location" : map
  274. });
  275. ac.addEventListener("onhighlight", function(e) { //鼠标放在下拉列表上的事件
  276. /* var str = "";
  277. var _value = e.fromitem.value;
  278. var value = "";
  279. if (e.fromitem.index > -1) {
  280. value = _value.province + _value.city + _value.district + _value.street + _value.business;
  281. }
  282. str = "FromItem<br />index = " + e.fromitem.index + "<br />value = " + value;
  283. value = "";
  284. if (e.toitem.index > -1) {
  285. _value = e.toitem.value;
  286. value = _value.province + _value.city + _value.district + _value.street + _value.business;
  287. }
  288. str += "<br />ToItem<br />index = " + e.toitem.index + "<br />value = " + value;
  289. G("searchResultPanel").innerHTML = str; */
  290. });
  291. var myValue;
  292. ac.addEventListener("onconfirm", function(e) { //鼠标点击下拉列表后的事件
  293. lng.value = '';
  294. lat.value = '';
  295. var _value = e.item.value;
  296. myValue = _value.province + _value.city + _value.district + _value.street + _value.business;
  297. /* G("searchResultPanel").innerHTML ="onconfirm<br />index = " + e.item.index + "<br />myValue = " + myValue; */
  298. setPlace();
  299. });
  300. function setPlace(){// 创建地址解析器实例
  301. myGeo.getPoint(myValue, function(point){
  302. if (point) {
  303. lng.value = point.lng;
  304. lat.value = point.lat;
  305. map.centerAndZoom(point, 16);
  306. map.addOverlay(new BMap.Marker(point));
  307. }
  308. }, "上海");
  309. }
  310. map.addEventListener('click', function (e) {
  311. lng.value = e.point.lng;
  312. lat.value = e.point.lat;
  313. //清除地图上的marker
  314. map.clearOverlays();
  315. var pt = e.point;
  316. var marker = new BMap.Marker(new BMap.Point(pt.lng, pt.lat));
  317. map.addOverlay(marker);
  318. //myGeo.getLocation(pt, function(rs){
  319. //addressComponents对象可以获取到详细的地址信息
  320. //var addComp = rs.addressComponents;
  321. //var site = addComp.province + addComp.city + addComp.district + addComp.street + addComp.streetNumber;
  322. //$("#address").val(site);
  323. //设置放大倍数
  324. //map.centerAndZoom(new BMap.Point(pt.lng, pt.lat), 18);
  325. //将对应的HTML元素设置值
  326. //$("#addressLonglat").val(pt.lng+","+pt.lat);
  327. // });
  328. })
  329. /* function onloaded(){
  330. var _grid = $('#detailList');
  331. var tableTd = $('div.datagrid-body td[field="address"]');
  332. tableTd.each(function () {
  333. var $this = $(this);
  334. var index = $this.parent('tr').attr('datagrid-row-index');
  335. var rows = _grid.datagrid('getRows');
  336. var currentRow = rows[index];
  337. var content = '<div style="font-size:16px; max-width:700px;word-break: break-all; word-wrap: break-word;">' + currentRow.address + '</div>';
  338. $this.tips({ content: content, wrapColor: 'black' });
  339. });
  340. } */
  341. </script>