首页 / 浏览问题 / 云GIS / 问题详情
通过接口添加点数据时报错
5EXP 2021年11月12日

通过接口添加点时报错,文档已经看完了,还有疑问,请帮助解答,不要再让我看文档了。

iservice 9D(9.1.2)

疑问,1.使用post请求还是get请求。    2.传参时图层自带的属性需要带进去吗,如SMID等。 3.报错信息具体说的是缺少啥字段或其他问题。

使用get请求报错信息:

SuperMap.Util.RequestJSONP.supermap_callbacks[32397977375578030]({"succeed":false,"error":{"code":500,"errorMsg":"the number of 'fieldNames' and 'fieldValues' are not equal or Geometry is null"}},500)

使用post请求报错信息:

SuperMap.Util.RequestJSONP.supermap_callbacks[32397977375578030]({"succeed":false,"error":{"code":400,"errorMsg":"parameters can not be empty"}},400)

请求API的URL

http://127.0.0.1:8090/iserver/services/data-aomen1118/rest/data/datasources/aomen/datasets/predio_POI_1/features.jsonp?returnContent=true&_method=POST&requestEntity=[{"fieldNames":["cname","pname","zhname","ename","ptype","visible_scale"],"fieldValues":["werqwe","","","","1","0"],"geometry":{"id":0,"style":null,"parts":[1],"points":[{"id":"SuperMap.Geometry.Point_810","x":113.5497588029,"y":22.193803434828,"type":"NONE","tag":null,"bounds":null,"SRID":null}],"type":"POINT","prjCoordSys":{"epsgCode":null}}}]&callback=SuperMap.Util.RequestJSONP.supermap_callbacks[32397977375578030]&sectionCount=1&sectionIndex=0&jsonpUserID=1636698777148

代码:

var sjy_adresss = SUPERMAPLAYER_NewPOI.split('@')[0];
            var data_url = DATASETURL + "/" + sjy_adresss;
            if (op == "add") {
                var editFeatureParameter, editFeatureService,
                    features = {
                        fieldNames: fieldname,
                        fieldValues: fieldvalue,
                        geometry: geometry_add
                    };
                editFeatureParameter = new SuperMap.REST.EditFeaturesParameters({
                    features: [features],
                    editType: SuperMap.REST.EditType.ADD,
                    returnContent: true
                });
                editFeatureService = new SuperMap.REST.EditFeaturesService(data_url, {
                    eventListeners: {
                        "processCompleted": addFeaturesProcessCompleted,
                        "processFailed": processFailed
                    }
                });
                editFeatureService.processAsync(editFeatureParameter);
            }

1个回答

添加要素数据使用的是post请求,get请求表示获取要素

您上述的使用post请求报错的原因是由于参数填写为空导致的,添加参数时需要把所有参数都添加上,您可以看下帮助文档中对应的features要素模块

2,248EXP 2021年11月15日
...