[英]Openlayers geometry shapes not zooming when map is zoomed
我已经使用Openlayers绘制了一个圆形几何图形,并且该圆形显示在地图中,但是当我缩放地图时,该圆形没有被缩放,并且它保持在相同的半径,在每个缩小级别上都会变小
我已经按照下面绘制了圆的几何形状
var circleFeature = new ol.Feature
({
geometry: new ol.geom.Circle([0, 0], 5)
});
circleStyle = new ol.style.Style({
image: new ol.style.Circle({
radius: 5,
fill: null,
zIndex: 3,
stroke: new ol.style.Stroke({
color: '#FF0000',
width: 2
})
})
});
我希望圆(或任何几何形状)会像例如https://openlayers.org/en/latest/examples/draw-shapes.html一样被放大。 但就我而言,它不起作用
使用样式
new ol.style.Style({
fill: null,
zIndex: 3,
stroke: new ol.style.Stroke({
color: '#FF0000',
width: 2
})
});
ol.style.Circle
用于为特征(例如具有圆形图像的点)设置样式,半径以像素为单位,因此不会随缩放而变化。
您已添加圆圈作为标记,因此无法正常工作。 根据需要,您需要添加圆形属性类。
尝试这个
var centerLongitudeLatitude = ol.proj.fromLonLat([23.0225,72.5714]);
var layer = new ol.layer.Vector({
source: new ol.source.Vector({
projection: 'EPSG:4326',
features: [new ol.Feature(new ol.geom.Circle(centerLongitudeLatitude, 400000))]
}),
style: [
new ol.style.Style({
stroke: new ol.style.Stroke({
color: 'blue',
width: 3,
opacity:0.6,
brightness: 0.2
}),
fill: new ol.style.Fill({
color: 'rgba(0, 0, 255, 0.1)'
})
})
]
});
这里400000 = 400000米
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.