我这边是可以访问的,并且它下面还有三个子节点
看了一下,数据集与数据源名称是没错的MPH,这问题到底出在哪里了呀
function addrLocate(){ mphLayer.getSource().clear(); var mphname = $("#addrVal").val(); var sqlParam = new SuperMap.GetFeaturesBySQLParameters({ queryParameter : { name : "mph@mph_nwe", attributeFilter : "MPH.JLXNAME like '%mphname%'", hasGeometry : true }, datasetNames : [ "mph:mph_nwe" ] }); new ol.supermap.FeatureService(urlf).getFeaturesBySQL(sqlParam, function(serviceResult) { var data = serviceResult.result; if(data.length<1){ alert("没有查询到该地址"); }else{ var gpsx; var gpsy; for (var i = 0; i < data.length; i++) { gpsx=parseFloat(data[i].X); gpsy=parseFloat(data[i].Y); var feature = new ol.Feature({ geometry: new ol.geom.Point([gpsx,gpsy]), name:data[i].MPHID, type:'house' }) let style = new ol.style.Style({ image: new ol.style.Icon({ scale: 0.8, src: '../img/housea.png', anchor: [0.48, 0.52] }) }) feature.setStyle(style); mphLayer.getSource().addFeature(feature); } map.getView().setCenter([gpsx,gpsy]); map.getView().setZoom(15); //定义select控制器,点击标注后的事件 } }); }
var sqlParam = new SuperMap.GetFeaturesBySQLParameters({ queryParameter: { name: "Countries@World", attributeFilter: "SMID = 234" }, datasetNames: ["World:Countries"] });
var sqlParam = new SuperMap.GetFeaturesBySQLParameters({ queryParameter : { name : "MPH@mph_nwe", attributeFilter : "MPH.JLXNAME like '%mphname%'", hasGeometry : true }, datasetNames : [ "MPH:mph_nwe" ] });
您仔细对比一下官网的示例,您的这个顺序就乱了呀,name的格式是“数据集@数据源”
datasetNames的格式是“数据源:数据集”呀
var sqlParam = new SuperMap.GetFeaturesBySQLParameters({ queryParameter : { name : "MPH@MPH", attributeFilter : "MPH.JLXNAME like '%mphname%'", hasGeometry : true }, datasetNames : [ "MPH:MPH" ] });