使用js

时间:2017-08-18 09:05:47

标签: javascript ruby-on-rails google-maps

我正在尝试在js(rails)中绘制简单的折线,但它没有显示任何内容。

function drawlines()
{
    var flightPath = new google.maps.Polyline({
    path: flightPlanCoordinates,
    geodesic: true,
    strokeColor: '#ff0000',
    strokeOpacity: 1.0,
    strokeWeight: 25,
    map:map
    });

flightPath.setMap(map);
console.log('drawn');
}

1 个答案:

答案 0 :(得分:0)

我建议使用此代码。在您的代码中,您不需要使用map:map。

的设置

试试此代码

function drawlines(){

        var flightPath = new google.maps.Polyline({
          path: flightPlanCoordinates,
          geodesic: true,
          strokeColor: '#ff0000',
          strokeOpacity: 1.0,
          strokeWeight: 25,

        });
        flightPath.setMap(map);
}