8000 [fix]maplinregl&&openlayers callback promise review by qiw · SuperMap/iClient-JavaScript@129c0a8 · GitHub
[go: up one dir, main page]

Skip to content

Commit 129c0a8

Browse files
committed
[fix]maplinregl&&openlayers callback promise review by qiw
1 parent 9d32e40 commit 129c0a8

File tree

66 files changed

+288
-305
lines changed
  • Some content is hidden

    Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

    66 files changed

    +288
    -305
    lines changed

    examples/maplibregl/01_mapQueryBySQL_FGB.html

    Lines changed: 2 additions & 2 deletions
    Original file line numberDiff line numberDiff line change
    @@ -57,7 +57,7 @@
    5757
    }
    5858
    });
    5959

    60-
    queryService = new maplibregl.supermap.QueryService(url).queryBySQL(param, function (serviceResult) {
    60+
    queryService = new maplibregl.supermap.QueryService(url).queryBySQL(param, 'FGB').then(function (serviceResult) {
    6161
    var FGBLayer = new maplibregl.supermap.FGBLayer({
    6262
    url: serviceResult.result.newResourceLocation,
    6363
    layerID: 'points',
    @@ -68,7 +68,7 @@
    6868
    }
    6969
    });
    7070
    map.addLayer(FGBLayer);
    71-
    }, 'FGB');
    71+
    });
    7272
    }
    7373

    7474
    </script>

    examples/maplibregl/02_getFeatureBySQL_FGB.html

    Lines changed: 3 additions & 4 deletions
    Original file line numberDiff line numberDiff line change
    @@ -77,7 +77,8 @@
    7777

    7878
    new maplibregl.supermap.FeatureService(dataUrl).getFeaturesBySQL(
    7979
    sqlParam,
    80-
    function (serviceResult) {
    80+
    'FGB'
    81+
    ).then(function (serviceResult) {
    8182
    var FGBLayer = new maplibregl.supermap.FGBLayer({
    8283
    url: serviceRes F987 ult.result.newResourceLocation,
    8384
    layerId: 'queryDatas',
    @@ -100,9 +101,7 @@
    100101
    )
    101102
    .addTo(map);
    102103
    });
    103-
    },
    104-
    'FGB'
    105-
    );
    104+
    });
    106105
    }
    107106
    </script>
    108107
    </body>

    examples/maplibregl/04_bufferAnalystService_FGB.html

    Lines changed: 2 additions & 2 deletions
    Original file line numberDiff line numberDiff line change
    @@ -96,7 +96,7 @@
    9696
    })
    9797
    });
    9898
    //缓冲区分析服务 使用 FGB 格式
    99-
    new maplibregl.supermap.SpatialAnalystService(serviceUrl).bufferAnalysis(dsBufferAnalystParameters, function (serviceResult) {
    99+
    new maplibregl.supermap.SpatialAnalystService(serviceUrl).bufferAnalysis(dsBufferAnalystParameters, 'FGB').then(function (serviceResult) {
    100100
    var FGBLayer = new maplibregl.supermap.FGBLayer({
    101101
    url: serviceResult.result.newResourceLocation,
    102102
    strategy: 'all',
    @@ -106,7 +106,7 @@
    106106
    }
    107107
    });
    108108
    map.addLayer(FGBLayer);
    109-
    }, 'FGB')
    109+
    })
    110110
    }
    111111
    </script>
    112112
    </body>

    examples/maplibregl/04_bufferAnalystService_geometry_FGB.html

    Lines changed: 4 additions & 4 deletions
    Original file line numberDiff line numberDiff line change
    @@ -129,7 +129,9 @@
    129129

    130130
    new maplibregl.supermap.SpatialAnalystService(serviceUrl).bufferAnalysis(
    131131
    geoBufferAnalystParams,
    132-
    function (serviceResult) {
    132+
    null,
    133+
    'FGB'
    134+
    ).then(function (serviceResult) {
    133135
    var FGBLayer = new maplibregl.supermap.FGBLayer({
    134136
    url: serviceResult.result.newResourceLocation,
    135137
    strategy: 'all',
    @@ -139,9 +141,7 @@
    139141
    }
    140142
    });
    141143
    map.addLayer(FGBLayer);
    142-
    },
    143-
    'FGB'
    144-
    );
    144+
    });
    145145
    }
    146146
    </script>
    147147
    </body>

    examples/maplibregl/04_overlayAnalystService_FGB.html

    Lines changed: 3 additions & 4 deletions
    Original file line numberDiff line numberDiff line change
    @@ -60,7 +60,8 @@
    6060

    6161
    new maplibregl.supermap.SpatialAnalystService(serviceUrl).overlayAnalysis(
    6262
    datasetOverlayAnalystParameters,
    63-
    function (serviceResult) {
    63+
    'FGB'
    64+
    ).then(function (serviceResult) {
    6465
    var FGBLayer = new maplibregl.supermap.FGBLayer({
    6566
    url: serviceResult.result.newResourceLocation,
    6667
    strategy: 'all',
    @@ -70,9 +71,7 @@
    7071
    }
    7172
    });
    7273
    map.addLayer(FGBLayer);
    73-
    },
    74-
    'FGB'
    75-
    );
    74+
    });
    7675
    }
    7776
    </script>
    7877
    </body>

    examples/maplibregl/04_surfaceAnalystService_FGB.html

    Lines changed: 2 additions & 2 deletions
    Original file line numberDiff line numberDiff line change
    @@ -80,7 +80,7 @@
    8080
    });
    8181
    //创建表面分析服务实例
    8282
    surfaceAnalystService = new maplibregl.supermap.SpatialAnalystService(serviceUrl);
    83-
    surfaceAnalystService.surfaceAnalysis(surfaceAnalystParameters, function (surfaceAnalystServiceResult) {
    83+
    surfaceAnalystService.surfaceAnalysis(surfaceAnalystParameters, 'FGB').then(function (surfaceAnalystServiceResult) {
    8484
    var FGBLayer = new maplibregl.supermap.FGBLayer({
    8585
    url: surfaceAnalystServiceResult.result.newResourceLocation,
    8686
    featureLoader: function(feature) {
    @@ -106,7 +106,7 @@
    106106
    }
    107107
    });
    108108
    map.addLayer(FGBLayer);
    109-
    }, 'FGB');
    109+
    });
    110110
    }
    111111
    </script>
    112112
    </body>

    examples/maplibregl/04_thiessenAnalystService_datasets_FGB.html

    Lines changed: 2 additions & 2 deletions
    Original file line numberDiff line numberDiff line change
    @@ -52,7 +52,7 @@
    5252
    dataset: "Town_P@Jingjin"
    5353
    });
    5454

    55-
    new maplibregl.supermap.SpatialAnalystService(serviceUrl).thiessenAnalysis(dThiessenAnalystParameters, function (serviceResult) {
    55+
    new maplibregl.supermap.SpatialAnalystService(serviceUrl).thiessenAnalysis(dThiessenAnalystParameters, 'FGB').then(function (serviceResult) {
    5656
    var FGBLayer = new maplibregl.supermap.FGBLayer({
    5757
    url: serviceResult.result.newResourceLocation,
    5858
    strategy: 'all',
    @@ -62,7 +62,7 @@
    6262
    }
    6363
    });
    6464
    map.addLayer(FGBLayer);
    65-
    }, 'FGB');
    65+
    });
    6666
    }
    6767
    </script>
    6868
    </body>

    examples/maplibregl/04_thiessenAnalystService_geometry_FGB.html

    Lines changed: 2 additions & 2 deletions
    Original file line numberDiff line numberDiff line change
    @@ -103,7 +103,7 @@
    103103
    points: pointsList
    104104
    });
    105105
    //创建泰森多边形服务实例
    106-
    new maplibregl.supermap.SpatialAnalystService(serviceUrl).thiessenAnalysis(gThiessenAnalystParameters, function (serviceResult) {
    106+
    new maplibregl.supermap.SpatialAnalystService(serviceUrl).thiessenAnalysis(gThiessenAnalystParameters, 'FGB').then(function (serviceResult) {
    107107
    var FGBLayer = new maplibregl.supermap.FGBLayer({
    108108
    url: serviceResult.result.newResourceLocation,
    109109
    strategy: 'all',
    @@ -113,7 +113,7 @@
    113113
    }
    114114
    });
    115115
    map.addLayer(FGBLayer);
    116-
    }, 'FGB')
    116+
    })
    117117
    }
    118118
    </script>
    119119
    </body>

    examples/maplibregl/rangeTheme3DLayer.html

    Lines changed: 1 addition & 2 deletions
    Original file line numberDiff line numberDiff line change
    @@ -76,9 +76,8 @@
    7676

    7777
    new maplibregl.supermap.FeatureService(dataUrl).getFeaturesBySQL(
    7878
    getFeatureBySQLParams,
    79-
    processCompleted,
    8079
    maplibregl.supermap.DataFormat.GEOJSON
    81-
    );
    80+
    ).then(processCompleted);
    8281
    }
    8382

    8483
    function processCompleted(serviceResult) {

    examples/maplibregl/rangeThemeLayer.html

    Lines changed: 0 additions & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -119,7 +119,6 @@ <h5 class='panel-title text-center'>
    119119
    });
    120120
    new maplibregl.supermap.FeatureService(dataUrl).getFeaturesBySQL(
    121121
    getFeatureBySQLParams,
    122-
    null,
    123122
    maplibregl.supermap.DataFormat.ISERVER
    124123
    ).then(processCompleted);
    125124

    examples/maplibregl/uniqueTheme3DLayer.html

    Lines changed: 0 additions & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -75,7 +75,6 @@
    7575

    7676
    new maplibregl.supermap.FeatureService(dataUrl).getFeaturesBySQL(
    7777
    getFeatureBySQLParams,
    78-
    null,
    7978
    maplibregl.supermap.DataFormat.GEOJSON
    8079
    ).then( processCompleted);
    8180
    }

    examples/maplibregl/uniqueThemeLayer.html

    Lines changed: 0 additions & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -147,7 +147,6 @@ <h5 class='panel-title text-center'>
    147147
    });
    148148
    new maplibregl.supermap.FeatureService(dataUrl).getFeaturesBySQL(
    149149
    getFeatureBySQLParams,
    150-
    null,
    151150
    maplibregl.supermap.DataFormat.ISERVER
    152151
    ).then(processCompleted);
    153152

    examples/openlayers/01_mapQueryBySQL_FGB.html

    Lines changed: 1 addition & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -42,7 +42,7 @@
    4242
    attributeFilter: "SMID > 0"
    4343
    }
    4444
    });
    45-
    new ol.supermap.QueryService(url).queryBySQL(param, null, 'FGB').then(function (serviceResult) {
    45+
    new ol.supermap.QueryService(url).queryBySQL(param, 'FGB').then(function (serviceResult) {
    4646
    const vectorSource = new ol.source.FGB({
    4747
    url: serviceResult.result.newResourceLocation,
    4848
    strategy: ol.loadingstrategy.all,

    examples/openlayers/02_getFeatureBySQL_FGB.html

    Lines changed: 0 additions & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -51,7 +51,6 @@
    5151
    });
    5252
    new ol.supermap.FeatureService(url).getFeaturesBySQL(
    5353
    sqlParam,
    54-
    null,
    5554
    'FGB'
    5655
    ).then(function (serviceResult) {
    5756
    const vectorSource = new ol.source.FGB({

    examples/openlayers/04_bufferAnalystService_FGB.html

    Lines changed: 1 addition & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -80,7 +80,7 @@
    8080
    semicircleLineSegment: 10
    8181
    })
    8282
    });
    83-
    new ol.supermap.SpatialAnalystService(serviceUrl).bufferAnalysis(dsBufferAnalystParameters, null, 'FGB').then(function (serviceResult) {
    83+
    new ol.supermap.SpatialAnalystService(serviceUrl).bufferAnalysis(dsBufferAnalystParameters, 'FGB').then(function (serviceResult) {
    8484
    const vectorSource = new ol.source.FGB({
    8585
    url: serviceResult.result.newResourceLocation,
    8686
    strategy: ol.loadingstrategy.all,

    examples/openlayers/04_bufferAnalystService_geometry_FGB.html

    Lines changed: 2 additions & 2 deletions
    Original file line numberDiff line numberDiff line change
    @@ -142,7 +142,8 @@
    142142
    var spatialAnalystService = new ol.supermap.SpatialAnalystService(serviceUrl);
    143143
    spatialAnalystService.bufferAnalysis(
    144144
    geoBufferAnalystParams1,
    145-
    function (serviceResult) {
    145+
    'FGB'
    146+
    ).then(function (serviceResult) {
    146147
    const vectorSource = new ol.source.FGB({
    147148
    url: serviceResult.result.newResourceLocation,
    148149
    strategy: ol.loadingstrategy.all
    @@ -162,7 +163,6 @@
    162163
    });
    163164
    map.addLayer(resultLayer);
    164165
    },
    165-
    'FGB'
    166166
    );
    167167

    168168
    spatialAnalystService.bufferAnalysis(

    examples/openlayers/04_overlayAnalystService_FGB.html

    Lines changed: 1 addition & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -44,7 +44,7 @@
    4444
    tolerance: 0,
    4545
    operation: ol.supermap.OverlayOperationType.UNION
    4646
    });
    47-
    new ol.supermap.SpatialAnalystService(serviceUrl).overlayAnalysis(datasetOverlayAnalystParameters, null, 'FGB').then(function (serviceResult) {
    47+
    new ol.supermap.SpatialAnalystService(serviceUrl).overlayAnalysis(datasetOverlayAnalystParameters, 'FGB').then(function (serviceResult) {
    4848
    const vectorSource = new ol.source.FGB({
    4949
    url: serviceResult.result.newResourceLocation,
    5050
    strategy: ol.loadingstrategy.all

    examples/openlayers/04_surfaceAnalystService_FGB.html

    Lines changed: 2 additions & 2 deletions
    Original file line numberDiff line numberDiff line change
    @@ -66,7 +66,7 @@
    6666
    });
    6767
    //创建表面分析服务实例
    6868
    surfaceAnalystService = new ol.supermap.SpatialAnalystService(serviceUrl);
    69-
    surfaceAnalystService.surfaceAnalysis(surfaceAnalystParameters, function (surfaceAnalystServiceResult) {
    69+
    surfaceAnalystService.surfaceAnalysis(surfaceAnalystParameters, 'FGB').then(function (surfaceAnalystServiceResult) {
    7070
    const vectorSource = new ol.source.FGB({
    7171
    url: surfaceAnalystServiceResult.result.newResourceLocation,
    7272
    strategy: ol.loadingstrategy.all
    @@ -85,7 +85,7 @@
    8585
    })
    8686
    });
    8787
    map.addLayer(resultLayer);
    88-
    }, 'FGB');
    88+
    });
    8989
    }
    9090
    </script>
    9191
    </body>

    examples/openlayers/04_thiessenAnalystService_datasets_FGB.html

    Lines changed: 2 additions & 2 deletions
    Original file line numberDiff line numberDiff line change
    @@ -46,7 +46,7 @@
    4646
    var dThiessenAnalystParameters = new ol.supermap.DatasetThiessenAnalystParameters({
    4747
    dataset: "Factory@Changchun"
    4848
    });
    49-
    new ol.supermap.SpatialAnalystService(serviceUrl).thiessenAnalysis(dThiessenAnalystParameters, function (serviceResult) {
    49+
    new ol.supermap.SpatialAnalystService(serviceUrl).thiessenAnalysis(dThiessenAnalystParameters, 'FGB').then(function (serviceResult) {
    5050
    const vectorSource = new ol.source.FGB({
    5151
    url: serviceResult.result.newResourceLocation,
    5252
    strategy: ol.loadingstrategy.all
    @@ -65,7 +65,7 @@
    6565
    })
    6666
    });
    6767
    map.addLayer(resultLayer);
    68-
    }, 'FGB');
    68+
    });
    6969
    }
    7070
    </script>
    7171
    </body>

    examples/openlayers/04_thiessenAnalystService_geometry_FGB.html

    Lines changed: 2 additions & 2 deletions
    Original file line numberDiff line numberDiff line change
    @@ -61,7 +61,7 @@
    6161
    points: pointsList
    6262
    });
    6363
    //创建泰森多边形服务实例
    64-
    new ol.supermap.SpatialAnalystService(serviceUrl).thiessenAnalysis(gThiessenAnalystParameters, function (serviceResult) {
    64+
    new ol.supermap.SpatialAnalystService(serviceUrl).thiessenAnalysis(gThiessenAnalystParameters, 'FGB').then(function (serviceResult) {
    6565
    const vectorSource = new ol.source.FGB({
    6666
    url: serviceResult.result.newResourceLocation,
    6767
    strategy: ol.loadingstrategy.all,
    @@ -80,7 +80,7 @@
    8080
    })
    8181
    });
    8282
    map.addLayer(resultLayer);
    83-
    }, 'FGB')
    83+
    })
    8484
    }
    8585
    </script>
    8686
    </body>

    examples/openlayers/rangeThemeLayer.html

    Lines changed: 1 addition & 10 deletions
    Original file line numberDiff line numberDiff line change
    @@ -101,19 +101,10 @@ <h5 class='panel-title text-center'>
    101101
    });
    102102
    getFeatureBySQLService = new ol.supermap.FeatureService(url2).getFeaturesBySQL(
    103103
    getFeatureBySQLParams,
    104-
    processAsync,
    105104
    ol.supermap.DataFormat.ISERVER
    106-
    );
    105+
    ).then(processCompleted).catch(processFailed);
    107106
    });
    108107

    109-
    function processAsync(result) {
    110-
    if(result.type === 'processCompleted') {
    111-
    processCompleted(result);
    112-
    } else {
    113-
    processFailed(result);
    114-
    }
    115-
    }
    116-
    117108
    function processCompleted(getFeaturesEventArgs) {
    118109
    var result = getFeaturesEventArgs.result;
    119110
    if (result && result.features) {

    examples/openlayers/uniqueThemeLayer.html

    Lines changed: 0 additions & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -131,7 +131,6 @@ <h5 class='panel-title text-center'>
    131131
    });
    132132
    getFeatureBySQLService = new ol.supermap.FeatureService(url2).getFeaturesBySQL(
    133133
    getFeatureBySQLParams,
    134-
    null,
    135134
    ol.supermap.DataFormat.ISERVER
    136135
    ).then(processAsync);
    137136
    });

    src/maplibregl/services/AddressMatchService.js

    Lines changed: 2 additions & 2 deletions
    Original file line numberDiff line numberDiff line change
    @@ -35,7 +35,7 @@ export class AddressMatchService extends ServiceBase {
    3535
    * @function AddressMatchService.prototype.code
    3636
    * @description 获取正向地址匹配结果。
    3737
    * @param {GeoCodingParameter} params - 正向匹配参数。
    38-
    * @param {RequestCallback} callback - 回调函数。
    38+
    * @param {RequestCallback} [callback] 回调函数,该参数未传时可通过返回的promise 获取结果
    3939
    * @returns {Promise} Promise 对象。
    4040
    */
    4141
    code(params, callback) {
    @@ -46,7 +46,7 @@ export class AddressMatchService extends ServiceBase {
    4646
    * @function AddressMatchService.prototype.decode
    4747
    * @description 获取反向地址匹配结果。
    4848
    * @param {GeoDecodingParameter} params -反向匹配参数。
    49-
    * @param {RequestCallback} callback - 回调函数。
    49+
    * @param {RequestCallback} [callback] 回调函数,该参数未传时可通过返回的promise 获取结果
    5050
    * @returns {Promise} Promise 对象。
    5151
    */
    5252
    decode(params, callback) {

    src/maplibregl/services/ChartService.js

    Lines changed: 2 additions & 2 deletions
    Original file line numberDiff line numberDiff line change
    @@ -35,7 +35,7 @@ export class ChartService extends ServiceBase {
    3535
    * @function ChartService.prototype.queryChart
    3636
    * @description 查询海图服务。
    3737
    * @param {ChartQueryParameters} params - 海图查询参数类。
    38-
    * @param {RequestCallback} callback 回调函数。
    38+
    * @param {RequestCallback} [callback] 回调函数,该参数未传时可通过返回的promise 获取结果
    3939
    * @param {DataFormat} [resultFormat=DataFormat.GEOJSON] - 返回结果类型。
    4040
    * @returns {Promise} Promise 对象。
    4141
    */
    @@ -46,7 +46,7 @@ export class ChartService extends ServiceBase {
    4646
    /**
    4747
    * @function ChartService.prototype.getChartFeatureInfo
    4848
    * @description 获取海图物标信息服务。
    49-
    * @param {RequestCallback} callback 回调函数。
    49+
    * @param {RequestCallback} [callback] 回调函数,该参数未传时可通过返回的promise 获取结果
    5050
    * @returns {Promise} Promise 对象。
    5151
    */
    5252
    getChartFeatureInfo(callback) {

    src/maplibregl/services/DatasetService.js

    Lines changed: 4 additions & 4 deletions
    Original file line numberDiff line numberDiff line change
    @@ -41,7 +41,7 @@ export class DatasetService extends ServiceBase {
    4141
    * //doSomething
    4242
    * });
    4343
    * @param {string} datasourceName - 数据源名称。
    44-
    * @param {RequestCallback} callback - 回调函数。
    44+
    * @param {RequestCallback} [callback] 回调函数,该参数未传时可通过返回的promise 获取结果
    4545
    */
    4646
    getDatasets(datasourceName, callback) {
    4747
    if (!datasourceName) {
    @@ -59,7 +59,7 @@ export class DatasetService extends ServiceBase {
    5959
    * });
    6060
    * @param {string} datasourceName - 数据源名称。
    6161
    * @param {string} datasetName - 数据集名称。
    62-
    * @param {RequestCallback} callback - 回调函数。
    62+
    * @param {RequestCallback} [callback] 回调函数,该参数未传时可通过返回的promise 获取结果
    6363
    */
    6464
    getDataset(datasourceName, datasetName, callback) {
    6565
    if (!datasourceName || !datasetName) {
    @@ -76,7 +76,7 @@ export class DatasetService extends ServiceBase {
    7676
    * //doSomething
    7777
    * });
    7878
    * @param {CreateDatasetParameters|UpdateDatasetParameters} params - 数据集创建参数类或数据集信息更改参数类。
    79-
    * @param {RequestCallback} callback - 回调函数。
    79+
    * @param {RequestCallback} [callback] 回调函数,该参数未传时可通过返回的promise 获取结果
    8080
    */
    8181
    setDataset(params, callback) {
    8282
    if(!(params instanceof CreateDatasetParameters) && !(params instanceof UpdateDatasetParameters)){
    @@ -109,7 +109,7 @@ export class DatasetService extends ServiceBase {
    109109
    * });
    110110
    * @param {string} datasourceName - 数据源名称。
    111111
    * @param {string} datasetName - 数据集名称。
    112-
    * @param {RequestCallback} callback - 回调函数。
    112+
    * @param {RequestCallback} [callback] 回调函数,该参数未传时可通过返回的promise 获取结果
    113113
    */
    114114
    deleteDataset(datasourceName, datasetName, callback) {
    115115
    return this._datasetService.deleteDatasetService(datasourceName, datasetName, callback);

    0 commit comments

    Comments
     (0)
    0