Web forum is in read-only mode. Login as active registered customer for write access
  Forum Search   New Posts New Posts

TMSFMXWebGMapsReverseGeocoding android sensor

 Post Reply Post Reply
Author
Camacho Chacon Hilda View Drop Down
Member
Member
Avatar

Joined: 03 Sep 2014
Posts: 59
Post Options Post Options   Quote Camacho Chacon Hilda Quote  Post ReplyReply Direct Link To This Post Topic: TMSFMXWebGMapsReverseGeocoding android sensor
    Posted: 26 Sep 2016 at 6:02pm
Hi guys , when i use the code below and I invoke   TMSFMXWebGMapsReverseGeocoding1.LaunchReverseGeocoding with andorind

  procedure TForm1.LocationSensor1LocationChanged(Sender: TObject;
    const OldLocation, NewLocation: TLocationCoord2D);
  var
    LDecSeparator: String;
  begin
    try
      LDecSeparator := FormatSettings.DecimalSeparator;
      FormatSettings.DecimalSeparator := '.';
      if FCurrentPosition.Distance(NewLocation) > Accuracy then
      begin
        FCurrentPosition := NewLocation;

        latmap := NewLocation.Latitude;
        Longmap := NewLocation.Longitude;

        if ((latmap >= -90) and (latmap <= 90)) and
          ((Longmap >= -180) and (Longmap <= 180)) then
        begin
          cp := '0';
          try

            TMSFMXWebGMapsReverseGeocoding1.Latitude := latmap;
            TMSFMXWebGMapsReverseGeocoding1.Longitude := Longmap;
            TMSFMXWebGMapsReverseGeocoding1.LaunchReverseGeocoding;   <------
            cp := (TMSFMXWebGMapsReverseGeocoding1.ResultAddress.PostalCode);

          except
            cp := '0';
          end;
        end
        else
          showmessage('GPS error, location not found');
      end;
    finally
      LocationSensor1.Active := False;
    end;
  end;

 I get the next error



  procedure TForm1.LocationSensor1LocationChanged(Sender: TObject;
    const OldLocation, NewLocation: TLocationCoord2D);
  var
    LDecSeparator: String;
  begin
    try
      LDecSeparator := FormatSettings.DecimalSeparator;
      FormatSettings.DecimalSeparator := '.';
      if FCurrentPosition.Distance(NewLocation) > Accuracy then
      begin
        FCurrentPosition := NewLocation;

        latmap := NewLocation.Latitude;
        Longmap := NewLocation.Longitude;

        if ((latmap >= -90) and (latmap <= 90)) and
          ((Longmap >= -180) and (Longmap <= 180)) then
        begin
          cp := '0';
          try

            TMSFMXWebGMapsReverseGeocoding1.Latitude := latmap;
            TMSFMXWebGMapsReverseGeocoding1.Longitude := Longmap;
            TMSFMXWebGMapsReverseGeocoding1.LaunchReverseGeocoding;
            cp := (TMSFMXWebGMapsReverseGeocoding1.ResultAddress.PostalCode);

          except
            cp := '0';
          end;
        end
        else
          showmessage('GPS error, location not found');
      end;
    finally
      LocationSensor1.Active := False;
    end;
  end;



can I help you?
Back to Top
Camacho Chacon Hilda View Drop Down
Member
Member
Avatar

Joined: 03 Sep 2014
Posts: 59
Post Options Post Options   Quote Camacho Chacon Hilda Quote  Post ReplyReply Direct Link To This Post Posted: 26 Sep 2016 at 6:02pm
Back to Top
Camacho Chacon Hilda View Drop Down
Member
Member
Avatar

Joined: 03 Sep 2014
Posts: 59
Post Options Post Options   Quote Camacho Chacon Hilda Quote  Post ReplyReply Direct Link To This Post Posted: 26 Sep 2016 at 6:03pm
Sorry this is the error

---------------------------
Debugger Exception Notification
---------------------------
Project UBSPA.apk raised exception class EJNIException with message 'android.os.NetworkOnMainThreadException'.
---------------------------
Break   Continue   Help   
---------------------------
Back to Top
Pieter Scheldeman View Drop Down
TMS Support
TMS Support
Avatar

Joined: 18 May 2010
Posts: 3259
Post Options Post Options   Quote Pieter Scheldeman Quote  Post ReplyReply Direct Link To This Post Posted: 27 Sep 2016 at 8:43am
Hi, 

You are launching the reverse geocoding from within a different thread, please use the following code to thread queue the code and avoid the exception.

procedure TForm1.LocationSensor1LocationChanged(Sender: TObject;
  const OldLocation, NewLocation: TLocationCoord2D);
begin
  TThread.Queue(nil,
  procedure
  var
    cp: String;
  begin
    TMSFMXWebGMapsReverseGeocoding1.Latitude := NewLocation.Latitude;
    TMSFMXWebGMapsReverseGeocoding1.Longitude := NewLocation.Longitude;
    TMSFMXWebGMapsReverseGeocoding1.LaunchReverseGeocoding;
    cp := TMSFMXWebGMapsReverseGeocoding1.ResultAddress.PostalCode;
  end
  );
end;
Back to Top
camacho hilda View Drop Down
New Member
New Member
Avatar

Joined: 09 Feb 2015
Posts: 23
Post Options Post Options   Quote camacho hilda Quote  Post ReplyReply Direct Link To This Post Posted: 27 Sep 2016 at 7:41pm
Thanks , it work
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down