Route between two location here map

时间:2019-01-09 21:50:31

标签: javascript html

I could not put the coordinates of address 1 and 2 in waypoint0 and waypoint1

//address1 and address2 with the same methode :

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);
  }
};

route

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 个答案:

没有答案