I have this (now working) code based on bits I picked up various places:
procedure TFormMain.imgMapsGesture(Sender: TObject;
const EventInfo: TGestureEventInfo; var Handled: Boolean);
var
LObj: IControl;
LImage: TImage;
W: Single;
H: Single;
begin
LImage := nil;
LObj := Self.ObjectAtPoint(ClientToScreen(EventInfo.Location));
if (LObj is TImage) and (LObj.Visible) then
begin
LImage := TImage(LObj.GetObject);
if (LImage <> imgMaps) then
LImage := nil
;
end
;
if LImage = nil then
Exit
;
if LImage.Bitmap = nil then
Exit
;
case EventInfo.GestureID of
igiZoom:
begin
if (EventInfo.Distance < 1) then
Exit
;
if
(not(TInteractiveGestureFlag.gfBegin in EventInfo.Flags))
and
(not(TInteractiveGestureFlag.gfEnd in EventInfo.Flags))
then
begin
W := LImage.Width + 2 * ((EventInfo.Distance - FLastDistanceZoom) / 3);
H := LImage.Height + 2 * ((EventInfo.Distance - FLastDistanceZoom) / 3);
if
(W < layoutMapsContent.Width)
or
(H < layoutMapsContent.Height)
then
begin
W := layoutMapsContent.Width;
H := layoutMapsContent.Height;
end
;
LImage.Width := W;
LImage.Height := H;
FLastDistanceZoom := EventInfo.Distance;
end
;
end
;
igiPan:
begin
if
(not(TInteractiveGestureFlag.gfEnd in EventInfo.Flags))
then
begin
if (not(TInteractiveGestureFlag.gfBegin in EventInfo.Flags)) then
begin
LImage.Position.X := LImage.Position.X + (EventInfo.Location.X - FMapsLastPositionPan.X);
LImage.Position.Y := LImage.Position.Y + (EventInfo.Location.Y - FMapsLastPositionPan.Y);
end
;
FMapsLastPositionPan.X := EventInfo.Location.X;
FMapsLastPositionPan.Y := EventInfo.Location.Y;
end
;
end
;
I got zoom working fairly well (not in simulator though, but on iOS iPhone), however panning is not working at all. When panning in simulator I can see eventdisance is always 0. I have enabled pan + zoom geatures on the TImage.