如何在Maps API v3中更改折线的路径?

时间:2012-09-02 13:53:31

标签: javascript google-maps path move polyline

有一种方法可以在Javascript中使用Google Maps API v3更改折线的位置吗?

更改已绘制线条的“路径”选项的方法?我已经改变了“圆圈”的位置,但没有改变“RadiusLine”...

映射初始化代码

var latlng = new google.maps.LatLng(lat, lng);
        var map = new google.maps.Map(document.getElementById('map'),{
            zoom: 13,
            center: latlng,
            mapTypeId: google.maps.MapTypeId.HYBRID,
            streetViewControl: false
        });

        var marker = new google.maps.Marker({
            position: latlng,
            map: map
        });

        var sunCircle = {
          strokeColor: "#c3fc49",
          strokeOpacity: 0.8,
          strokeWeight: 2,
          fillColor: "orange",
          fillOpacity: 0.15,
          map: map,
          center: latlng,
          radius: 1500
        };

        var origin = sunCircle.center;
        var endpoint = google.maps.geometry.spherical.computeOffset(sunCircle.center,sunCircle.radius,180+sunPos);

        var radiusLineSettings = {
            clickable: false,
            map: map,
            strokeColor: "orange",
            strokeWeight: 10,
            path: [origin,endpoint]
        };
        Circle = new google.maps.Circle(sunCircle);
        RadiusLine = new google.maps.Polyline(radiusLineSettings);

1 个答案:

答案 0 :(得分:6)

解决方案:

RadiusLine.setPath(...)