Hint: Many Google API services are still free, but now require a valid key. To do so, you need to register as a developer at Google and unlock the corresponding API.
Example: Define and check areas on a map
In this example we want to check if an address given by the user is within a certain area. This area, which could be a delivery area or area of responsibility, for example, is defined by a list of geocoordinates.
First step: Define areas
In any case, the Google API needs a list of geocoordinates that encloses an area (polygon).
Second step: The GuiXT Scripts
// Needed so SAP GUI uses Internet Explorer 11
InputField (16,4) "Check Address" (16,24) _
Pushbutton (16,65) "GO" "?" process="check_google_address.txt"
InputField (17,4) "Result" (17,24) size=40 name="google_contains_text" -readonly
CallJS codeAddress "&U[AD]"
Set V[count] 1
if not V[google_completed]
set V[count] "&V[count]" + 1
Message "E: Google failed" -statusline
The idea here is that the InputScript loops for a while so the Google API can execute the request, which is sometimes faster and sometimes slower, depending, for example, on the Internet connection, server load and so on.
The use of external libraries and web services can enhance SAP screens with various functions. However, communication with the corresponding services is somewhat tricky due to the HTTP protocol and the often asynchronous processing.
It is recommended to test the functions in an HTML page first. In this case you can use the file google_geometry.html, for example, to visualize an area and test the Google API.