两个标记(地址)之间的折线

时间:2019-01-12 23:12:26

标签: javascript

我无法将地址1和2的坐标放在waypoint0和waypoint1

//address1 and address2 with the same method:

var geocodingParams = {
      searchText: 'address1'
};
var onResult = function (result) {
    var locations = result.Response.View[0].Result,
        position,
        marker;
      for (i = 0; i < locations.length; i++) {
        position = {
          lat: locations[i].Location.DisplayPosition.Latitude,
          lng: locations[i].Location.DisplayPosition.Longitude
        };

        marker = new H.map.Marker(position);
        map.addObject(marker);
      }
};

路线:

function calculateRouteFromAtoB (platform) {
    var router = platform.getRoutingService(),
      routeRequestParams = {
         mode: 'fastest;truck',
         representation: 'display',
         routeattributes : 'waypoints,summary,shape,legs',
         maneuverattributes: 'direction,action',
         waypoint0: 'coords_address1' ,  
         waypoint1:  'coords_address2'
      };
      router.calculateRoute(routeRequestParams,onSuccess,onError );
}

0 个答案:

没有答案