2Pascal-新时代的Pascal

 找回密码
 立即注册
搜索
热搜: fastreport
查看: 3195|回复: 6
打印 上一主题 下一主题

BaiduLocation_百度定位_LBS_定位_5_SDK_DEMO_Add_Jar_BaiduLBS_Android5

[复制链接]

90

主题

293

帖子

8万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
81976
楼主
发表于 2015-7-3 12:48:19 | 显示全部楼层
京东数码购物支持本站
百度地图 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]
(C)(P)Flying Wang
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|新时代Pascal论坛

GMT+8, 2024-5-10 08:16 , Processed in 0.061189 second(s), 23 queries .

Powered by Discuz! X3

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表