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
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:
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,
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;