OpenLayers 3绘制坐标为

时间:2018-03-20 17:52:49

标签: openlayers openlayers-3 angular-openlayers

我尝试使用Openlayers 3的Geolocation服务来映射用户移动并根据距离收集坐标,然后提供将在地图上显示的测量或多边形形状。

我做了很多研究,并没有找到任何能让我开始朝着我的最终目标前进的东西。这可能与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)
                    );


                })



            };

对于指导我正确方向的任何帮助表示赞赏!!

1 个答案:

答案 0 :(得分:1)

您可以查看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