|
百度地图 SDK 显示 相关代码。
by [重庆]新手(371889755)
作者参考了 EMB TAndroidMapView_UIThread 的相关代码。
[mw_shl_code=delphi,true]procedure TBaiduMap.InitInstance;
var
Rect: JRect;
begin
CallInUIThreadAndWaitFinishing(
procedure
begin
FJNativeLayout := TJNativeLayout.JavaClass.init(SharedActivity,
MainActivity.getWindow.getDecorView.getWindowToken);
FMapView := TJMapView.JavaClass.init(SharedActivity);
Rect := TJRect.JavaClass.init(0, 0, Round(Size.Height),
Round(Size.Width));
FMapView.requestFocus(0, Rect);
FJNativeLayout.setPosition(0, 0);
FJNativeLayout.setSize(Round(Size.Height), Round(Size.Width));
FJNativeLayout.setControl(FMapView);
RealignView;
end);
end;
procedure TBaiduMap.RealignView;
const
VideoExtraSpace = 100;
// To be sure that destination rect will fit to fullscreen
var
MapRect: TRectF;
RoundedRect: TRect;
LSizeF: TPointF;
LRealBounds: TRectF;
LRealPosition, LRealSize: TPointF;
begin
if (FJNativeLayout <> nil) then
begin
LRealPosition := Self.LocalToAbsolute(TPointF.Zero) * FScale;
LSizeF := TPointF.Create(Self.Size.Size.cx, Self.Size.Size.cy);
LRealSize := Self.LocalToAbsolute(LSizeF) * FScale;
LRealBounds := TRectF.Create(LRealPosition, LRealSize);
MapRect := TRectF.Create(0, 0, Self.Width * VideoExtraSpace,
Self.Height * VideoExtraSpace);
RoundedRect := MapRect.FitInto(LRealBounds).Round;
if not Self.ParentedVisible then
RoundedRect.Left := Round(Screen.Size.cx * FScale);
FJNativeLayout.setPosition(RoundedRect.TopLeft.X, RoundedRect.TopLeft.Y);
FJNativeLayout.setSize(RoundedRect.Width, RoundedRect.Height);
end;
end;[/mw_shl_code]
|
|