04_thiessenAnalystService_datasets.html 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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_thiessenAnalystDataset"></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-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: [4503.6240321526, -3861.911472192499],
  32. zoom: 1,
  33. projection: projection,
  34. multiWorld: true
  35. })
  36. });
  37. options = ol.source.TileSuperMapRest.optionsFromMapJSON(baseUrl, mapJSONObj);
  38. var layer = new ol.layer.Tile({
  39. source: new ol.source.TileSuperMapRest(options)
  40. });
  41. map.addLayer(layer);
  42. thiessenAnalystProcess();
  43. });
  44. function thiessenAnalystProcess() {
  45. var dThiessenAnalystParameters = new SuperMap.DatasetThiessenAnalystParameters({
  46. dataset: "Factory@Changchun"
  47. });
  48. new ol.supermap.SpatialAnalystService(serviceUrl).thiessenAnalysis(dThiessenAnalystParameters, function (serviceResult) {
  49. var vectorSource = new ol.source.Vector({
  50. features: (new ol.format.GeoJSON()).readFeatures(serviceResult.result.regions)
  51. });
  52. var resultLayer = new ol.layer.Vector({
  53. source: vectorSource,
  54. style: new ol.style.Style({
  55. stroke: new ol.style.Stroke({
  56. color: 'rgba(100, 100, 225, 10)',
  57. width: 2
  58. }),
  59. fill: new ol.style.Fill({
  60. color: 'rgba(0, 0, 255, 0.1)'
  61. })
  62. })
  63. });
  64. map.addLayer(resultLayer);
  65. });
  66. }
  67. </script>
  68. </body>
  69. </html>