报错信息是这样的
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