delphi - 想要将标记图标更改为小圆圈

标签 delphi gmlib

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

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

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; 

ypu 会帮助我做到这一点吗? 谢谢 皮埃尔

最佳答案

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'
  .....

图像必须位于网络上或本地 PC 中

关于delphi - 想要将标记图标更改为小圆圈,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40743392/

相关文章:

visual-studio - Delphi (.NET) 的最佳替代 IDE 是什么

如果按不同索引排序,Delphi 7 TClientDataSet 聚合不起作用

delphi - 将字符串从某些代码页转换为Unicode

delphi - 如何在Delphi 2007中安装Delphi Chromium Embedded?

delphi - GMLib 简单方向示例

google-maps - Delphi 的谷歌地图库突然停止工作?

google-maps - GM 方向组件为空且具有特定坐标

delphi - 从TStringsList读取Delphi访问冲突