0

所以我看到了一个创建多边形圆来缩放的例子。这是从兴趣点到半径的实际距离。

  map.on('postrender', function (event) {
        const { projection, resolution, center, } = event.frameState.viewState;
        pointResolution = getPointResolution(projection.getCode(), resolution, center);
    });

是否有必要这样做,var newradius = radius / pointResolution因为这没有给我以米为单位的正确距离。它实际上将它分开。我不知道这是否有意义。

 function addCirclePolygon(coordinates) {
        if (vectorSource && vectorSource.getFeatures().length > 0) {
            vectorSource.clear();
        }
        var radius = $scope.options.radius;
        if (createPolygon) {
            **var radius = radius / pointResolution;** <---problem
            circle = new Feature(new Circle(coordinates, radius));
            circle.setStyle(new Style({
                stroke: new Stroke({
                    color: $scope.options.lcolor,
                    width: $scope.options.lwidth
                }),
                fill: new Fill({
                    color: $scope.options.fcolor ? $scope.options.fcolor : 'rgba(255, 255, 255, 0.0)'
                })
            }));
            var geom = circle.get('geometry');
            if (circle instanceof Circle) {
                // We don't like circles, at all.  So here we convert
                // drawn circles to their equivalent polygons.  
                circle.set('geometry', fromCircle(geom));
            }
            vectorSource.addFeature(circle);
            /**
             * Adds a line to show the radius in Units(meters as default)
             * Leaving this here for prosterity
             */
            if (circle) {
                let line = addRadius(circle);
                vectorSource.addFeature(line);
            }
        }
    }
4

0 回答 0