【问题标题】:Would like change Marker icon to little circles想将标记图标更改为小圆圈
【发布时间】:2016-12-06 20:13:21
【问题描述】:

在我的 Delphi 应用程序中,我第一次使用 GMlib,我成功地显示了一张带有航线和所有标记的地图。 我使用了 GMMap、GMMarker、GMPolyline 组件

但是我想用小红色圆圈(3-4 像素半径)替换普通标记图标。 这是我用来绘制地图和路线的代码:

procedure TfrmWebBrowser.PlotMap;
var
  aList1,
  aList2: TstringList;
  dLatitude,
  dLatitude1,
  dLatD,
  dLonD,
  dLongitude,
  dLongitude1: Single;
  i: Integer;
  Poly: TPolyline;
  begin
    Poly:= TPolyline(GMPolyline1.Add);
    Poly.StrokeColor:= clRed;
    Poly.StrokeWeight:= 1;
    aList1:= TstringList.Create;
    aList1.StrictDelimiter:= True;
    aList1.Delimiter:= ';';
    aList2:= TstringList.Create;
    aList2.StrictDelimiter:= True;
    aList2.Delimiter:= ';';
    GMMarker1.Clear;
    for i := 0  to GstlMapPoints.Count-1 do
    begin
      aList1.DelimitedText:= GstlMapPoints.Strings[i];
      if i > 0 then
      begin
        aList2.DelimitedText:= GstlMapPoints.Strings[i - 1];
        dLatitude:= StrToFloat(aList2[0]);
        dLatitude1:= StrToFloat(aList1[0]);
        dLongitude:= StrToFloat(aList2[1]);
        dLongitude1:= StrToFloat(aList1[1]);
        Poly.AddLinePoint(dLatitude,dLongitude);
        Poly.AddLinePoint(dLatitude1,dLongitude1);
        Poly.Geodesic:= True;
      end
      else
      begin
        dLatD:= StrToFloat(aList1[0]);
        dLonD:= StrToFloat(aList1[1]);
      end;
    dLatitude:= StrToFloat(aList1[0]);
    dLongitude:= StrToFloat(aList1[1]);
    GMMarker1.Add(dLatitude, dLongitude, aList1[2]);
  end;
  GMMarker1.ZoomToPoints;
  aList1.Free;
  aList2.Free;
end; 

你会帮我这样做吗? 谢谢 皮埃尔

【问题讨论】:

    标签: delphi gmlib


    【解决方案1】:

    TGMMarker 类的 Add 方法返回一个 TMarker 对象。该对象有一个 Icon 属性来设置要显示的图像

    var
      Marker: TMarker
    begin
      .....
      Marker := GMMarker1.Add(dLatitude, dLongitude, aList1[2]);
      Marker.Icon := 'http://www.cadetill.com/imagenes/gallery/gmlib/marker.png'
      .....
    

    图片必须在网络上或本地电脑上

    【讨论】:

    • 非常感谢它工作正常。也感谢您提供了很棒的 GMlib。
    猜你喜欢
    • 2022-08-15
    • 1970-01-01
    • 2023-03-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多