{"version":"0.1.0","code":"0000","result":true,"message":"处理成功","errdetail":"","timestamp":1671508807005,"data":{"id":71712815,"title":"2.5.1 视图控制","slug":"erxub1","format":"lake","bookId":26046811,"body":null,"body_draft":null,"body_html":"


本章节主要介绍如何支持动态调整视图窗口。

场景图

如下两张图可理解为两种视图场景的切换。从对比图可知视图控制即可改变地图大小,也可以改变地图在屏幕上显示的位置。

通过x,y 控制地图渲染视口与屏幕左上角的距离,通过height,width 控制地图在屏幕上显示的大小。

在屏幕宽高1024,600下,设置x=100,y=200, width=514, height=388的视图效果

\"image.png\"

在屏幕宽高1024,600下,设置x=200,y=100, width=800, height=400的视图效果

\"image.png\"

时序图

核心接口

void com.autonavi.gbl.map.MapView.setMapviewPort(MapViewPortParam portParam)

说明:函数详情,请复制函数名称到在线API搜索

调用示例

long x = 200; //左上角 左偏置\nlong y = 100; //左上角 顶偏置\n\nlong width = 800; //地图宽\nlong height = 400; //地图高\n\nlong screenWidth = 1024; //屏幕宽\nlong screenHeight = 600; //屏幕高\n\nMapViewPortParam mapViewPortParam = new MapViewPortParam(x, y, width, height, screenWidth, screenHeight);\nmapView.setMapviewPort(mapViewPortParam);


","body_lake":null,"pub_level":null,"status":"0","updated_at":"2022-04-06 07:01:27","deleted_at":null,"nameSpace":"mnlcaa/v610","browseCount":241,"collectCount":0,"estimateDate":2,"docStatus":0,"permissions":true,"overView":false}}