04_overlayAnalystService.html 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <!--********************************************************************
  2. * Copyright© 2000 - 2021 SuperMap Software Co.Ltd. All rights reserved.
  3. *********************************************************************-->
  4. <!DOCTYPE html>
  5. <html lang="en">
  6. <head>
  7. <meta charset="UTF-8">
  8. <title data-i18n="resources.title_overlayAnalyst"></title>
  9. <script type="text/javascript" include="bootstrap-css" src="../js/include-web.js"></script>
  10. <script type="text/javascript" src="../../dist/mapboxgl/include-mapboxgl.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="margin:0 auto;width: 100%;height: 100%"></div>
  14. <script type="text/javascript">
  15. var host = window.isLocal ? window.server : "https://iserver.supermap.io";
  16. var map,
  17. attribution = "<a href='https://www.mapbox.com/about/maps/' target='_blank'>© Mapbox </a>" +
  18. " with <span>© <a href='https://iclient.supermap.io' target='_blank'>SuperMap iClient</a> | </span>" +
  19. " Map Data <span>© <a href='http://support.supermap.com.cn/product/iServer.aspx' target='_blank'>SuperMap iServer</a></span> ",
  20. baseUrl = host + "/iserver/services/map-jingjin/rest/maps/京津地区地图/zxyTileImage.png?z={z}&x={x}&y={y}",
  21. serviceUrl = host + "/iserver/services/spatialanalyst-sample/restjsr/spatialanalyst";
  22. map = new mapboxgl.Map({
  23. container: 'map',
  24. style: {
  25. "version": 8,
  26. "sources": {
  27. "raster-tiles": {
  28. "attribution": attribution,
  29. "type": "raster",
  30. "tiles": [baseUrl],
  31. "tileSize": 256
  32. }
  33. },
  34. "layers": [{
  35. "id": "simple-tiles",
  36. "type": "raster",
  37. "source": "raster-tiles",
  38. }]
  39. },
  40. center: [116.2740019864, 39.8970124079],
  41. zoom: 6.5
  42. });
  43. map.addControl(new mapboxgl.NavigationControl(), 'top-left');
  44. map.addControl(new mapboxgl.supermap.LogoControl(), 'bottom-right');
  45. map.on("load", function () {
  46. overlayAnalystProcess();
  47. });
  48. function overlayAnalystProcess() {
  49. var datasetOverlayAnalystParameters = new SuperMap.DatasetOverlayAnalystParameters({
  50. sourceDataset: "BaseMap_R@Jingjin",
  51. operateDataset: "Neighbor_R@Jingjin",
  52. tolerance: 0,
  53. operation: SuperMap.OverlayOperationType.UNION
  54. });
  55. new mapboxgl.supermap.SpatialAnalystService(serviceUrl).overlayAnalysis(datasetOverlayAnalystParameters, function (serviceResult) {
  56. map.addSource("analystDatas", {
  57. "type": "geojson",
  58. "data": serviceResult.result.recordset.features
  59. });
  60. map.addLayer({
  61. "id": "analystLayer",
  62. "type": "fill",
  63. "source": "analystDatas",
  64. "paint": {
  65. "fill-color": "rgba(0, 0, 255, 0.1)",
  66. "fill-outline-color": "rgba(100, 100, 225, 10)"
  67. },
  68. });
  69. });
  70. }
  71. </script>
  72. </body>
  73. </html>