我在Windows1064位开发机器上使用带有GMLib v3谷歌地图组件的德尔福柏林。我希望在使用GMMarker组件的LoadFromDataSet函数时,能够在单击标记或网格时对位置进行动画处理。我不知道该怎么做。
我的ERP应用程序尝试验证输入的地址,方法是对输入的地址进行地理编码,获取返回的纬度和经度,然后将这些值存储在数据库中。当地理编码返回多个值时,我会显示一个带有网格和地图的屏幕,其中显示了地理编码结果的位置。

为此,我首先将所有结果添加到一个Listview组件,然后处理每个Listview项,并为每个事件添加一个GMMarker,如下所示:
for I := 0 to ListView.Items.Count-1 do
begin
GMMarker1.Add(StrToFloat(ListView.Items[I].SubItems[2]),StrToFloat(ListView.Items[I].SubItems[1]),ListView.Items[I].Caption);
end;然后,我可以访问反弹动画方法,并在单击标记时使用GMMarker的索引来定位列表视图,如下所示:
procedure TfrmGeoCodeAdd.GMMarker1Click(Sender: TObject; LatLng: TLatLng;Index: Integer; LinkedComponent: TLinkedComponent);
begin
inherited;
if ListView.ItemIndex = Index then
HandleAnimation(Index)
else
ListView.ItemIndex := Index;
end;
procedure TfrmGeoCodeAdd.HandleAnimation(Index: integer);
begin
inherited;
if (AnimationIndex >= 0) then
begin
GMMarker1[AnimationIndex].Animation.Bounce := False;
end;
if (AnimationIndex = index) then
AnimationIndex := -1
else
begin
if GMMarker1[Index].Animation.Bounce then
GMMarker1[Index].Animation.Bounce := False
else
GMMarker1[Index].Animation.Bounce := True;
AnimationIndex := Index;
end;
end;当我将位置加载到单独的GMMarkers中时,这非常有效。然而,一旦数据库被更新,我想通过在google地图上显示某一天的所有送货位置来完成类似的事情。为此,我使用GMMarker的LoadfromDataset函数,如下所示:
GMMarker1.LoadFromDataSet(cdsDeliveries, 'Latitude', 'Longitude', 'SO_NO', 'Marker', True);
GMMarker1.ZoomToPoints;这也可以很好地工作,并生成以下映射:

我遇到的问题是,当使用LoadFromDataSet时,即使地图上有许多标记,GMMarker.Count也是1。因此,我假设我必须使用GMMarker的VisualObjects属性。但是,GMMarker.VisualObjects.Count也是1。
我的问题是:
当我使用GMMarkers.LoadFromDataset函数时,如何访问屏幕上标记的Animation.Bounce属性?
任何帮助都是非常感谢的。
伦纳德
发布于 2016-11-16 04:46:08
我解决了我的问题,但不知道为什么在问问题之前我没有尝试一下。不过,也许我的答案会对其他人有所帮助。
为了解决这个问题,我将标记从OnClick事件传递给我的HandleAnimation函数,并使用传递的参数访问动画方法,如下所示:
procedure TfrmDeliveryMap.GMMarker1Click(Sender: TObject; LatLng: TLatLng; Index: Integer; LinkedComponent: TLinkedComponent);
begin
inherited;
if cdsDeliveries.RecNo = Index then
HandleAnimation((Sender as TGMMarker), Index)
else
cdsDeliveries.RecNo := Index;
end;
procedure TfrmDeliveryMap.HandleAnimation(Marker: TGMMarker; Index: integer);
begin
inherited;
if (AnimationIndex >= 0) then
Marker[AnimationIndex].Animation.Bounce := False;
if (AnimationIndex = index) then
AnimationIndex := -1
else
begin
if Marker[Index].Animation.Bounce then
Marker[Index].Animation.Bounce := False
else
Marker[Index].Animation.Bounce := True;
AnimationIndex := Index;
end;
end;https://stackoverflow.com/questions/40618007
复制相似问题