2016-11-22 82 views
1

在我的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; 

会YPU帮我做到这一点? 谢谢 Pierre

回答

2

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

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

图像必须是在网络上还是在本地PC

+0

非常感谢它工作正常。 谢谢你的真棒GMlib。 –