如何将距离和时间的信息窗口(如Google Map)添加到连接两个点的折线上?

时间:2018-12-10 09:55:43

标签: ionic-native google-direction

我正在使用Ionic应用程序,并使用由Google提供的Ionic Google Map Native和Directions服务我通过使用以下代码绘制了多条路线:

calculateAndDisplayRoute() {
var points = [];
this.directionsService.route({
  origin: this.start,
  destination: this.end,
  travelMode: 'DRIVING',
  provideRouteAlternatives: true


}, (response, status) => {
  if (status === 'OK') {
    var step = 1;

    for(var j=0;j<response.routes.length;j++){

      points=[]
      for (var i = 0; i < response.routes[j].overview_path.length; i++) {
        points.push(response.routes[j].overview_path[i].toJSON())
      }
      let position=points[20]
      this.drawRoutePolyLine(points,j,position)
      step=step+1
    }


  } else {
    window.alert('Directions request failed due to ' + status);
  }
});

} 帮助我添加信息窗口

0 个答案:

没有答案