画一个精确的圆

This commit is contained in:
jiangzhongzhi 2023-07-06 09:26:04 +08:00
parent 4b840698b5
commit d895c51712

View File

@ -646,6 +646,7 @@ const onclick = () => {
//
// getmeteorologicalFreezes();
meteorologicals()
};
const meteorologicals = () => {
for (const i in circleLayer.value) {
@ -666,33 +667,67 @@ const meteorologicals = () => {
for (const i in informationData.value) {
const centerLonLat = [parseFloat(informationData.value[i].msLongitude),
parseFloat(informationData.value[i].msLatitude)];
const radius = radio1.value / map.getView().getProjection().getMetersPerUnit(); // EPSG:4326
const circleGeometry = new ol.geom.Circle(centerLonLat, radius);
//
circleLayer.value[i] = new ol.layer.Vector({
source: new ol.source.Vector({
features: [
new ol.Feature({
geometry: circleGeometry
})
]
}),
style: new ol.style.Style({
// fill: new ol.style.Fill({
// color: 'rgba(255,255,255,0.5)'
// }),
stroke: new ol.style.Stroke({
color: 'rgb(255,255,0)', //
width: 2
}),
//
const points = 128;
const circleCoords = [];
for (let i = 0; i < points; i++) {
const angle = 2 * Math.PI * i / points;
const coordinate = ol.sphere.computeDestinationPoint(centerLonLat, radio1.value, angle);
circleCoords.push(coordinate);
}
//
const circleFeature = new ol.Feature({
geometry: new ol.geom.Polygon([circleCoords])
});
//
const circleStyle = new ol.style.Style({
stroke: new ol.style.Stroke({
color: 'rgb(255,255,0)',
width: 2
})
});
//
//
circleLayer.value[i] = new ol.layer.Vector({
source: new ol.source.Vector({
features: [circleFeature]
}),
style: circleStyle
});
if(informationData.value[i].warning!=='无灾害'){
map.addLayer(circleLayer.value[i]);
}
//
// const radius = radio1.value / map.getView().getProjection().getMetersPerUnit(); // EPSG:4326
// const circleGeometry = new ol.geom.Circle(centerLonLat, radius);
// //
// circleLayer.value[i] = new ol.layer.Vector({
// source: new ol.source.Vector({
// features: [
// new ol.Feature({
// geometry: circleGeometry
// })
// ]
// }),
// style: new ol.style.Style({
// // fill: new ol.style.Fill({
// // color: 'rgba(255,255,255,0.5)'
// // }),
// stroke: new ol.style.Stroke({
// color: 'rgb(255,255,0)', //
// width: 2
// }),
// })
// });
// //
// if(informationData.value[i].warning!==''){
// map.addLayer(circleLayer.value[i]);
// }
// 使EPSG:4326
const iconPointGeometry = new ol.geom.Point(centerLonLat);
// Feature
@ -722,7 +757,7 @@ const meteorologicals = () => {
})
meteorologicalsPeople({flag:1,alertRange:radio1.value}).then(res => {
meteorologicalsPeople({flag:1,alertRange:radio1.value,data:value.value}).then(res => {
peopleData.value = res.data
for (const i in peopleData.value) {