Official Content

The CalculateDirections method offered by the Maps external object allows getting Directions between two points.



sourceLocation GeoPoint The source location for the route.
destinationLocation GeoPoint The destination location for the route.
transportType TransportType  The transport type to use when calculating the route. It is based on the TransportType Enumerated Domain. The possible values are: Walking, Driving, Bicycling, and Transit.
requestAlternateRoutes Boolean Whether the service will serve multiple alternative routes.

When you call the CalculateDirections method from a Procedure object, it returns a Directions Structured Data Type (SDT) object:


On the other hand, when you call the CalculateDirection method from a Panel object, the behavior is asynchronous. That is to say, you call the method and it doesn't return anything; however, after a few seconds, the DirectionCalculate event is automatically invoked and it receives the Directions SDT as a parameter. So, in this event, you have to define what you want to do with the SDT content.


Direction = Maps.CalculateDirections(GeoPoint, GeoPoint, TransportType, Boolean)


&directionsMaps = Maps.CalculateDirections(Geopoint.fromwkt("POINT (-56.1983300 -34.9064600)"), Geopoint.fromwkt("POINT (-56.2066700 -34.9101100)"), TransportType.Driving,false)

It returns a Direction Route. The serialization Json of this Route should be something like this:

{"Routes":[{"name":"Plaza Independencia",
          "geoline":"LINESTRING (-56.19833 -34.90642, -56.19874 -34.90645, -56.19874 -34.90645, -56.19877 -34.90621, -56.19878 -34.90617, -56.1988 -34.90612, -56.19881 -34.9061,... ,-56.20671 -34.91003)"

Another use case

Since GeneXus 17 upgrade 4, the CalculateDirections method can be used with a parameter (shown as DirectionsParameters) based on the DirectionsRequestParameters SDT (it allows using waypoints).



&iniGeoPoint.FromString("POINT(-56.134953860299575 -34.901402497181124)") 
&FinGeoPoint.FromString("POINT(-56.146807789135565 -34.88463356035207)")   
&wayPoint1.FromString("POINT(-56.163740158081055 -34.92478600243492)")

&directionsrequestparameter.sourceLocation = &iniGeoPoint
&directionsrequestparameter.destinationLocation = &FinGeoPoint

&directions = Maps.CalculateDirections(&directionsrequestparameter)


This method is available since GeneXus 16 upgrade 6.

Last update: November 2023 | © GeneXus. All rights reserved. GeneXus Powered by Globant