Official Content

This article explains how to calculate and show the route between Locations in Native Mobile applications (in other words, how to use the Directions Layer).

There are two ways to achieve it. Both involve working with a Grid with its Control Type property = Maps (in a Panel object): 

  1. Configuring the Directions Layer property of the Grid
  2. Using methods provided by the Maps external object

Scope

Controls: Grid (Control Type: Maps)
Generators: Android, Apple

Description

1. Configuring the Directions Layer property

In a Panel Grid control with its Control Type property = Maps, it is possible to view the best way between one or more locations (GeoPoints) using the Directions Layer property.

When setting the Directions Layer property to True, it is possible to draw the route between the points of the Grid. Each point or position in the Grid will be given by the attribute or variable indicated in the Location Attribute property.

 SDLayer2Direction

In addition, when setting the Directions Layer property to True, two more properties are enabled to be configured: Transport Type property and Default Route Class property.
For more information, please refer to Directions Layer property.

2. Using methods provided by the Maps external object

In certain cases, you don't want to draw the route beforehand because you don't have the Locations in advance, but you need them available on the spot.

To show the route between Locations, the Maps external object provides the following:

  • DirectionsCalculated event: It returns the direction between two GeoPoints after calling the method CalculateDirections.

Sample

Event Maps.DirectionsCalculated(&routes, &messages) // &routes is a collection variable of the Route Structure Data Type.
    composite
         if &messages.Count = 0 
           &i = 1
           do While &routes.Count >= &i 
             &geoline = &Routes.Item(&i).geoline
             Grid1.DrawGeoLine(&geoline,"8")
             &i+=1
           enddo
        endif
    endcomposite
endevent 

To draw on a map the direction between two or more locations obtained with the Maps external object, there is a set of methods available to be used in Grids with their Control Type property = Maps.

Showcase

GeoCity: In this Knowledge Base, you can find the "Pruning" section, where the "RecoleccionPodas" (Pruning Collection) Panel object uses Directions.

See Also

Layers in Maps

Last update: June 2025 | © GeneXus. All rights reserved. GeneXus Powered by Globant