7 Replies Latest reply on Jan 31, 2012 11:25 AM by mgores

    Integrating Geolocation services into Filemaker Go

    ahcho

      Title

      Integrating Geolocation services into Filemaker Go

      Post

      Hello!

      I am trying to create a form for FileMaker Go that records the location of the user. I am using the solution from HERE:

      Now, I've downloaded the test application and ported one of the scripts to my project. There are 4 scripts (onOpen, get location, send location, view on map) and I've only ported over the "get location" script as that's the only one that I believe I need.

      Now, my application doesn't work and only returns "unknowns" for the lat, long and accuracy fields so that probably means that the call to the web object isn't returning any data or the call isn't even made. I've tried the demo by itself and it works so I'm a little lost with what could be wrong with the script.

      Can anybody help tell me what's wrong with this script?

      I've changed all the field names that are relevant to my application and added the extra fields that the demo uses. Here is the script (The items that are Bold are things that I've updated for my application):

      ------------------------------------------

      Go to Layout [ “Install” (Install) ]

      Freeze Window
      #
      New Record/Request

      Commit Records/Requests

      #

      Set Web Viewer [ Object Name: "web"; Action: Reset ] Pause/Resume Script [ Duration (seconds): .5 ]
      #
      Set Variable [ $i; Value:0 ]

      Loop

      Set Variable [ $i; Value:$i + 1 ]

      Pause/Resume Script [ Duration (seconds): .5 ]

      Set Variable [ $html; Value:GetLayoutObjectAttribute ( "web" ; "content" ) ]

      Exit Loop If [ $i > 10 or ( not IsEmpty ( $html ) and PatternCount ( $html ; "Location unknown" ) = 0 ) ]

      End Loop
      Set Field [ Install::result; $html ]

      Commit Records/Requests

      #
      #
      If [ PatternCount ( $html ; "<div id=\"messageArea\"><p>Latitude" ) = 0 ]

      Set Field [ Install::longitude; "unknown" ]

      Set Field [ Install::latitude; "unknown" ]

      Set Field [ Install::accuracy; "unknown" ]

      Exit Script [ ] End If

      #

      Set Field [ Install::latitude; Let ( [

      html = $html ;
      startTag = "<div id=\"messageArea\"><p>Latitude: " ;
      startP = Position ( html ; startTag ; 1 ; 1 ) + Length ( startTag );
      endP = Position ( html ; "</p><p>Longitude: " ; 1 ; 1 ) ;
      string =Substitute ( Middle ( html ; startP ; endP - startP ) ; "</a>" ; "" ) ; gt = Position ( string ; ">" ; Length (string) ; -1 )];

      If ( Left ( string ; 1 ) = "-" ; "-" ) & Abs(Right (string;Length(string)-gt))

      )]

      Set Field [ Install::longitude; Let ( [

      html = $html ;
      startTag = "</p><p>Longitude: " ;
      startP = Position ( html ; startTag ; 1 ; 1 ) + Length ( startTag );
      endP = Position ( html ; "</p><p>Accuracy: " ; 1 ; 1 ) ;
      string =Substitute ( Middle ( html ; startP ; endP - startP ) ; "</a>" ; "" ) ; gt = Position ( string ; ">" ; Length (string) ; -1 )];

      If ( Left ( string ; 1 ) = "-" ; "-" ) & Abs(Right (string;Length(string)-gt))

      )]

      Set Field [ Install::accuracy; Let ( [

      html = $html ;

      startTag = "</p><p>Accuracy: " ;

      startStr1 = Position ( html ; startTag ; 1 ; 1 ) + Length ( startTag ) - 1; str1 = Right ( html ; Length ( html ) - startStr1 ) ;
      lt = Position ( str1 ; "<" ; 1 ; 1 )
      ];

      Left ( str1 ; lt-1 )

      )] 

      Commit Records/Requests 

      ------------------------------------------