123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- <!--********************************************************************
- * Copyright© 2000 - 2021 SuperMap Software Co.Ltd. All rights reserved.
- *********************************************************************-->
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="UTF-8">
- <title data-i18n="resources.title_terrainCurvatureCalculation"></title>
- <script type="text/javascript" src="../js/include-web.js"></script>
- <script type="text/javascript" src="../../dist/mapboxgl/include-mapboxgl.js"></script>
- </head>
- <body style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%;position: absolute;top: 0;">
- <div id="map" style="margin:0 auto;width: 100%;height: 100%"></div>
- <script type="text/javascript">
- var host = window.isLocal ? window.server : "https://iserver.supermap.io";
- var map, terrainCurvatureCalculationService, terrainCurvatureCalculationParameters,
- terrainCurvatureCalculationResult,
- themeService, themeGridRange, themeParameters, themeLayer,
- baseUrl = host + "/iserver/services/map-jingjin/rest/maps/京津地区地图/zxyTileImage.png?z={z}&x={x}&y={y}",
- dataUrl = host + "/iserver/services/map-jingjin/rest/maps/京津地区地图",
- serviceUrl = host + "/iserver/services/spatialanalyst-sample/restjsr/spatialanalyst",
- attribution = "<a href='https://www.mapbox.com/about/maps/' target='_blank'>© Mapbox </a>" +
- " with <span>© <a href='https://iclient.supermap.io' target='_blank'>SuperMap iClient</a> | </span>" +
- " Map Data <span>© <a href='http://support.supermap.com.cn/product/iServer.aspx' target='_blank'>SuperMap iServer</a></span> ";
- map = new mapboxgl.Map({
- container: 'map',
- style: {
- "version": 8,
- "sources": {
- "raster-tiles": {
- "attribution": attribution,
- "type": "raster",
- "tiles": [baseUrl],
- "tileSize": 256
- }
- },
- "layers": [{
- "id": "simple-tiles",
- "type": "raster",
- "source": "raster-tiles",
- }]
- },
- center: [116.85, 39.79],
- zoom: 7
- });
- map.addControl(new mapboxgl.NavigationControl(), 'top-left');
- map.addControl(new mapboxgl.supermap.LogoControl(), 'bottom-right');
- map.on("load", function () {
- terrainCurvatureCalculationProcess();
- });
- function terrainCurvatureCalculationProcess() {
- //创建地形曲率计算服务实例
- terrainCurvatureCalculationService = new mapboxgl.supermap.SpatialAnalystService(serviceUrl);
- //创建地形曲率计算参数实例
- terrainCurvatureCalculationParameters = new SuperMap.TerrainCurvatureCalculationParameters({
- dataset: "JingjinTerrain@Jingjin",
- zFactor: 1.0,
- averageCurvatureName: "CurvatureA",
- deleteExistResultDataset: true
- });
- //向iServer发起地形曲率计算请求
- terrainCurvatureCalculationService.terrainCurvatureCalculate(terrainCurvatureCalculationParameters, function (serviceResult) {
- terrainCurvatureCalculationResult = serviceResult.result;
- //用栅格专题图展示分析结果
- showAnalysisResult_ThemeGridRange();
- });
- }
- function showAnalysisResult_ThemeGridRange() {
- themeService = new mapboxgl.supermap.ThemeService(dataUrl);
- var themeGridRangeIteme1 = new SuperMap.ThemeGridRangeItem({
- start: -9000000,
- end: -1000,
- color: new SuperMap.ServerColor(0, 0, 255)
- }),
- themeGridRangeIteme2 = new SuperMap.ThemeGridRangeItem({
- start: -1000,
- end: -1,
- color: new SuperMap.ServerColor(0, 0, 125)
- }),
- themeGridRangeIteme3 = new SuperMap.ThemeGridRangeItem({
- start: -1,
- end: 1,
- color: new SuperMap.ServerColor(0, 125, 125)
- }),
- themeGridRangeIteme4 = new SuperMap.ThemeGridRangeItem({
- start: 1,
- end: 1000,
- color: new SuperMap.ServerColor(0, 125, 0)
- }),
- themeGridRangeIteme5 = new SuperMap.ThemeGridRangeItem({
- start: 1000,
- end: 20000000,
- color: new SuperMap.ServerColor(0, 255, 0)
- });
- themeGridRange = new SuperMap.ThemeGridRange({
- reverseColor: false,
- rangeMode: SuperMap.RangeMode.EQUALINTERVAL,
- //栅格分段专题图子项数组
- items: [themeGridRangeIteme1,
- themeGridRangeIteme2,
- themeGridRangeIteme3,
- themeGridRangeIteme4,
- themeGridRangeIteme5
- ]
- });
- themeParameters = new SuperMap.ThemeParameters({
- //制作专题图的数据集(地形曲率计算的结果数据集)
- datasetNames: [terrainCurvatureCalculationResult.averageCurvatureResult.dataset.split('@')[0]],
- dataSourceNames: ["Jingjin"],
- joinItems: null,
- themes: [themeGridRange]
- });
- themeService.getThemeInfo(themeParameters, function (serviceResult1) {
- var result = serviceResult1.result;
- if (result && result.newResourceID) {
- map.addLayer({
- "id": "themeLayer",
- "type": "raster",
- "source": {
- "type": "raster",
- "tiles": [baseUrl + "&transparent=true&cacheEnabled=false&layersID=" + result.newResourceID],
- "tileSize": 256
- },
- "minzoom": 0,
- "maxzoom": 22
- });
- }
- })
- }
- </script>
- </body>
- </html>
|