请问以下代码哪里有错误,为什么已经有数据了,还是显示不出来
try {
const featureService = new FeatureService(this.iServerDataLayerUrl);
featureService.getFeaturesBySQL(queryParams).then((serviceResult) => {
if (serviceResult && serviceResult.result && serviceResult.result.features && serviceResult.result.features.length > 0)
{
const features = serviceResult.result.features;
const feature = features[0];
const content = this.generatePopupContent(feature.properties, e.latlng);
this.popup = L.popup({ maxWidth: 300 })
.setLatLng(e.latlng)
.setContent(content)
.openOn(this.map);
}
else {
console.error('未找到要素或查询结果无效');
}
}).catch((error) => {
console.error('查询失败:', error);
});
} catch (error) {
console.error('查询失败:', error);
}
},
generatePopupContent(attributes, latlng) {
let content = '<div><b>水库信息:</b>';
for (const key in attributes) {
content += `<p>${key}: ${attributes[key]}</p>`;
}
content += `<p>经纬度: 经度 ${latlng.lng}, 纬度 ${latlng.lat}</p></div>`;
return content;
},