GetGeocoding in C++

In a TMS FNC Maps VCL demo I found Delphi code like this ...

procedure TSearchCoordForm.SearchButtonClick(Sender: TObject);
begin
  GeoCoding.GetGeocoding( _OrtsnameEdit.Text ,
    procedure( const ARequest: TTMSFNCGeocodingRequest; const ARequestResult: TTMSFNCCloudBaseRequestResult )
      begin
        ...
      end );
end;

What is the same code in C++?

Best regards, Dirk

At this time samples are only provided in Delphi code.
Unfortunately we are unable to provide C++ samples.

It is recommended to use the OnGetGeocoding event instead for C++.

Example:

procedure TForm1.Button1Click(Sender: TObject);
begin
  TMSFNCGeocoding1.GetGeocoding(Address.Text);
end;

procedure TForm1.TMSFNCGeocoding1GetGeocoding(Sender: TObject;
  const ARequest: TTMSFNCGeocodingRequest;
  const ARequestResult: TTMSFNCCloudBaseRequestResult);
begin
  ...
end;

Hi Bart,

thank you for your answer. In a short test it worked like that. It is much easier than the Delphi code in the demo.

Another question about this ...

You used OnGetGeocoding and there is another called OnGetGeocodingResult.
What is the difference between both functions?

Regards, Dirk

Hi Dirk,

There's actually not much difference between the two:

  • OnGetGeocoding is triggered when GetGeocoding is used and will return both the result of the request and request information itself.
  • OnGetGeocodingResult is triggered when GetGeocodingResult is used and will only return the result of the request.

You can use the one you prefer as the request result will be the same.

GetGeocoding and OnGetGeocoding is working fine so far in C++.

Additional questions:

Is there a way to get the results in my language (German and software is multi-language)?
Now I am searching for "Moskau" and getting "Москва", searching vor "Mailand" and getting "Milano", searching for "Peking" and getting "北京市" ... always local name of city.
I am using Service "gsOpenStreetMap".

Same question for TTMSFNCMaps about localization. Here I can set Options/Locale to "de-DE" (in object inspector), but couldn't get a difference naming of cities.
Here Service = msOpenLayers.

Regards, Dirk

  • You can change the results language in the GetGeocoding call by specifying the desired locale in the ALocale parameter.
    Example:
    TMSFNCGeocoding1.GetGeocoding(Edit1.Text, nil, '', nil, 'de-DE');

  • You can indeed set the map language using the Options.Locale property. The supported languages, however, depend on the mapping service in use. Unfortunately OpenLayers does not provide locale configuration, but for example both Here and Google do offer support for language settings.

Thanks for the quick reply.
It's working.

Regards, Dirk

Happy to help!