04_bufferAnalystService.html 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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_bufferAnalystService"></title>
  9. <script type="text/javascript" src="../js/include-web.js"></script>
  10. <script type="text/javascript" src="../../dist/ol/include-ol.js"></script>
  11. </head>
  12. <body style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%; position: absolute;top: 0;">
  13. <div id="map" style="width: 100%;height:100%"></div>
  14. <script type="text/javascript">
  15. var map, roadLine,
  16. baseUrl = (window.isLocal ? window.server : "https://iserver.supermap.io")+"/iserver/services/map-changchun/rest/maps/长春市区图",
  17. serviceUrl = (window.isLocal ? window.server : "https://iserver.supermap.io")+"/iserver/services/spatialanalyst-changchun/restjsr/spatialanalyst";
  18. var extent = [48.4, -7668.25, 8958.85, -55.58];
  19. var projection = new ol.proj.Projection({
  20. code:'',
  21. extent: extent,
  22. units: 'm'
  23. });
  24. new ol.supermap.MapService(baseUrl).getMapInfo(function (serviceResult) {
  25. var mapJSONObj = serviceResult.result;
  26. map = new ol.Map({
  27. target: 'map',
  28. controls: ol.control.defaults({attributionOptions: {collapsed: false}})
  29. .extend([new ol.supermap.control.Logo()]),
  30. view: new ol.View({
  31. center: [5105, -3375],
  32. zoom: 6,
  33. projection: projection,
  34. multiWorld: true
  35. })
  36. });
  37. var layer = new ol.layer.Tile({
  38. source: new ol.source.TileSuperMapRest(ol.source.TileSuperMapRest.optionsFromMapJSON(baseUrl, mapJSONObj))
  39. });
  40. map.addLayer(layer);
  41. roadLine = new ol.geom.LineString([
  42. [5305.19551436013, -3376.9669111768926],
  43. [5075.3145648369318, -3378.0037556404409],
  44. [5006.0235999418364, -3358.8890067038628],
  45. [4960.9674060199022, -3349.3316322355736],
  46. [4933.319287022352, -3337.3849141502124]
  47. ]);
  48. var vectorSource = new ol.source.Vector({
  49. features: [new ol.Feature(roadLine)]
  50. });
  51. var vectorLayer = new ol.layer.Vector({
  52. source: vectorSource,
  53. style: new ol.style.Style({
  54. stroke: new ol.style.Stroke({
  55. color: 'blue',
  56. width: 3
  57. }),
  58. fill: new ol.style.Fill({
  59. color: 'rgba(0, 0, 255, 0.1)'
  60. })
  61. })
  62. });
  63. map.addLayer(vectorLayer);
  64. bufferAnalystProcess();
  65. });
  66. function bufferAnalystProcess() {
  67. var dsBufferAnalystParameters = new SuperMap.DatasetBufferAnalystParameters({
  68. dataset: "RoadLine2@Changchun",
  69. filterQueryParameter: new SuperMap.FilterParameter({
  70. attributeFilter: "NAME='团结路'"
  71. }),
  72. bufferSetting: new SuperMap.BufferSetting({
  73. endType: SuperMap.BufferEndType.ROUND,
  74. leftDistance: {value: 10},
  75. rightDistance: {value: 10},
  76. semicircleLineSegment: 10
  77. })
  78. });
  79. new ol.supermap.SpatialAnalystService(serviceUrl).bufferAnalysis(dsBufferAnalystParameters, function (serviceResult) {
  80. var vectorSource = new ol.source.Vector({
  81. features: (new ol.format.GeoJSON()).readFeatures(serviceResult.result.recordset.features)
  82. });
  83. var resultLayer = new ol.layer.Vector({
  84. source: vectorSource,
  85. style: new ol.style.Style({
  86. stroke: new ol.style.Stroke({
  87. color: 'red',
  88. width: 1
  89. }),
  90. fill: new ol.style.Fill({
  91. color: 'rgba(255, 0, 0, 0.1)'
  92. })
  93. })
  94. });
  95. map.addLayer(resultLayer);
  96. });
  97. }
  98. </script>
  99. </body>
  100. </html>