简体   繁体   English

Delphi FMX MapView - 删除所有标记

[英]Delphi FMX MapView - remove all markers

I have TMapView and placed some TMapMarkerDescriptors on it using MapView1.AddMarker(...), but how I can clear map (remove all placed marers) from it ?我有 TMapView 并使用 MapView1.AddMarker(...) 在其上放置了一些 TMapMarkerDescriptor,但是如何从中清除地图(删除所有放置的 marers)?

I cant find something as MapView.Clear in documentation.我在文档中找不到 MapView.Clear 之类的东西。

okay this works fine好的,这很好用

var
   mar : array of  TMapMarker;

procedure TForm1.clear_markers;
var
i:integer;
begin
 if high(mar) > -1 then
  for i:=0 to high(mar) do
    if Assigned(mar[i]) then
     mar[i].Remove;

setlength(mar,0);
end;

Markers was placed by this code in loop.此代码在循环中放置了标记。 Variables loc and s are loaded from database变量locs从数据库加载

setlength(mar,length(mar)+1);
Descr := TMapMarkerDescriptor.Create(loc, s);
mar[high(mar)]:=MapView1.AddMarker(Descr);

It appears that you have to remove each marker individually as far as I can tell, which means you'll have to store references to the TMapMarker objects you've created.据我所知,您似乎必须单独删除每个标记,这意味着您必须存储对您创建的 TMapMarker 对象的引用。 TMapMarker (the result of the MapView1.AddMarker call) has two methods. TMapMarker(MapView1.AddMarker 调用的结果)有两个方法。 "Remove" removes the marker from the map, while "DisposeOf" will remove the marker from the map and free the TMapMarker object. “Remove”从地图上删除标记,而“DisposeOf”将从地图上删除标记并释放 TMapMarker 对象。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM