Official Content

Geocoding is the process of transforming a description of a location (such as a pair of coordinates, an address, or the name of a place) into a location on the Earth's surface.

To geocode an address or to reverse geocode a coordinate (GeoPoint), the following methods are available in the Maps external object:

  1. GeocodeAddress method
  2. ReverseGeocode method

Samples


1. Using the GeocodeAddress method (Maps external object)

&Locations = Maps.GeocodeAddress("Peatonal Sarandi, Montevideo, Uruguay")  //&Locations: collection variable of GeoPoint type
for &GeoPoint in &Locations                                                //GeoPoint: variable of GeoPoint type
   &Latitude =  &GeoPoint.Latitude
   &longitude = &GeoPoint.Longitude
   //do something with the &Latitude and &longitude variables
endfor


2. Using the ReverseGecode method (Maps external object)

&GeoPoint = GeoPoint.New(-34.8910275746741, -56.18720064473088)            //GeoPoint: variable of GeoPoint type
&CollectionChar = Maps.ReverseGeocode(&GeoPoint)  
For &Char in &CollectionChar
   &PlaceName = &Char
   //do something with the &PlaceName variable
EndFor

In this sample, the &GeoPoint variable (based on the GeoPoint data type) is loaded with the coordinates of a mall in Montevideo. After that, the ReverseGecode method is used to load the &CollectionChar variable with a list of place names that correspond to the &GeoPoint coordinates. Finally, the collection is scanned to use each place name.

Note: The Geolocation external object (deprecated) offers similar methods based on the Geolocation domain (deprecated too). Their names are GetLocation and GetAddress.

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