poi.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. //var host = 'http://localhost:9082';
  2. function loadPOI(config, markerClick, otherParam) {
  3. var poihost = window.EASYMAP_CONFIG['poihost'];
  4. let timeStart = otherParam.timeStart
  5. let timeEnd = otherParam.timeEnd
  6. let timeRange = (timeStart && timeEnd) ? getTimeRang(otherParam.timeField, 'gte', timeStart, 'lt', timeEnd) : '';
  7. let stateTerms = otherParam.state ? getTerms("state", [otherParam.state]) : '';
  8. let code = otherParam.areaCode ? getTerms("code", [otherParam.areaCode]) : '';
  9. let xiansuoLabs = otherParam.xiansuoLabs ? getTerms("xiansuoLabs", [otherParam.xiansuoLabs]) : '';
  10. let customsQuery = getCustomsQuery([timeRange, stateTerms, xiansuoLabs]);
  11. // let customsQuery = getCustomsQuery([timeRange, stateTerms, code]);
  12. // let customsQuery = getCustomsQuery([timeRange, stateTerms]);
  13. //var layerpoi = new L.tileLayer.wmts(
  14. // console.log(customsQuery)
  15. var obj = {
  16. size: 1000,
  17. // from:1,页面数或者条数
  18. layer: '_all',
  19. style: "default",
  20. tilematrixSet: "default",
  21. format: "marker",//"marker ",//json , hot :热力图,aggs:聚合查询
  22. //source: "pcolor,location,layerGroupName,lon,lat",
  23. //自定义条件查询,需要对ES查询有所了解,字段前必须加上attributes.
  24. //customsQuery:"{\"must\":[{\"terms\":{\"attributes.tow_pac\":[\"460105002\",\"460106100\",\"儋州\"]}}]}",
  25. //"{\"must\":[{\"term\":{\"attributes.tow_pac\":\"460105002\"}},{\"terms\":{\"attributes.city\":[\"海口\",\"三亚\",\"儋州\"]}}],\"should\":[{\"range\":{\"attributes.lon\":{\"lte\":\"109.6875\",\"gt\":\"109.7875\"}}}],\"must_not\":[],\"filter\":[]}"
  26. //矩形选空间查询
  27. //bbox:"BBOX(109.6875,111.12671,20.17639,19.44031)",
  28. //BBOX:"BBOX(minx,maxx,maxy,miny)
  29. //多边形选空间查询
  30. //polygon:"[{lat: 20.05966, lng: 110.16678},{lat: 20.05486, lng: 110.42702},{lat: 19.88731, lng: 110.42976},{lat: 19.89899, lng: 110.10841}]",
  31. //LatLng(20.05966, 110.16678),LatLng(20.05486, 110.42702),LatLng(19.88731, 110.42976),LatLng(19.89899, 110.10841)
  32. //圈选空间查询
  33. //point:"19.52109999980007,109.59813000000008",
  34. //radius:"5000m",
  35. //关键字查询
  36. //keyworks:"海口"
  37. }
  38. console.log(customsQuery)
  39. if (customsQuery) {
  40. obj.customsQuery = customsQuery
  41. }
  42. // if (otherParam.areaCode) {
  43. // obj.areaCode = otherParam.areaCode
  44. // }
  45. obj = Object.assign(obj, config)
  46. var layerpoi = new L.tileLayer.wmts.poi(
  47. poihost + '/poiwmts/aggMarker/getTile',
  48. poihost + '/poiwmts/aggjson/getTile',
  49. obj,
  50. markerClick
  51. );
  52. return layerpoi
  53. // map.addLayer(layerpoi);
  54. /*var layerhotpoi = new L.tileLayer.wmts(
  55. host+'/poiwmts/marker/getTile',
  56. {
  57. size:10000,
  58. layer: "_all",
  59. style: "default",
  60. tilematrixSet: "default",
  61. format: "marker",//"marker ",//json , hot :热力图,aggs:聚合查询
  62. //自定义条件查询,需要对ES查询有所了解,字段前必须加上attributes.
  63. //customsQuery:"{\"must\":[{\"terms\":{\"attributes.tow_pac\":[\"460105002\",\"460106100\",\"儋州\"]}}]}",
  64. //"{\"must\":[{\"term\":{\"attributes.tow_pac\":\"460105002\"}},{\"terms\":{\"attributes.city\":[\"海口\",\"三亚\",\"儋州\"]}}],\"should\":[{\"range\":{\"attributes.lon\":{\"lte\":\"109.6875\",\"gt\":\"109.7875\"}}}],\"must_not\":[],\"filter\":[]}"
  65. //矩形选空间查询
  66. //bbox:"BBOX(109.6875,111.12671,20.17639,19.44031)",
  67. //BBOX:"BBOX(minx,maxx,maxy,miny)
  68. //多边形选空间查询
  69. //polygon:"[{lat: 20.05966, lng: 110.16678},{lat: 20.05486, lng: 110.42702},{lat: 19.88731, lng: 110.42976},{lat: 19.89899, lng: 110.10841}]",
  70. //LatLng(20.05966, 110.16678),LatLng(20.05486, 110.42702),LatLng(19.88731, 110.42976),LatLng(19.89899, 110.10841)
  71. //圈选空间查询
  72. //point:"19.52109999980007,109.59813000000008",
  73. //radius:"5000m",
  74. //关键字查询
  75. //keyworks:"海口"
  76. });*/
  77. //this.map.addLayer(layerhotpoi);
  78. /*var layerjsonpoi = new L.tileLayer.wmts(
  79. host+'/poiwmts/json/getTile',
  80. {
  81. size:10000,
  82. layer: "_all",
  83. style: "default",
  84. tilematrixSet: "default",
  85. format: "json",//"marker ",//json , hot :热力图,aggs:聚合查询
  86. //自定义条件查询,需要对ES查询有所了解,字段前必须加上attributes.
  87. //customsQuery:"{\"must\":[{\"terms\":{\"attributes.tow_pac\":[\"460105002\",\"460106100\",\"儋州\"]}}]}",
  88. //"{\"must\":[{\"term\":{\"attributes.tow_pac\":\"460105002\"}},{\"terms\":{\"attributes.city\":[\"海口\",\"三亚\",\"儋州\"]}}],\"should\":[{\"range\":{\"attributes.lon\":{\"lte\":\"109.6875\",\"gt\":\"109.7875\"}}}],\"must_not\":[],\"filter\":[]}"
  89. //矩形选空间查询
  90. //bbox:"BBOX(109.6875,111.12671,20.17639,19.44031)",
  91. //BBOX:"BBOX(minx,maxx,maxy,miny)
  92. //多边形选空间查询
  93. //polygon:"[{lat: 20.05966, lng: 110.16678},{lat: 20.05486, lng: 110.42702},{lat: 19.88731, lng: 110.42976},{lat: 19.89899, lng: 110.10841}]",
  94. //LatLng(20.05966, 110.16678),LatLng(20.05486, 110.42702),LatLng(19.88731, 110.42976),LatLng(19.89899, 110.10841)
  95. //圈选空间查询
  96. //point:"19.52109999980007,109.59813000000008",
  97. //radius:"5000m",
  98. //关键字查询
  99. //keyworks:"海口"
  100. });*/
  101. //this.map.addLayer(layerjsonpoi);
  102. }
  103. function getCustomsQuery(arr) {
  104. // console.log(arr)
  105. let customsQuery = "{\"must\":[";
  106. for (var i = 0; i < arr.length; i++) {
  107. if (!arr[i]) {
  108. arr.splice(i, 1)
  109. i--
  110. }
  111. }
  112. // console.log(arr)
  113. customsQuery += arr.join(',')
  114. customsQuery += "]}";
  115. return arr.length ? customsQuery : '';
  116. }
  117. /***
  118. * field : 字段名称 :updateTime
  119. * opStart : 操作符: lte , lt , gt , gte
  120. * startTime: 开始时间:20201016151700
  121. * opEnd : 操作符: lte , lt , gt , gte
  122. * endTime:结束时间:20201017151700
  123. * */
  124. function getTimeRang(field, opStart, startTime, opEnd, endTime) {
  125. return "{\"range\":{\"attributes." + field + "\":{\"" + opStart + "\":\"" + startTime + "\",\"" + opEnd + "\":\"" + endTime + "\"}}}";
  126. }
  127. /***
  128. * field : 字段名称 :updateTime
  129. * opStart : 操作符: lte , lt , gt , gte
  130. * startTime: 开始时间:20201016151700
  131. * opEnd : 操作符: lte , lt , gt , gte
  132. * endTime:结束时间:20201017151700
  133. * */
  134. function getTerms(field, values) {
  135. let val = '';
  136. if (values.length) {
  137. val = values.join(',')
  138. }
  139. return "{\"terms\":{\"attributes." + field + "\":[" + val + "]}}";
  140. }
  141. function loadPoiHot(config) {
  142. console.log(123123)
  143. var poihost = window.EASYMAP_CONFIG['poihost'];
  144. // var layerpoi = new L.tileLayer.wmts(
  145. var layerpoi = new L.tileLayer.wmts.poi(
  146. poihost + '/poiwmts/hot/getTile', null,
  147. {
  148. size: 1000,
  149. layer: config.type,
  150. style: "default",
  151. tilematrixSet: "default",
  152. format: "hot",//"marker ",//json , hot :热力图,aggs:聚合查询
  153. source: "pcolor,location,layerGroupName,lon,lat",
  154. //自定义条件查询,需要对ES查询有所了解,字段前必须加上attributes.
  155. // customsQuery: "{\"nested\" : {\"path\" : \"attributes\",\"query\" : {\"range\" : {\"attributes.createDate\": {\"gte\": \"" + config.timeStart + "\",\"lte\": \"" + config.timeEnd + "\"}}}}}"
  156. customsQuery: "{\"must\":[{\"range\":{\"attributes.collecTime\":{\"lte\":\"" + config.timeEnd + "\",\"gte\":\"" + config.timeStart + "\"}}}]}"
  157. // customsQuery: "{\"must\":[{\"range\":{\"attributes.collectime\":{\"lte\":" + config.timeEnd + ",\"gt\":" + config.timeStart + "}}}]}",
  158. // customsQuery: "{\"must\":[{\"terms\":{\"attributes.createDate\":[\"1605579383\"]}}]}",
  159. //"{\"must\":[{\"term\":{\"attributes.tow_pac\":\"460105002\"}},{\"terms\":{\"attributes.city\":[\"海口\",\"三亚\",\"儋州\"]}}],\"should\":[{\"range\":{\"attributes.lon\":{\"lte\":\"109.6875\",\"gt\":\"109.7875\"}}}],\"must_not\":[],\"filter\":[]}"
  160. //矩形选空间查询
  161. //bbox:"BBOX(109.6875,111.12671,20.17639,19.44031)",
  162. //BBOX:"BBOX(minx,maxx,maxy,miny)
  163. //多边形选空间查询
  164. //polygon:"[{lat: 20.05966, lng: 110.16678},{lat: 20.05486, lng: 110.42702},{lat: 19.88731, lng: 110.42976},{lat: 19.89899, lng: 110.10841}]",
  165. //LatLng(20.05966, 110.16678),LatLng(20.05486, 110.42702),LatLng(19.88731, 110.42976),LatLng(19.89899, 110.10841)
  166. //圈选空间查询
  167. //point:"19.52109999980007,109.59813000000008",
  168. //radius:"5000m",
  169. //关键字查询
  170. //keyworks:"海口"
  171. });
  172. return layerpoi
  173. // map.addLayer(layerpoi);
  174. /*var layerhotpoi = new L.tileLayer.wmts(
  175. host+'/poiwmts/marker/getTile',
  176. {
  177. size:1000,
  178. layer: "_all",
  179. style: "default",
  180. tilematrixSet: "default",
  181. format: "marker",//"marker ",//json , hot :热力图,aggs:聚合查询
  182. //自定义条件查询,需要对ES查询有所了解,字段前必须加上attributes.
  183. //customsQuery:"{\"must\":[{\"terms\":{\"attributes.tow_pac\":[\"460105002\",\"460106100\",\"儋州\"]}}]}",
  184. //"{\"must\":[{\"term\":{\"attributes.tow_pac\":\"460105002\"}},{\"terms\":{\"attributes.city\":[\"海口\",\"三亚\",\"儋州\"]}}],\"should\":[{\"range\":{\"attributes.lon\":{\"lte\":\"109.6875\",\"gt\":\"109.7875\"}}}],\"must_not\":[],\"filter\":[]}"
  185. //矩形选空间查询
  186. //bbox:"BBOX(109.6875,111.12671,20.17639,19.44031)",
  187. //BBOX:"BBOX(minx,maxx,maxy,miny)
  188. //多边形选空间查询
  189. //polygon:"[{lat: 20.05966, lng: 110.16678},{lat: 20.05486, lng: 110.42702},{lat: 19.88731, lng: 110.42976},{lat: 19.89899, lng: 110.10841}]",
  190. //LatLng(20.05966, 110.16678),LatLng(20.05486, 110.42702),LatLng(19.88731, 110.42976),LatLng(19.89899, 110.10841)
  191. //圈选空间查询
  192. //point:"19.52109999980007,109.59813000000008",
  193. //radius:"5000m",
  194. //关键字查询
  195. //keyworks:"海口"
  196. });*/
  197. //this.map.addLayer(layerhotpoi);
  198. /*var layerjsonpoi = new L.tileLayer.wmts(
  199. host+'/poiwmts/json/getTile',
  200. {
  201. size:1000,
  202. layer: "_all",
  203. style: "default",
  204. tilematrixSet: "default",
  205. format: "json",//"marker ",//json , hot :热力图,aggs:聚合查询
  206. //自定义条件查询,需要对ES查询有所了解,字段前必须加上attributes.
  207. //customsQuery:"{\"must\":[{\"terms\":{\"attributes.tow_pac\":[\"460105002\",\"460106100\",\"儋州\"]}}]}",
  208. //"{\"must\":[{\"term\":{\"attributes.tow_pac\":\"460105002\"}},{\"terms\":{\"attributes.city\":[\"海口\",\"三亚\",\"儋州\"]}}],\"should\":[{\"range\":{\"attributes.lon\":{\"lte\":\"109.6875\",\"gt\":\"109.7875\"}}}],\"must_not\":[],\"filter\":[]}"
  209. //矩形选空间查询
  210. //bbox:"BBOX(109.6875,111.12671,20.17639,19.44031)",
  211. //BBOX:"BBOX(minx,maxx,maxy,miny)
  212. //多边形选空间查询
  213. //polygon:"[{lat: 20.05966, lng: 110.16678},{lat: 20.05486, lng: 110.42702},{lat: 19.88731, lng: 110.42976},{lat: 19.89899, lng: 110.10841}]",
  214. //LatLng(20.05966, 110.16678),LatLng(20.05486, 110.42702),LatLng(19.88731, 110.42976),LatLng(19.89899, 110.10841)
  215. //圈选空间查询
  216. //point:"19.52109999980007,109.59813000000008",
  217. //radius:"5000m",
  218. //关键字查询
  219. //keyworks:"海口"
  220. });*/
  221. //this.map.addLayer(layerjsonpoi);
  222. }