OpenLayers 3 绘制带坐标的路径

OpenLayers 3 draw path with coordinates

我正在尝试使用 Openlayers 3 的地理定位服务绘制用户移动地图并根据距离收集坐标,然后提供将在地图上显示的测量值或多边形形状。

我已经做了很多研究,但还没有发现任何可以真正让我开始实现最终目标的东西。这在 OpenLayers 3 中可行吗?是否已经内置了我可以使用的东西,或者我必须使用 OpenLayers 3 组件从头开始构建它。

我目前的代码只是通过浏览器打开 OpenLayers 定位服务并跟踪位置。

   new ol.Geolocation({
                projection: mapObj.getView().getProjection(),
                tracking: true,
                trackingOptions: {
                    enableHighAccuracy: true
                }
            })
                .on('change', function () {
                    geoLocationPosition = this.getPosition();
                    geoLocationHeading = this.getHeading() || 0;


             mapObj.getView().setCenter(geoLocationPosition);
                    var trackerStyle = new ol.style.Style({
                        stroke: new ol.style.Stroke({
                            color: '#383838',
                            width: 1
                        }),
                        fill: new ol.style.Fill({
                            color: '#319FD3'
                        })
                    });
                    geoLocationCircle.setStyle(trackerStyle);
                    geoLocationCircle.setGeometry(
                        new ol.geom.Circle(geoLocationPosition, 5)
                    );


                })



            };

感谢任何能指导我正确方向的帮助!!

您可以查看 ol-ext 交互 GeolocationDraw,它结合了地理定位和绘图交互来跟踪位置。 https://viglino.github.io/ol-ext/examples/mobile/map.interaction.geolocationdraw.html

这是文档:http://viglino.github.io/ol-ext/doc/doc-pages/ol.interaction.GeolocationDraw.html