小编Rit*_*ick的帖子

如何在react-google-maps中弯曲折线?

我是 React 的新手,一直在玩 react-google-maps 包。我正在尝试弯曲连接两个地方的折线。阅读完文档后,我尝试将曲线折线函数合并到“可编辑”道具下。

这是弯曲折线的函数:

var map;
var curvature = 0.4; // Arc of the Polyline

function init() {
        var Map = google.maps.Map,
            LatLng = google.maps.LatLng,
            LatLngBounds = google.maps.LatLngBounds,
            Marker = google.maps.Marker,
            Point = google.maps.Point;

            // Initial location of the points
            var pos1 = new LatLng(this.state.srcMarker);
            var pos2 = new LatLng(this.state.desMarker);

            var bounds = new LatLngBounds();
            bounds.extend(pos1);
            bounds.extend(pos2);

            map = new Map(document.getElementById('map-canvas'), {
                    center: bounds.getCenter(),
                    zoom: 12
            });
            map.fitBounds(bounds);

            var markerP1 = new Marker({
                    position: pos1,
                    map: map
            }); …
Run Code Online (Sandbox Code Playgroud)

javascript google-maps reactjs react-google-maps

7
推荐指数
1
解决办法
2136
查看次数