TdxMapControlAzureMapRouteProvider.CreateQueryParams Method
In This Article
Creates an information container required to send a query to an Azure Maps server.
#Declaration
Delphi
function CreateQueryParams: IdxAzureMapRouteQueryParams;
#Returns
Type | Description |
---|---|
Idx |
Stores Azure Maps Route query parameters. |
#Remarks
Call the CreateQueryParams
function to create and configure server query parameters before an Execute or ExecuteAsync procedure call.
#Asynchronous Queries and Server Responses
To receive and process a response from an Azure Maps server after an ExecuteAsync procedure call, handle the OnResponse event.
#Code Example: Draw a Map Route
The following code example uses a configured information provider to draw a route between two specified points on a map:
uses
dxAzureMapInformationProviders, // Declares TdxMapControlAzureMapRouteProvider
dxCoreGraphics; // Declares TdxAlphaColors
// ...
procedure TMyForm.DrawMapRoute(ARouteStart, ARouteEnd: TdxMapControlGeoPoint);
var
APolyline: TdxMapPolyline;
ARoute: TdxAzureMapRouteItem;
AParams: IdxAzureMapRouteQueryParams;
AResponse: TdxAzureMapRouteRequestResponse;
ARouteWaypoints: TdxMapControlGeoPoints;
I, J: Integer;
begin
AParams := dxMapControl1AzureMapRouteProvider1.CreateQueryParams;
SetLength(ARouteWaypoints, 2);
ARouteWaypoints[0] := ARouteStart;
ARouteWaypoints[1] := ARouteEnd;
AParams.WayPoints := ARouteWaypoints;
AParams.TravelMode := TdxAzureMapRouteTravelMode.Car;
AParams.MaxAlternatives := 1;
dxMapControl1AzureMapRouteProvider1.Execute(AParams, AResponse);
dxMapControl1.BeginUpdate; // Initiates the following batch change
try
if AResponse <> nil then
begin
if AResponse.IsSuccess then // Draws a route if a valid server response is received
begin
APolyline := dxMapControl1ItemLayer1.AddItem(TdxMapPolyline) as TdxMapPolyline;
ARoute := AResponse.Routes.Items[0]; // Selects the first returned route
for I := 0 to ARoute.Legs.Count - 1 do
for J := 0 to ARoute.Legs.Items[I].Points.Count - 1 do
APolyline.GeoPoints.Add.GeoPoint := ARoute.Legs.Items[I].Points.Items[J];
APolyline.Style.BorderWidth := 4;
APolyline.Style.BorderColor := TdxAlphaColors.DarkBlue;
end;
end;
finally
dxMapControl1.EndUpdate; // Calls EndUpdate regardless of the batch operation's success
end;
end;
See Also