Created
May 3, 2021 10:13
-
-
Save retwas/79882350bcedd1fdc605ae7bb522f50c to your computer and use it in GitHub Desktop.
Map marker sync click
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unit Unit1; | |
interface | |
uses | |
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants, | |
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.Objects, | |
FMX.Maps, FMX.Controls.Presentation, FMX.StdCtrls; | |
type | |
TForm1 = class(TForm) | |
Map: TMapView; | |
Text1: TText; | |
Load: TButton; | |
procedure FormCreate(Sender: TObject); | |
procedure MapMapClick(const Position: TMapCoordinate); | |
procedure MapMarkerClick(Marker: TMapMarker); | |
procedure LoadClick(Sender: TObject); | |
private | |
public | |
{ Déclarations publiques } | |
end; | |
var | |
Form1: TForm1; | |
implementation | |
{$R *.fmx} | |
{ TForm1 } | |
procedure TForm1.FormCreate(Sender: TObject); | |
begin | |
inherited; | |
Map.Location := TMapCoordinate.Create(30.3970, -97.7300); | |
end; | |
procedure TForm1.LoadClick(Sender: TObject); | |
begin | |
TThread.CreateAnonymousThread( | |
procedure | |
var | |
LDescriptor: TMapMarkerDescriptor; | |
begin | |
Sleep(1000); | |
TThread.Synchronize(nil, | |
procedure | |
begin | |
Map.Location := TMapCoordinate.Create(30.3970, -97.7300); | |
LDescriptor := TMapMarkerDescriptor.Create(Map.Location, ''); | |
LDescriptor.Snippet := 'A'; | |
Map.AddMarker(LDescriptor); | |
Map.Location := TMapCoordinate.Create(30.3966, -97.7275); | |
LDescriptor := TMapMarkerDescriptor.Create(Map.Location, ''); | |
LDescriptor.Snippet := 'B'; | |
Map.AddMarker(LDescriptor); | |
Map.Zoom := 18; | |
end); | |
end).Start; | |
end; | |
procedure TForm1.MapMapClick(const Position: TMapCoordinate); | |
begin | |
Text1.Text := 'MapClick ' + DateToStr(Now); | |
end; | |
procedure TForm1.MapMarkerClick(Marker: TMapMarker); | |
begin | |
Text1.Text := 'MarkerClick' + Marker.Descriptor.Snippet; | |
end; | |
end. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment