Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Reverse geocoding with TGeocoder error


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 6 - Last Post: Sep 3, 2017 5:57 AM Last Post By: Darrel Christen...
Darrel Christen...

Posts: 25
Registered: 12/19/07
Reverse geocoding with TGeocoder error  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 2, 2017 6:26 AM
Using Delphi 10.01 under 64-bit Windows 10 testing Android apps on an Amazon Kindle.

I've followed this online example:

http://docwiki.embarcadero.com/RADStudio/Tokyo/en/Mobile_Tutorial:_Using_Location_Sensors_(iOS_and_Android)

... though I changed a few object names, but when I get to the line trying to do the reverse geocode:

if (Assigned(Geocoder) and (not Geocoder.Geocoding)) then
Geocoder.GeocodeReverse(NewLocation);

... all I get is a generic "Geocoding failed" and a directive to "check the logs".

I've checked location services on my Kindle and they're on in general, on for my app, and on for "maps".

Q1: does anyone have any idea if the tutorial is missing something that might be causing the error, or some common causes of this error?

Q2: what logs is it referring to?

Thanks in advance...

drc :)

Darrel Christen...

Posts: 25
Registered: 12/19/07
Re: Reverse geocoding with TGeocoder error  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 2, 2017 7:15 AM   in response to: Darrel Christen... in response to: Darrel Christen...
Follow up to my own post, I checked the Geocoder object Supported and Authorized flags - Supported is True but Authorized...

if (Geocoder.Authorized <> System.Sensors.TAuthorizationType.atAuthorized) then

... is atNotSpecified.

Assuming this is my issue - what am I missing to get this flag to be set to atAuthorized?

drc :)

Dave Nottage

Posts: 1,850
Registered: 1/7/00
Re: Reverse geocoding with TGeocoder error  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 2, 2017 1:59 PM   in response to: Darrel Christen... in response to: Darrel Christen...
Darrel Christenson wrote:


Have you set the appropriate permissions, as per one of the first lines in the article?:

"Note: On Android devices, TLocationSensor requires specific Uses Permissions to be set, specifically Access coarse
location and Access fine location."

--
Dave Nottage [MVP, TeamB]
Find hints, tips and tricks at Delphi Worlds blog: http://www.delphiworlds.com
Darrel Christen...

Posts: 25
Registered: 12/19/07
Re: Reverse geocoding with TGeocoder error  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 2, 2017 4:11 PM   in response to: Dave Nottage in response to: Dave Nottage
Have you set the appropriate permissions, as per one of the first lines in the article?:

"Note: On Android devices, TLocationSensor requires specific Uses Permissions to be set, specifically Access coarse
location and Access fine location."

Yes under Project Options for Android both of those permissions are checked.

I went through the permissions list of items and checked a few others as well that sounds like they might apply.

And the TLocationSensor is working just fine - it's location change fires and I can put my hands on the latitude and longitude, it's when I call the reverse geocode method on the TGeocode object that I get the error.

drc :)

Dave Nottage

Posts: 1,850
Registered: 1/7/00
Re: Reverse geocoding with TGeocoder error  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 2, 2017 4:49 PM   in response to: Darrel Christen... in response to: Darrel Christen...
Darrel Christenson wrote:

Yes under Project Options for Android both of those permissions are checked.

I went through the permissions list of items and checked a few others as well that sounds like they might apply.

And the TLocationSensor is working just fine - it's location change fires and I can put my hands on the latitude and
longitude, it's when I call the reverse geocode method on the TGeocode object that I get the error.

I created a new project in Tokyo, using the following code:

unit Unit1;
 
interface
 
uses
  System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
  FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs,
  System.Sensors, FMX.Controls.Presentation, FMX.StdCtrls, FMX.Layouts;
 
type
  TForm1 = class(TForm)
    BottomLayout: TLayout;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    FGeocoder: TGeocoder;
    procedure GeocoderGeocodeReverseHandler(const Address: TCivicAddress);
  public
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
  end;
 
var
  Form1: TForm1;
 
implementation
 
{$R *.fmx}
 
const
  // A favourite haunt of mine when I was living in Melbourne
  cGeorgeHotel: TLocationCoord2D = (
    Latitude: -37.8327;
    Longitude: 144.9579
  );
 
constructor TForm1.Create(AOwner: TComponent);
begin
  inherited;
  if TGeocoder.Current <> nil then
  begin
    FGeocoder := TGeocoder.Current.Create;
    FGeocoder.OnGeocodeReverse := GeocoderGeocodeReverseHandler;
  end;
end;
 
destructor TForm1.Destroy;
begin
  FGeocoder.Free;
  inherited;
end;
 
procedure TForm1.GeocoderGeocodeReverseHandler(const Address: TCivicAddress);
begin
  Sleep(0);
end;
 
procedure TForm1.Button1Click(Sender: TObject);
begin
  if FGeocoder <> nil then
    FGeocoder.GeocodeReverse(cGeorgeHotel);
end;


Worked OK for me on my Nexus 5X (Android 7.1.2). Which version of Delphi do you have, and what device and version of
Android?

--
Dave Nottage [MVP, TeamB]
Find hints, tips and tricks at Delphi Worlds blog: http://www.delphiworlds.com
Darrel Christen...

Posts: 25
Registered: 12/19/07
Re: Reverse geocoding with TGeocoder error  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 3, 2017 5:57 AM   in response to: Dave Nottage in response to: Dave Nottage
Worked OK for me on my Nexus 5X (Android 7.1.2). Which version of Delphi do you have, and what device and version of
Android?

As per the original post it Delphi 10.01 and I'm usuing my 4th Gen Amazon Kindle 8.9 HDX.

I believe under the hood the Android version is 4.4.2 possibly 5.1.

I'll try your simple example sometime after the holiday weekend.

drc :)

Markus Humm

Posts: 5,113
Registered: 11/9/03
Re: Reverse geocoding with TGeocoder error  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 3, 2017 1:22 AM   in response to: Darrel Christen... in response to: Darrel Christen...
Am 02.09.2017 um 15:26 schrieb Darrel Christenson:

Q2: what logs is it referring to?

Most likely logcat.
Try to find monitor.bat on your development system inside your Android
SDK installation.
Run it to get access to that log while your device is connected to the
PC in debug mode. Starting monitor.bat takes a bit of time.

Greetings

Markus
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02