123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
- <!--********************************************************************
- * Copyright© 2000 - 2021 SuperMap Software Co.Ltd. All rights reserved.
- *********************************************************************-->
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="UTF-8">
- <title data-i18n="resources.title_mathExpression"></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, mathExpressionAnalysisService, mathExpressionAnalysisParameters, mathExpressionAnalysisResult,
- 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 () {
- mathExpressionAnalysisProcess();
- });
- function mathExpressionAnalysisProcess() {
- //创建栅格代数运算服务实例
- mathExpressionAnalysisService = new mapboxgl.supermap.SpatialAnalystService(serviceUrl);
- //创建栅格代数运算参数实例
- mathExpressionAnalysisParameters = new SuperMap.MathExpressionAnalysisParameters({
- //指定数据集,必设
- dataset: "JingjinTerrain@Jingjin",
- //要执行的栅格运算代数表达式,必设
- expression: "[Jingjin.JingjinTerrain] + 600",
- //存储结果数据集的数据源,必设
- targetDatasource: "Jingjin",
- //结果数据集名称,必设
- resultGridName: "MathExpressionAnalysis_Result",
- deleteExistResultDataset: true
- /*//指定数据集中参与栅格代数运算的区域
- extractRegion: L.polygon([
- [38, 116],
- [38, 117],
- [42, 117],
- [42, 116]
- ])*/
- });
- //向iServer发起栅格代数运算请求
- mathExpressionAnalysisService.mathExpressionAnalysis(mathExpressionAnalysisParameters, function (serviceResult) {
- mathExpressionAnalysisResult = serviceResult.result;
- //用栅格专题图展示分析结果
- showAnalysisResult_ThemeGridRange();
- });
- }
- function showAnalysisResult_ThemeGridRange() {
- themeService = new mapboxgl.supermap.ThemeService(dataUrl);
- var themeGridRangeIteme1 = new SuperMap.ThemeGridRangeItem({
- start: 0,
- end: 650,
- color: new SuperMap.ServerColor(40, 140, 40)
- }),
- themeGridRangeIteme2 = new SuperMap.ThemeGridRangeItem({
- start: 650,
- end: 750,
- color: new SuperMap.ServerColor(170, 198, 40)
- }),
- themeGridRangeIteme3 = new SuperMap.ThemeGridRangeItem({
- start: 750,
- end: 900,
- color: new SuperMap.ServerColor(191, 191, 0)
- }),
- themeGridRangeIteme4 = new SuperMap.ThemeGridRangeItem({
- start: 900,
- end: 1350,
- color: new SuperMap.ServerColor(191, 95, 0)
- }),
- themeGridRangeIteme5 = new SuperMap.ThemeGridRangeItem({
- start: 1350,
- end: 3600,
- color: new SuperMap.ServerColor(127, 0, 0)
- });
- themeGridRange = new SuperMap.ThemeGridRange({
- reverseColor: false,
- rangeMode: SuperMap.RangeMode.EQUALINTERVAL,
- //栅格分段专题图子项数组
- items: [themeGridRangeIteme1,
- themeGridRangeIteme2,
- themeGridRangeIteme3,
- themeGridRangeIteme4,
- themeGridRangeIteme5
- ]
- });
- themeParameters = new SuperMap.ThemeParameters({
- //制作专题图的数据集
- datasetNames: [mathExpressionAnalysisResult.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>
|