With the latest beta of HCL Nomad and the beta 2 of Notes/Domino 11 you are now able to use GPS functions in your Notes apps. This might be interesting for apps that users will use exclusively on their mobile devices to track where they were when the document was created. I think of all kinds of service apps that document e.g. damages on vehicles or track the location of parts during a process. The missing link now is the possibility to scan bar codes with the camera and then have the content also available as a string - that would solve so many problems.
LotusScript only
But for now we can enjoy GPS - but only in LotusScript. Some may think: why LS only? I would like to use it in Java or Javascript, too. The reason is obvious: there is no Java available on the mobile apps especially on iOS. Using it with Javascript would need an XPage to execute it (same with Java beans or native classes) - XPages are not supported in Nomad of course.
The implementation of the GPS stuff is quite straight forward:
- NotesGPS is the entry class, derived from NotesSession
- NotesGPSPosition is the collector class that contains several properties e.g. timeout settings and a method to obtain the real position
- NotesGPSCoordinates is returned by NotesGPSPosition via the method GetCurrentPosition
- The coordinates are read with the NotesGPSCoordinates properties for Latitude and Longitude. Both values are Double values
Nomad only
Interestingly all this also does not work in the Notes client on the desktop though every computer should be able to provide basic geo location data. For example Google maps also uses this data (from the browser) to get your current location, and though this may be not an option for Notes, there is an API built in the operating systems, too. Anyway, you cannot use this on the desktop, and even worse: you have to catch the error that will occur once you try it. The error number is 4508, so a proper onError statement will do.
I put up some sample code:
Public Function getCoordinates() As String
On Error GoTo errhandler
On Error 4508 GoTo err4508
Dim session As New NotesSession
Dim GPS As NOTESGPS
Set GPS = session.Creategps()
Dim hasAccess As Boolean
hasAccess = GPS.Requestaccess()
If hasAccess Then
Dim pos As NOTESGPSPOSITION
Set pos = GPS.Getcurrentposition()
Dim coo As NOTESGPSCOORDINATES
Set coo = pos.Coordinates
Dim lat As Double
Dim lot As Double
lat = coo.Latitude
lot = coo.Longitude
End If
getCoordinates = "Coordinates: LAT " & lat & " LONG " & lot
Exit Function
errhandler:
MsgBox Error$ & " in " & Erl & " - " & Err
Exit Function
err4508:
getCoordinates = ""
Exit function
End Function
You can use this e.g. in a form to fill a simple text field with the return value:
Sub Postrecalc(Source As Notesuidocument)
Dim gps As New gps
Dim s As String
s = gps.getCoordinates()
If s <> "" Then
Call source.FieldSetText("gps", s)
End If
End Sub
When you use this code for the first time the OS will ask you if the app "Nomad" is allowed to access your location. Depending on the OS you have different options. In my case on iOS you can select between "Everytime the app is running", "Just once" and "Nope, go away" (something like that).
I am not sure if this question will popup again with a different Notes app used in Nomad - maybe you can answer this question in the comments 