gpt4 book ai didi

geometry - OpenLayers 4 - 半径为米的圆的功能不起作用?

转载 作者:行者123 更新时间:2023-12-02 05:04:58 25 4
gpt4 key购买 nike

我现在从 OpenLayers 2 转到 OpenLayers 4。我想画一个特殊半径为米的圆。

我尝试过:

var circleStyle = new ol.style.Style({
fill: new ol.style.Fill({ color: 'rgba(255,0,0,0.4)' }),
stroke: new ol.style.Stroke({ color: 'rgb(255,0,0)', width: 2 }),
});
//var units = map.getView().getProjection().getUnits();
// var radiusM = circle.getRadius() * ol.proj.METERS_PER_UNIT[units];

var circleFeature = new ol.Feature({
geometry: new ol.geom.Circle(ol.proj.fromLonLat([Element.Position.Longitude, Element.Position.Latitude]), MetersToRadius(Element.RadiusInMetern)),
UserID: Element.UserID,
ID: Element.ID
});

circleFeature.setStyle(circleStyle);
vectorSource.addFeature(circleFeature);

但是当我用 control.ScaleLine 检查圆圈时,它太小了!

我找到了这段代码,但它在 OpenLayer 4 上不起作用。

The object "projection.getPointResolution(resolutionAtEquator, center);" doesnt exists!

 var view = map.getView();
var projection = view.getProjection();
var resolutionAtEquator = view.getResolution();
var center = map.getView().getCenter();
var pointResolution=projection.getPointResolution(resolutionAtEquator, center);
var resolutionFactor = resolutionAtEquator / pointResolution;
var radius = (radius / ol.proj.METERS_PER_UNIT.m) * resolutionFactor;

return(radius);

最佳答案

你需要使用

ol.proj.getPointResolution(projection,resolutionAtEquator,center);

关于geometry - OpenLayers 4 - 半径为米的圆的功能不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46680351/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com