04_overlayAnalystService.html 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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_overlayAnalyst"></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, options,
  16. baseUrl = (window.isLocal ? window.server : "https://iserver.supermap.io")+"/iserver/services/map-jingjin/rest/maps/京津地区人口分布图_专题图",
  17. serviceUrl = (window.isLocal ? window.server : "https://iserver.supermap.io")+"/iserver/services/spatialanalyst-sample/restjsr/spatialanalyst";
  18. var extent = [104.07, 30.54, 119.51, 42.31];
  19. new ol.supermap.MapService(baseUrl).getMapInfo(function (serviceResult) {
  20. var mapJSONObj = serviceResult.result;
  21. map = new ol.Map({
  22. target: 'map',
  23. controls: ol.control.defaults({attributionOptions: {collapsed: false}})
  24. .extend([new ol.supermap.control.Logo()]),
  25. view: new ol.View({
  26. center: [116.77, 40.04],
  27. zoom: 8,
  28. projection: "EPSG:4326",
  29. multiWorld: true
  30. })
  31. });
  32. options = ol.source.TileSuperMapRest.optionsFromMapJSON(baseUrl, mapJSONObj);
  33. var layer = new ol.layer.Tile({
  34. source: new ol.source.TileSuperMapRest(options)
  35. });
  36. map.addLayer(layer);
  37. overlayAnalystProcess();
  38. });
  39. function overlayAnalystProcess() {
  40. var datasetOverlayAnalystParameters = new SuperMap.DatasetOverlayAnalystParameters({
  41. sourceDataset: "BaseMap_R@Jingjin",
  42. operateDataset: "Neighbor_R@Jingjin",
  43. tolerance: 0,
  44. operation: SuperMap.OverlayOperationType.UNION
  45. });
  46. new ol.supermap.SpatialAnalystService(serviceUrl).overlayAnalysis(datasetOverlayAnalystParameters, function (serviceResult) {
  47. var resultLayer = new ol.layer.Vector({
  48. source: new ol.source.Vector({
  49. features: (new ol.format.GeoJSON()).readFeatures(serviceResult.result.recordset.features)
  50. }),
  51. style: new ol.style.Style({
  52. stroke: new ol.style.Stroke({
  53. color: 'rgba(100, 100, 225, 10)',
  54. width: 3
  55. }),
  56. fill: new ol.style.Fill({
  57. color: 'rgba(0, 0, 255, 0.1)'
  58. })
  59. })
  60. });
  61. map.addLayer(resultLayer);
  62. });
  63. }
  64. </script>
  65. </body>
  66. </html>