Composant Delphi / Google Maps / OpenStreetMap / Leaflet  / Mappilary / Native Maps 100% Delphi 0% WebBrowser 0% Javascript

Road

you are here :TECMap > Overlays
The roads are managed by the list Routes Type TECMapRoutes

TECMapRoutes

This list has the following methods and properties :

function Add(const sName:string;const dStartLatitude,dStartLongitude,dEndLatitude,dEndLongitude:double;
const OptimizeWaypoints:boolean=false;const WayPoints:TLatLngList=nil):integer;

Adding a road, returns the index of the road in the list

Raises the event OnRouteChange on success otherwise OnRouteError

Name name of your road, can be empty

dStartLatitude,dStartLongitude starting point of the road

dEndLatitude, dEndLongitude endpoint of the road

OptimizeWayPoints force the calculation of the most direct route by reorganizing your crossings (has no action under CloudMade)

WayPoints list type TLatLngList of crossings.

Pass nil if you do not specify a particular crossing points

35
function AddByAdr(const sName,sStartAdress,sEndAdress:string;
const OptimizeWaypoints:boolean=false;const WayPoints:TLatLngList=nil):integer;

Adding a road, returns the index of the road in the list

Raises the event OnRouteChange on success otherwise OnRouteError

Name name of your road, can be empty

sStartAdress Address of the starting point of the road

sEndAdress Address endpoint of the road

OptimizeWayPoints force the calculation of the most direct route by reorganizing your crossings (has no action under CloudMade)

WayPoints list type TLatLngList of crossings.

Pass nil if you do not specify a particular crossing points

36

AddByAdr is not available CloudMade

15
procedure Clear;
Clears all routes
function Count:integer;
Returns the number of routes
procedure Delete(index:integer);
Clears the road index Index
procedure Undo(index:integer);
Cancels the change of direction made the mouse on the road index Index
You can undo changes in the last ten trip.

Not available CloudMade

16
function Ready:boolean;
Indicates whether you can add a route, you can not do when a road is about to be calculated.
property TravelMode: TDirectionsTravelMode
Property read / write which can select the type of route you want
property Distance : longint;
Read-only property that returns the length of all roads in meters
property Duration : longint;
Read-only property that returns the time it takes, in seconds, to make journeys.

Not available CloudMade

17
property avoidHighways : boolean;
Property read / written offering the choice of avoiding motorways or not
property avoidTolls : boolean;
Property read / written offering the choice whether to avoid toll roads
property Color : TColor;
Property read / written offering the choice to set the color of the road
property Draggable : boolean;
Property read / written that allows the mouse to change the route of the road.

With the API CloudMade you can not change the points of departure / arrival and passages

11
property Opacity : double;
Property read / written, which adjusts the percentage of opacity of the color of the road
property Weight : integer;
Property read / written which sets the size of the Roadway
property ZIndex : integer;
Property read / written, attribute a priority index for the display of the road, a road with a zIndex higher will be displayed on top of that with a lower zIndex
property MarkerOptions : TECMapMarker;

property Route[index:integer]:TECMapRoute; default;
Table for road access is the default property so you can access it directly by map.Routes [index] instead of map.Routes.Route [index]
property ToKml : string;
Read-only property that returns a string in kml format containing the list of roads
property ToTxt : string;
Property read / write which gives access to the route list in text format.

In writing there is an addition and not a replacement, if you do not want to keep the old values before making a Clear adding

37

// Delphi map component ECMap

wp := TLatLngList.create(nil);
try
// add waypoint
wp.add(43.2237336276672,0.0462043685729441);

map.Routes.Color := clGreen;

id := map.Routes.Add('my first route',
43.2328643,0.074120799999946,
43.0946324606031,-0.0254427986328665,true,
wp);

finally
wp.free;
end;

Events

OnRouteChange(sender: Tobject;const idRoute:integer;const NewRoute:boolean)

idRoute is the index of the road in the list Routes

NewRoute equal True it is an addition to road, False if a rerouting

OnRouteError(sender: Tobject;const idRoute:integer;const sError:string)

idRoute is the index of the road in the list Routes

sError explanation of the error

