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