Javascript 在地图上绘制时,OpenLayers OpenMaps圆的大小不正确
我试图在地图上画一个以公里为半径的圆。但是,圆的大小不正确 如果调用Javascript 在地图上绘制时,OpenLayers OpenMaps圆的大小不正确,javascript,openlayers,openlayers-3,openmap,Javascript,Openlayers,Openlayers 3,Openmap,我试图在地图上画一个以公里为半径的圆。但是,圆的大小不正确 如果调用绘图点({'lat'=>35.055615,'lon'=>85.31179,'radius'=>1000}) 您可以看到显示了圆,但是,并不能立即看出圆太小 我通过访问以下网站验证了尺寸: 您可以看到,圆更大,包含更多的区域。在示例中,移动到制造业道路之外 我知道我的版本更小,因为我一直在研究三边测量点。虽然我的点显示在正确的位置,并且计算都是正确的,但从视觉上看,这些圆并不接触 有人知道为什么我的圆圈更小吗 代码 let
绘图点({'lat'=>35.055615,'lon'=>85.31179,'radius'=>1000})
您可以看到显示了圆,但是,并不能立即看出圆太小
我通过访问以下网站验证了尺寸:
您可以看到,圆更大,包含更多的区域。在示例中,移动到制造业道路之外
我知道我的版本更小,因为我一直在研究三边测量点。虽然我的点显示在正确的位置,并且计算都是正确的,但从视觉上看,这些圆并不接触
有人知道为什么我的圆圈更小吗
代码
let attribution = new ol.control.Attribution({
collapsible: true
});
let center = ol.proj.transform([center_point[0], center_point[1]], 'EPSG:4326', 'EPSG:3857');
let baseMapLayer = new ol.layer.Tile({
source: new ol.source.OSM()
});
let map_view = new ol.View({
center: center,
maxZoom: 18,
zoom: 12
});
let map = new ol.Map({
controls: ol.control.defaults({attribution: false}).extend([attribution]),
layers: [baseMapLayer],
loadTilesWhileAnimating: true,
target: 'map',
view: map_view,
});
let features = [];
let vectorSource = new ol.source.Vector({
projection: 'EPSG:4326'
});
let vectorLayer = new ol.layer.Vector({
source: vectorSource,
updateWhileAnimating: true,
updateWhileInteracting: true,
});
function buildFeature(point) {
console.log(point.lat, point.lon);
let feature = new ol.Feature({
geometry: new ol.geom.Point(ol.proj.transform([point.lon, point.lat], 'EPSG:4326', 'EPSG:3857')),
});
let circleStyle = new ol.style.Style({
geometry: function (feature) {
return new ol.geom.Circle(feature.getGeometry().getCoordinates(), point.radius);
},
stroke: new ol.style.Stroke({color: '#2E86C1', width: 2})
});
feature.setStyle(circleStyle);
return feature;
}
function plotPoint(point) {
vectorSource.addFeature(buildFeature(point));
map.addLayer(vectorLayer);
}
其中调用plotPointEPSG:3857投影单位与地面上的米不同,除非您位于赤道。在纬度60度时,物体的大小是赤道的两倍。您需要相应地调整半径
point.radius/ol.proj.getPointResolution('EPSG:3857',1,feature.getGeometry().getCoordinates())
@Mike就是这样。但在文件中我会在哪里找到呢?