TECMapRoute

TECMapRoute is the class that handles a route, it gives you access to methods and properties :

function getLatLngFromMeter(const SensStartEnd:boolean;const lMeter:longint;var dLatitude,dLongitude:double;var idPoint:integer;var heading:integer;var bEnd:boolean):boolean;

Calculates the latitude and longitude of a point on the road according to its distance in meters, returns True if we found a point

SensStartEnd meaning of course, true for start -> finish

lMeter the distance in meters

dLatitude,dLongitude type variables double who will receive the latitude and longitude

idPoint a variable that will contain the index Path where is the point, the calculation returns an approximation, since your drive does not contain all the real points

The Polylines / Polygons have a single function through their property Path type TLatLngList

38

Heading a variable to hold the angle of the point from the north ( 0 to 360°)

bEnd indicates whether it has exceeded or reaches the end of the road (or early depending on the direction)

procedure fitBounds
Adjusts the zoom of the map to display all of the road
procedure Update;
Redefined the road to reflect changes made to any of the properties
procedure OptimizeWaypoints;
Rearranges the way points for their order to be optimal

Not available CloudMade

18
procedure updateOptions;
Redraw the road to reflect properties Color, Opacity, and Weight Draggable
Read-only property that returns the length of the road in meters
property Duration : longint;
Read-only property that returns the time it takes in seconds for the journey.

Not available CloudMade

19
property Path : TECMapRoutePath;
List Type TECMapRoutePath containing the road constituent points
property WayPoints : TLatLngList;
List of crossings
property Copyright : string;
The possible copyright holder for this route
property StartAdress : string;

Address of starting point, read-only

Not available CloudMade

20
property StartLatitude : double;
Property read / write from the point of Latitude
property StartLongitude : double;
Property read / write Longitude of starting point
property EndAdress : string;

Address of the destination point, readonly

Not available CloudMade

21
property EndLatitude : double;
Property read / write from the point of arrival Latitude
property endLongitude : double;
Property read / write from the point of arrival Longitude
property Name : string;
Read-only property that returns the name of the road telqu'il has been indicated to the creation
property Id : integer;
Read-only property that returns the index of the road in the list Routes
property NorthEastLatitude : double;
Read-only property that returns the latitude of the north-east corner of the area surrounding the entire road
property NorthEastLongitude : double;
Read-only property that returns the longitude of the northeast corner of the area surrounding the entire road
property SouthWestLatitude : double;
Read-only property that returns the latitude of the southwest corner of the area surrounding the entire road
property SouthWestLongitude : double;
Read-only property that returns the longitude of the southwest corner of the area surrounding the entire road
property TravelMode: TDirectionsTravelMode
Property read / write which can select the type of route you want
property avoidHighways : boolean;
Property read / written offering the choice of avoiding motorways or not
property avoidTolls : boolean;
Property read / written offering the choice whether to avoid toll roads
property Color : TColor;
Property read / written offering the choice to set the color of the road
property Draggable : boolean;
Property read / written that allows the mouse to change the route of the road.

With the API CloudMade you can not change the points of departure / arrival and passages

12
property Opacity : double;
Property read / written, which adjusts the percentage of opacity of the color of the road
property Weight : integer;
Property read / written which sets the size of the Roadway
property ZIndex : integer;
Property read / written, attribute a priority index for the display of the road, a road with a zIndex higher will be displayed on top of that with a lower zIndex
property MarkerOptions : TECMapMarker;
Property that allows you to manipulate the markers of departure and arrival by changing the icon for instance, unfortunately we can not yet differentiate.

Not available CloudMade

22
property Tag :integer;
Property read / written, you can use it freely for whatever you want stoker
property ToKml : string;
Read-only property that returns a string in kml format contains the route
property ToTxt : string;
Property read / write which gives access to the road in a text format.

In writing there is an addition and not a replacement, if you do not want to keep the old values \u200b\u200bbefore making a Clear adding

39

TECMapRoutePath

List of points on the route, it gives you access to methods and properties

