ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage functions / Communication / Google functions / Managing Google Maps
  • Possible error cases:
  • Key for the Google Maps service
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
Retrieves the coordinates (latitude/longitude) of an address. This function is using the Google Maps service.
Example
MyGoogleKey is string
MyGoogleKey = "Google key example"
ParisLoc is gglCoordinate
ParisLoc = GglAddressToCoordinates(MyGoogleKey, "Paris, France")
HomeLoc is gglCoordinate
HomeLoc = GglAddressToCoordinates(MyGoogleKey, "3 rue Puech Villa, 34197 Montpellier")
MyGoogleKey is string
MyGoogleKey = "Google key example"
 
// Display a map from a physical address
MyZoom is int = 12
gglParameters is gglMapParameter
Latitude, Longitude are reals
Location is gglCoordinate
M1 is gglMarker
 
// Retrieve the longitude and latitude of a physical address
Location = GglAddressToCoordinates(MyGoogleKey, "3 rue Puech Villa 34000 Montpellier")
Latitude = Location.Latitude
Longitude = Location.Longitude
 
// Create the marker for this address
M1.Latitude = Latitude
M1.Longitude = Longitude
M1.Color = 0x0000FF
M1.Size = gglSmall
Add(gglParameters.Marker, M1)
 
// Display the address in an Image control
IMG_MAP = GglGetStaticMap(MyGoogleKey, Latitude, Longitude, Zoom, IMG_MAP.Width, ...
IMG_MAP.Height, gglRoadmap, gglParameters)
Syntax

Retrieving the address of a location while specifying the Google key Hide the details

<Result> = GglAddressToCoordinates(<Google key> , <Location>)
<Result>: gglCoordinate variable
gglCoordinate variable containing the latitude and longitude of the requested address.
<Google key>: Character string
Authentication key for the Google Maps service. This key is supplied by Google.
<Location>: Character string
Requested location (city name, country, full address, ...).
This syntax is obsolete since June 11th 2018. From now on, as the Google license has evolved, only the syntax using the Google key must be used.

Retrieving the address of a location Hide the details

<Result> = GglAddressToCoordinates(<Location>)
<Result>: gglCoordinate variable
gglCoordinate variable containing the latitude and longitude of the requested address.
<Location>: Character string
Requested location (city name, country, full address, ...).
Remarks

Possible error cases:

  • The Internet connection is not valid.
  • The server returns an error because the coordinates cannot be found.
To find out whether an error occurred, use the ErrorOccurred variable.

Key for the Google Maps service

To get the key required for using the Google Maps service, connect to the Google API console: use the following address: https://developers.google.com/console.
In the console:
  1. Click "Create a project" if necessary. Give the name of your project. An identifier is automatically proposed for your project. Validate. The project is created.
  2. In the menu on the left, click "API and authentication" then "API".
  3. Choose the services required by the application: "Geocoding API" and "Places API".
  4. In the menu on the left, click "Identifiers".
  5. Then, click the "Create a key" button.
  6. Then, click "Server key".
  7. Finally, click the "Create" button.
  8. The key is created and can be used in GglAddressToCoordinates.
Business / UI classification: Business Logic
Component: wd290ggl.dll
Minimum version required
  • Version 14
This page is also available for…
Comments
Exemplo Ws_EnderecoReturnLatLong
PROCEDURE Ws_EnderecoReturnLatLong(sEndereco is string)

bufPersonalJson is Variant

//Chave API Key Paga o valor de uso pelo console do developer Google Billing
//##########################################################################
ApiGoogle is string = "AIzaSyANvbs5GSl_wQBDdz6l93CcmcL6Nk8_GXU"
//##########################################################################

ChangeCharset(charsetOccidental)

sUrl is string = "https://maps.googleapis.com/maps/api/geocode/json?address="+sEndereco+"&key="+ApiGoogle

ok is boolean = HTTPRequest(sUrl)

bufPersonalJson = HTTPGetResult()

bufPersonalJson = JSONToVariant(bufPersonalJson)

arrMyAddress is array of ANSI string

IF bufPersonalJson.STATUS = "OK"

Add(arrMyAddress,bufPersonalJson.results[1].geometry.location.lat..Value)

Add(arrMyAddress,bufPersonalJson.results[1].geometry.location.lng..Value)

END

RESULT arrMyAddress
BOLLER
03 Dec. 2018

Last update: 05/26/2022

Send a report | Local help