routingParams.departure 对计算等值线没有影响

routingParams.departure has no effect for calculateIsoline

我正在使用 H.platform.routingService().calculateIsoline 方法并预计 routeParams.departure 属性 会对结果产生影响。 但是,更改日期 and/or 时间对计算的等值线没有影响。

在下面的代码中,startLocs 是一个包含 lat 和 lng 的地理编码对象数组

let queryDateString = queryDate.format('YYYY-MM-DDTHH:mm:ss');

startLocs.forEach(loc => {
      var routingParams = {
        mode: 'fastest;car;',
        start: `geo!${loc.geocode.lat},${loc.geocode.lng}`,
        range: 600,
        rangetype: 'time',
        departure: queryDateString
      };

      // Define a callback function to process the isoline response.
      var onResult = result => {
        var center = new H.geo.Point(
            result.response.center.latitude,
            result.response.center.longitude
          ),
          isolineCoords = result.response.isoline[0].component[0].shape,
          linestring = new H.geo.LineString(),
          isolinePolygon,
          isolineCenter;

        // Add the returned isoline coordinates to a linestring:
        isolineCoords.forEach(function(coords) {
          linestring.pushLatLngAlt.apply(linestring, coords.split(','));
        });

        // Create a polygon and a marker representing the isoline:
        isolinePolygon = new H.map.Polygon(linestring);
        isolineCenter = new H.map.Marker(center);

        // Add the polygon and marker to the map:
        this.markerGroup.addObject(isolineCenter);
        this.polylineGroup.addObject(isolinePolygon);            
      };

      // Get an instance of the routing service:
      var router = this.platform.getRoutingService();

      // Call the Routing API to calculate an isoline:
      router.calculateIsoline(routingParams, onResult, function(error) {
        console.log(error)
      });
    });
    this.isLoading = false;
  } catch (err) {
    console.log('failed processing isochrones', err);
  }

无论本例中 queryDateString 的值如何,结果都是相同的。

文档指出 ReST API 查询参数映射到 routeParams 中的属性,因此我预计离开 属性 应该会产生影响。有谁知道情况是否如此?

编辑: 更新以包含工作示例,以防有人偶然发现:

let queryDateString = queryDate.format('YYYY-MM-DDTHH:mm:ss');
let onResult = result => {

      let center = new H.geo.Point(
        result.response.center.latitude,
        result.response.center.longitude
      )

      let isolineCoords = result.response.isoline[0].component[0].shape;
      let linestring = new H.geo.LineString();
      let isolinePolygon;
      let isolineCenter;

      // Add the returned isoline coordinates to a linestring:
      isolineCoords.forEach(function(coords) {
        linestring.pushLatLngAlt.apply(linestring, coords.split(','));
      });

      // Create a polygon and a marker representing the isoline:
      isolinePolygon = new H.map.Polygon(linestring);
      isolineCenter = new H.map.Marker(center);
      //let isolineObj = [isolineCenter, isolinePolygon];
      // Add the polygon and marker to the map:
      this.markerGroup.addObject(isolineCenter);
      this.polylineGroup.addObject(isolinePolygon);
    };

    let router = this.platform.getRoutingService();

    startLocs.forEach(loc => {

      let routingParams = {
        mode: 'fastest;car;traffic:enabled',
        start: `geo!${loc.geocode.lat},${loc.geocode.lng}`,
        range: this.maxTime * 60,
        rangetype: 'time',
        departure: queryDateString
      };
      // Call the Routing API to calculate an isoline:
      router.calculateIsoline(routingParams, onResult, function(error) {
        alert(error.message);            
      });
    });        
  }
  catch (err) {
    console.log('failed processing isochrones', err);
  }
  finally{
    this.isLoading = false;
  }

该模式缺少交通部分。请尝试添加这个 '&mode=fastest;car;traffic:enabled'。然后你也会得到例如你发送了一个不同的形状,例如10:00上午

这里有一些可视化等值线的扩展示例:

https://tcs.ext.here.com/examples/v3/isoline_routing

这对你来说可能也很有趣。