// WFS 图层源
const wfsSource1 = new VectorSource({
format: new GML(),
strategy: bbox,
loader: (extent, resolution, projection) => {
const wfsUrl = '发布的地址,需要拼接参数'
fetch(wfsUrl)
.then((response) => {
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
return response.text();
})
.then((data) => {
const features = new GML().readFeatures(data, {
featureProjection: projection,
});
features.forEach((feature, index) => {
// 获取原始属性并详细打印
const properties = feature.getProperties();
// 创建标签,优先使用 name 字段
const label =
properties.name ||
properties.Name ||
properties.railway_name ||
12-09
8314
