flat: 修改地图

This commit is contained in:
Apcallover
2024-05-16 15:16:11 +08:00
parent 5d82ff12d4
commit f97bd0f232
3 changed files with 29 additions and 6 deletions

View File

@@ -44,6 +44,7 @@
FeatureService,
GetFeaturesByGeometryParameters
} from '@supermap/iclient-ol';
const geoJSONParser = new GeoJSON();
let mypoint = require('@/static/img/mypoint.png');
export default {
name: "uMapView",
@@ -197,7 +198,6 @@
scale: item.id === 1 ? [0.15, 0.15] : [0.1, 0.1]
}
}))
this.careateFeature(features)
},
@@ -228,6 +228,7 @@
POP: 1,
CAPITAL: 'test'
});
this.addPointsSource.clear()
// 将特征添加到矢量图层
this.addPointsSource.addFeature(pointFeature);
// 确保更新地图视图以显示新的标点
@@ -243,14 +244,22 @@
careateFeature(result) {
if (this.vectorSourceIcon) {
this.vectorSourceIcon.clear()
const geojsonObject = {
type: 'FeatureCollection',
features: result,
};
this.vectorSourceIcon.addFeatures(geoJSONParser.readFeatures(geojsonObject))
this.vectorSourceIcon.changed()
return
}
const geojsonObject = {
type: 'FeatureCollection',
features: result,
};
// 创建一个图层作为点位
this.vectorSourceIcon = new SourceVector({
features: new GeoJSON().readFeatures(geojsonObject)
features: geoJSONParser.readFeatures(geojsonObject)
});
this.vectorLayerIcon = new LayerVector({
source: this.vectorSourceIcon,
@@ -280,6 +289,7 @@
}
});
this.map.addLayer(this.vectorLayerIcon);
// 添加事件
this.selectInteraction = new Select({
layers: [this.vectorLayerIcon]
});