Retrieve more data with GooglePlaces (only description has value)

Hi,
I am trying to use the TTMSFNCGooglePlaces component. The result set has items with properties like city, street, website etc, but I only see values for description and longitude,latitude.
All the other proporties like postalcode, street, city etc... are empty.

code snippet:

procedure Tframe_Adres.googlePLacesGetAutoCompleteResult(Sender: TObject;
const AResult: TTMSFNCPlacesRequest);
begin
leesResultaat(AResult) ;
end;

procedure Tframe_Adres.leesResultaat( AResult: TTMSFNCPlacesRequest );
var
n: integer ;
begin

for n:= 0 to AResult.Items.Count -1 do

info(format( '%s : [%s;%s], url:%s, city:%s, ID:%s ',
[
AResult.Items[n].Description,
AResult.Items[n].Coordinate.Longitude.ToString,
AResult.Items[n].Coordinate.Latitude.ToString,
AResult.Items[n].Website,
AResult.Items[n].City,
AResult.Items[n].ID
]
)
);

Am I missing something?

Or is the only way to retrieve the adres using geocoding with longitude.latitude áfter selecting an item. based on description?

kind regards,

Dirk Janssens.

I tried to use the coordinates to get the adres (GetReverseGeocoding), but the coordinates are not correct. Whatever Item I choose, the coordinates point to NewYork:

Amsterdam Centraal railway station, Stationsplein, Amsterdam, Netherlands : [-74,044502;40,689247], url:, city:, ID:

Amsterdam-Zuid, Amsterdam, Netherlands : [-74,044502;40,689247], url:, city:, ID:

Amstelveen, Netherlands : [-74,044502;40,689247], url:, city:, ID:

Hi,

We are not aware of any issues with GetReverseGeocoding.
Can you please provide the following information so I can further investigate this?

  • Which service are you using to do the geocoding?
  • Are you using the OnGetReverseGeocoding event?
  • A code sample that demonstrates the issue

Hi Bart,

Please read the first post. The problem is not about reverse geocoding.
The problem is, that I try to use the TTMSFNCGooglePlaces to autocomplete adresses. In that component, the coördinates are always the same.
regards,

Dirk Janssens.

Sorry for the confusion.
Please note that the GetAutoComplete call only returns a list of items with a description.
The coordinates are not returned with the GetAutoComplete call and are initialized with a default value.
Unfortunately this is a limitation of the Google service.

To get the coordinates for a specific place, an extra request to the Google Places API is required for each place you require the coordinates for.

The required call is GetPlaceDetail. Unfortuntately this call is currently only compatible with results from the SearchByText and SearchNearby calls, not with results from the GetAutoComplete call.

However the necessary changes to make the GetPlaceDetail call compatible with GetAutoComplete results have been implemented. And this feature will be available with the next TMS FNC Maps release.

You'll be able to use the following code with the next TMS FNC Maps release to retrieve coordinates for an item retrieved with GetAutoComplete:

procedure TForm1.FormCreate(Sender: TObject);
begin
  TMSFNCGooglePlaces1.GetAutoComplete('Amsterdam Centraal railway station');
end;

procedure TForm1.TMSFNCGooglePlaces1GetAutoComplete(Sender: TObject;
  const ARequest: TTMSFNCPlacesRequest;
  const ARequestResult: TTMSFNCCloudBaseRequestResult);
begin
  Memo1.Text := '';
  if ARequest.Items.Count > 0 then
  begin
     TMSFNCGooglePlaces1.GetPlaceDetail(ARequest.Items[0]);
  end;
end;

procedure TForm1.TMSFNCGooglePlaces1GetPlaceDetail(Sender: TObject;
  const ARequest: TTMSFNCPlacesRequest;
  const ARequestResult: TTMSFNCCloudBaseRequestResult);
var
  lat, lon: Double;
begin
  if ARequest.Items.Count > 0 then
  begin
    lat := ARequest.Items[0].Coordinate.Latitude;
    lon := ARequest.Items[0].Coordinate.Longitude;
  end;
end;