function Distance:integer;
Distance in meters
function Duration:integer;
Duration in seconds
function Count:integer;
Returns the number of points constituting the road
function IndexOfLatLng(const dLatitude,dLongitude:double):integer;
Returns the index of a point we pass the latitude and longitude, -1 if no item
property Point[index:integer]:TECMapRoutePathPoint; default;
Table for access points is the default property so you can access it directly by map.Routes [idroute]. Path [idPoint] instead of map.Routes [idroute]. Path.Point [idPoint]

TECMapRoutePathPoint

Class manager point of the road, it gives you access to properties

property Altitude : double;
Read-only property that returns the height in meters from the point
property Instructions : string;
Read-only property that returns the instructions in HTML, associated with the point
property Latitude : double;
Read-only property that returns the latitude of the point
property Longitude : double;
Read-only property that returns the longitude of
property Distance : longint;
Read-only property that returns the distance in meters
property Text : string;
Read-only property that returns the instructions in text format

AddPolylineFromRoute

TECMap has a feature that allows you to add a polyline from the index of a road

// Delphi map component ECMap

// set version 3.7 for google api
map.apiVersion := '3.7';

Cela peut-être utile pour "figer" une route, en effet lors de la sauvergarde d'une route seul les points de départ et d'arrivée sont sauvés, lors de la lecture un recalcul de la route sera effectué.

Polylines can calculate batch altitude points while for the roads it must be done step by step, DemoRoute uses AddPolylineFromRoute to calculate the elevation.

Utility functions

function TECMap.GetRoutePathFrom(const dLatLngs: array of double;const params): TECMapRoutePath;

procedure TECMap.GetASyncRoutePathFrom(const dLatLngs: array of double;const params: string);

function TECMap.GetRoutePathByAdress(const StartAdress, EndAdress: string;const params: string): TECMapRoutePath;

procedure TECMap.GetAsyncRoutePathByAdress(const StartAdress, EndAdress: string;const params: string);

These four routines to get a road without made of path information, you have two asynchronous procedures that will run in the background and raise the OnRoutePath event when the data are available.

If you do not release the TECMapRoutePath obtained, it will be automatically during the destruction of TECMap

40

See open.mapquestapi.com/directions/ for the parameter Params

41

You can create a polyline from a TECMapRoutePath

// Delphi map component ECMap

// ge data road between Tarbes and Lourdes via Aureilhan
routePath := map.GetRoutePathByAdress('Tarbes','Aureilhan|Lourdes');
// draw polyline from routePath
if routePath<>nil then
begin

id := map.polylines.addFromRoutePath(routePath);
// see the entire route
map.polylines[id].fitBounds;

routePath.free;
end;
function TECMap.DistanceFrom(const LatStart, LngStart,LatEnd, LngEnd: double): double;

Returns the distance in KM between two geographical points, uses the haversine formula

function TECMap.DistanceRouteByAdress(const StartAdress, EndAdress: string;const params: string= ''): double;

Returns the distance in KM between two addresses passing by road

function TECMap.DistanceRouteFrom(const dLatLngs: array of double;const params: string = ''): double;

Returns the distance in KM between two geographic points through the road

See open.mapquestapi.com/directions/ for the parameter Params of the functions DistanceRouteXXX

42
function TECMap.AddRouteByAdress(const Adresses:TStrings):integer;

Adds a route, Adresses contains the addresses of passages.

// Delphi map component ECMap

// find the distance in km by road between Tarbes and Lourdes via Aureilhan
dKm := map.DistanceRouteByAdress('Tarbes','Aureilhan|Lourdes');

Adresses := TStringList.create;
try

Adresses.add('Tarbes');
Adresses.add('Aureilhan');
Adresses.add('Séméac');
Adresses.add('Lourdes');

// create route Tarbes/Lourdes via Aureilhan and Séméac
map.AddRouteByAdress(Adresses);

finally
Adresses.free;
end;

DemoRoute

The program DemoRoute shows you how to operate the routes
Fig. 40 DemoRoute - Instructions
Fig. 40 DemoRoute - Instructions
Fig. 41 DemoRoute - Altitudes
Fig. 41 DemoRoute - Altitudes
go to page
© 2016 ESCOT-SEP Christophe - Made width Help&Web - RSS - Google+