123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- <!--********************************************************************
- * Copyright© 2000 - 2021 SuperMap Software Co.Ltd. All rights reserved.
- *********************************************************************-->
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title data-i18n="resources.title_surfaceAnalyst"></title>
- <style type="text/css">
- body {
- margin: 0;
- overflow: hidden;
- background: #fff;
- width: 100%;
- height: 100%
- }
- #map {
- position: absolute;
- width: 100%;
- height: 100%;
- }
- #toolbar {
- position: absolute;
- top: 50px;
- right: 10px;
- text-align: center;
- z-index: 100;
- border-radius: 4px;
- }
- </style>
- </head>
- <body>
- <div id="toolbar" class="panel panel-primary">
- <div class='panel-heading'>
- <h5 class='panel-title text-center' data-i18n="resources.text_surfaceAnalyst"></h5></div>
- <div class='panel-body content'>
- <input type="button" class="btn btn-default" data-i18n="[value]resources.text_contourLine"
- onclick="surfaceAnalystProcess()"/>
- <input type="button" class="btn btn-default" data-i18n="[value]resources.text_remove" onclick="removeData()"/>
- </div>
- </div>
- <div id="map"></div>
- <script type="text/javascript" include="bootstrap,widgets.alert" src="../js/include-web.js"></script>
- <script type="text/javascript" exclude="iclient-classic" src="../../dist/classic/include-classic.js"></script>
- <script>
- var map, local, baseLayer, resultLayer, Spatialanalyst_sample,
- points = new SuperMap.Geometry.LinearRing([
- new SuperMap.Geometry.Point(0, 4010338),
- new SuperMap.Geometry.Point(1063524, 4010338),
- new SuperMap.Geometry.Point(1063524, 3150322),
- new SuperMap.Geometry.Point(0, 3150322)
- ]),
- region = new SuperMap.Geometry.Polygon([points]),
- host = window.isLocal ? window.server : "https://iserver.supermap.io",
- url = host + "/iserver/services/map-temperature/rest/maps/全国温度变化图",
- url2 = host + "/iserver/services/spatialanalyst-sample/restjsr/spatialanalyst";
- init();
- function init() {
- map = new SuperMap.Map("map", {
- controls: [
- new SuperMap.Control.ScaleLine(),
- new SuperMap.Control.Zoom(),
- new SuperMap.Control.Navigation({
- dragPanOptions: {
- enableKinetic: true
- }
- })], units: "m"
- });
- map.addControl(new SuperMap.Control.LayerSwitcher(), new SuperMap.Pixel(42, 80));
- map.allOverlays = true;
- baseLayer = new SuperMap.Layer.TiledDynamicRESTLayer("全国温度变化图", url, {
- transparent: true,
- cacheEnabled: true
- }, {maxResolution: "auto"});
- baseLayer.events.on({"layerInitialized": addLayer});
- resultLayer = new SuperMap.Layer.Vector("等值线");
- }
- function addLayer() {
- map.addLayers([baseLayer, resultLayer]);
- map.setCenter(new SuperMap.LonLat(531762, 3580330), 2);
- }
- function surfaceAnalystProcess() {
- widgets.alert.clearAlert();
- resultLayer.removeAllFeatures();
- var surfaceAnalystService = new SuperMap.REST.SurfaceAnalystService(url2),
- surfaceAnalystParameters = new SuperMap.REST.SurfaceAnalystParametersSetting({
- datumValue: 0,
- interval: 2,
- resampleTolerance: 0,
- smoothMethod: SuperMap.REST.SmoothMethod.BSPLINE,
- smoothness: 3,
- clipRegion: region
- }),
- params = new SuperMap.REST.DatasetSurfaceAnalystParameters({
- extractParameter: surfaceAnalystParameters,
- dataset: "SamplesP@Interpolation",
- resolution: 9000,
- zValueFieldName: "AVG_TMP"
- });
- surfaceAnalystService.events.on({
- "processCompleted": surfaceAnalystCompleted,
- "processFailed": surfaceAnalystFailed
- });
- surfaceAnalystService.processAsync(params);
- }
- function surfaceAnalystCompleted(args) {
- var features = args.result.recordset.features;
- for (var len = features.length, i = 0; i < len; i++) {
- style = {
- strokeColor: "#304DBE",
- fillOpacity: 0
- }
- features[i].style = style;
- }
- resultLayer.addFeatures(args.result.recordset.features);
- }
- function surfaceAnalystFailed(args) {
- widgets.alert.showAlert(args.error.errorMsg, false);
- }
- function removeData() {
- widgets.alert.clearAlert();
- resultLayer.removeAllFeatures();
- }
- </script>
- </body>
- </html>
|