04_bufferAnalystService_geometry.html 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <!--********************************************************************
  2. * Copyright© 2000 - 2021 SuperMap Software Co.Ltd. All rights reserved.
  3. *********************************************************************-->
  4. <!DOCTYPE html>
  5. <html>
  6. <head>
  7. <meta charset="UTF-8">
  8. <title data-i18n="resources.title_bufferAnalystServiceGeometry"></title>
  9. <script type="text/javascript" src="../js/include-web.js"></script>
  10. </head>
  11. <body style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%;position: absolute;top: 0;">
  12. <div id="map" style="margin:0 auto;width: 100%;height: 100%"></div>
  13. <script type="text/javascript" src="../../dist/leaflet/include-leaflet.js"></script>
  14. <script type="text/javascript">
  15. var host = window.isLocal ? window.server : "https://iserver.supermap.io";
  16. var map, bufferAnalystService, geoBufferAnalystParams, resultLayer,
  17. queryService, queryByGeometryParameters, resultLayer1,
  18. baseUrl = host + "/iserver/services/map-changchun/rest/maps/长春市区图",
  19. serviceUrl = host + "/iserver/services/spatialanalyst-changchun/restjsr/spatialanalyst";
  20. map = L.map('map', {
  21. crs: L.CRS.NonEarthCRS({
  22. bounds: L.bounds([48.4, -7668.25], [8958.85, -55.58]),
  23. origin: L.point(48.4, -55.58)
  24. }),
  25. center: [-3861.911472192499, 5100],
  26. maxZoom: 18,
  27. zoom: 2
  28. });
  29. L.supermap.tiledMapLayer(baseUrl, {noWrap: true}).addTo(map);
  30. geoBufferAnalystProcess();
  31. function geoBufferAnalystProcess() {
  32. var pointsList = [
  33. [-4690.000, 2823.940],
  34. [-4690.301, 3448.940],
  35. [-3810.125, 3816.561],
  36. [-3609.158, 3917.383],
  37. [-3490.291, 3976.983],
  38. [-4377.027, 4020.004],
  39. [-4382.939, 4076.265],
  40. [-4382.333, 4215.049],
  41. [-4382.285, 4428.156],
  42. [-4383.017, 4647.579],
  43. [-4382.898, 4679.707],
  44. [-4382.635, 4917.462],
  45. [-4381.833, 5074.019],
  46. [-4381.031, 5257.042],
  47. [-4380.717, 5363.785],
  48. [-4378.794, 5671.717],
  49. [-4377.970, 5847.521],
  50. [-4303.528, 5990.637],
  51. [-4270.072, 6055.343],
  52. [-4382.389, 6168.913],
  53. [-4209.927, 6214.183],
  54. [-4209.142, 6377.789],
  55. [-4210.142, 6393.692],
  56. [-4207.450, 6693.989],
  57. [-4208.450, 6788.392],
  58. [-4207.210, 6984.304],
  59. [-4208.296, 7189.183],
  60. [-4208.296, 7300.505],
  61. [-4208.803, 7573.056],
  62. [-4208.804, 7680.977],
  63. [-4208.393, 7850.593],
  64. [-4210.533, 8182.656],
  65. [-4261.485, 8554.893]
  66. ];
  67. //在地图上添加所有离散gps信号点
  68. for (var i = 0; i < pointsList.length; i++) {
  69. L.circleMarker(pointsList[i], {color: 'black', radius: 2}).addTo(map);
  70. }
  71. //将离散gps信号点生成线路
  72. var roadLine = L.polyline(pointsList, {color: 'red'}).addTo(map);
  73. bufferAnalystService = L.supermap.spatialAnalystService(serviceUrl);
  74. //对生成的线路进行缓冲区分析
  75. geoBufferAnalystParams = new SuperMap.GeometryBufferAnalystParameters({
  76. sourceGeometry: roadLine,
  77. bufferSetting: new SuperMap.BufferSetting({
  78. endType: SuperMap.BufferEndType.ROUND,
  79. leftDistance: new SuperMap.BufferDistance({value: 250}),
  80. rightDistance: new SuperMap.BufferDistance({value: 250}),
  81. semicircleLineSegment: 10
  82. })
  83. });
  84. bufferAnalystService.bufferAnalysis(geoBufferAnalystParams, function (serviceResult) {
  85. resultLayer = L.geoJSON(serviceResult.result.resultGeometry).addTo(map);
  86. //查询出缓冲区内信号影响范围内的工厂
  87. queryService = L.supermap.queryService(baseUrl);
  88. queryByGeometryParameters = new SuperMap.QueryByGeometryParameters({
  89. queryParams: [new SuperMap.FilterParameter({name: "Company@Changchun.2"})],
  90. geometry: resultLayer,
  91. spatialQueryMode: SuperMap.SpatialQueryMode.INTERSECT
  92. });
  93. queryService.queryByGeometry(queryByGeometryParameters, function (serviceResult) {
  94. var result = serviceResult.result;
  95. resultLayer1 = L.geoJSON(result.recordsets[0].features).addTo(map);
  96. });
  97. });
  98. }
  99. </script>
  100. </body>
  101. </html>