这是一个相当广泛的问题,但我将尝试将其范围缩小到要点。
我正在为学校项目开发Delphi应用程序,其中我想在程序中添加地图以提供位置功能。我正在使用RAD Studios 10.3

由于这是一个学校项目,如果可能的话,我不想在上面花钱,我也不想使用Google地图,因为您需要创建一个计费帐户(我知道您确实还会收到一些免费请求)。

要求:


用户可以查看动态地图并放置图钉(不需要是永久的)
正向和反向地理编码。
在VCL程序中使用


从我的研究中我了解到这一点:
我可以使用Leaflet(https://leafletjs.com/index.html)与Open Streets Maps进行交互
我将不得不将请求从我的Delphi应用程序发送到某个地方(传单?)以获取地图和geoCoding数据


我使用什么组件在vcl表单上显示地图
如何通过Leaflet与Open Street Maps互动?


(如果我能理解如何与传单等内容交互并且可以访问其文档,则以下以下问题可能是多余的)


如何从大头针请求坐标和街道地址?
如何使用GPS Coords的图钉显示地图?


先感谢您。

最佳答案

我很久以前就在Bing Maps工作。为了加载要显示的地图,我使用了Indy Project中的`TIdHTTP'。我认为它与Leaflet的工作方式相同。

这是我的代码:

const
  // Place here the key retrieved from the site Bing Maps Account Center
  Key = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
  Server = 'http://dev.virtualearth.net/REST/v1/';
  URLPicFormat = Server + 'Imagery/Map/%s/%s,%s/%d?ms=%d,%d&pp=%s,%s;6&key='
    + Key;
var
  Address, Map, LatStr, LongStr, TypeView: String;
  Response: TFileStream;
begin
  {...}
  // Don't forget to add the JPEG unit
  Map     := WindowsTempDir + 'Map.jpeg';

  // Format the URL for the picture to load
  Address := Format(URLPicFormat, [TypeView, LatStr, LongStr,
    TB_Zoom.Position, IMG_Map.Width, IMG_Map.Height, LatStr, LongStr]);

  // Load the picture from Bing Maps
  Response := TFileStream.Create(Map, fmCreate);
  try
    HTTP_BingMaps.Get(Address, Response);
  finally
    Response.Free();
  end;
  IMG_Map.Picture.LoadFromFile(Map);
  {...}
end;


您可以在这里找到法语的完整单元:
https://github.com/ILPlais/BingMapsGPS/blob/master/UBingMapsGPS.pas

07-24 09:47
查看更多