首页 / 浏览问题 / WebGIS / 问题详情
iserve ol进行sql查询时没有结果
xxn
23EXP 2024年04月09日

报错信息是这样的

1个回答

您好,看您服务是对地图服务进行的sql查询,代码具体是怎么实现的呢,参数具体是怎么设置的?
640EXP 2024年04月09日
var resultLayer,map = new ol.Map({
    target: 'map',
    controls: ol.control.defaults({attributionOptions: {collapsed: false}})
        .extend([new ol.supermap.control.Logo()]),
    view: new ol.View({
        center: [12645068.16 , 4132083.07],
        zoom: 17,
        projection: 'EPSG:3857'
    })
});
// 添加图层
var layer = new ol.layer.Tile({
    source: new ol.source.TileSuperMapRest({
        url: url,
        wrapX: true
    }),
    projection: 'EPSG:3857'
});
map.addLayer(layer);
query();

    function query() {
        var sqlParam = new ol.supermap.GetFeaturesBySQLParameters({
            queryParameter: {
                name: "Architecture@Campus",
                attributeFilter: "SMID >30"
            },
            datasetNames: ["Campus:Architecture"]


        });
        
        new ol.supermap.FeatureService(url).getFeaturesBySQL(sqlParam).then(function (serviceResult) {
            var vectorSource = new ol.source.Vector({
                features: (new ol.format.GeoJSON()).readFeatures(serviceResult.result.features),
                wrapX: false
            });
            resultLayer = new ol.layer.Vector({
                source: vectorSource
            });
            map.addLayer(resultLayer);
        });
    }

大概是这样

您代码是对数据服务进行sql查询的,但是您url填的是地图服务的地址。

数据服务的sql查询可参考:https://iclient.supermap.io/examples/openlayers/editor.html#02_getFeatureBySQL

...