forked from cleyjulio/maps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ufrMap.pas
103 lines (76 loc) · 2.54 KB
/
ufrMap.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
unit ufrMap;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants, System.Sensors, System.Sensors.Components,
FMX.Types, FMX.Graphics, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.StdCtrls, FMX.Objects, FMX.Layouts, FMX.Controls.Presentation, FMX.Maps,
map.example;
type
TfrMap = class(TFrame)
MapView: TMapView;
LocationSensor: TLocationSensor;
BarraTitulo: TRectangle;
SwitchMarkers: TSwitch;
Label2: TLabel;
Layout1: TLayout;
Label1: TLabel;
lblDistance: TLabel;
RecNameArea: TRectangle;
lblNameTh: TLabel;
procedure FramePainting(Sender: TObject; Canvas: TCanvas; const ARect: TRectF);
procedure MapViewMarkerClick(Marker: TMapMarker);
procedure LocationSensorLocationChanged(Sender: TObject; const OldLocation, NewLocation: TLocationCoord2D);
procedure FramePaint(Sender: TObject; Canvas: TCanvas; const ARect: TRectF);
procedure SwitchMarkersSwitch(Sender: TObject);
procedure btnBackClick(Sender: TObject);
public
{MANIPULAÇÃO DE MAPA}
LookAt, Position: TMapCoordinate;
outLinePolygon: TMapPolygonPolyvertex;
mapPolygon: TMapExample.TPolyArray;
LineDistance: TMapExample.TLineArray;
Names: TMapExample.TMarkersArray;
procedure CloseMap;
end;
implementation
{$R *.fmx}
procedure TfrMap.btnBackClick(Sender: TObject);
begin
CloseMap;
end;
procedure TfrMap.CloseMap;
begin
try
LocationSensor.Active := False;
MapView.DestroyComponents;
MapView.Destroy;
FreeAndNil(Self);
except
Self.Visible := False;
end;
end;
procedure TfrMap.FramePaint(Sender: TObject; Canvas: TCanvas; const ARect: TRectF);
begin
LocationSensor.Active := True;
end;
procedure TfrMap.FramePainting(Sender: TObject; Canvas: TCanvas; const ARect: TRectF);
begin
RecNameArea.Visible := False;
end;
procedure TfrMap.LocationSensorLocationChanged(Sender: TObject; const OldLocation, NewLocation: TLocationCoord2D);
begin
Position.Latitude := NewLocation.Latitude;
Position.Longitude := NewLocation.Longitude;
end;
procedure TfrMap.MapViewMarkerClick(Marker: TMapMarker);
begin
TMapExample.ChangeMarker(Marker, MapView, RecNameArea, lblNameTh, Names);
lblDistance.Text := '';
TMapExample.RemoveLine(LineDistance);
TMapExample.Distance(Marker.Descriptor.Position, Position, MapView, lblDistance, LineDistance);
end;
procedure TfrMap.SwitchMarkersSwitch(Sender: TObject);
begin
TMapExample.SetVisibleMarkers(Names, SwitchMarkers.IsChecked);
TMapExample.SetVisibleLine(LineDistance, SwitchMarkers.IsChecked);
end;
end.