{"version":"0.1.0","code":"0000","result":true,"message":"处理成功","errdetail":"","timestamp":1671508872292,"data":{"id":71713316,"title":"6.5.7多分辨率下的图层应用","slug":"evwqbs","format":"lake","bookId":26046811,"body":null,"body_draft":null,"body_html":"

基本介绍

多分辨率屏幕下,比如分辨率调整,分屏等,基本都是需要根据分辨率修改图层的纹理显示大小,以此达到最优的显示效果,那么有两种方式来达到此目的:

一种是根据分辨率提供不同的纹理图片大小(需要多套纹理图片);

一种是不管在什么分辨率下,纹理图片只有一张(只需要一套纹理图片,SVG格式图片),但是根据分辨率设置不同的纹理显示比例大小(推荐该方式,节省空间);


同时,目前有两种方式来修改点图元的纹理显示大小:

com.autonavi.gbl.map.layer.PointLayerItem.setScale

com.autonavi.gbl.map.layer.LayerMgr.setAllPointLayerItemsScale


至于不同分辨率下的缩放比例值,则需要由客户端根据业务得出对应的比例尺,可参考附录,该显示大小同样适用于底图自定义文字大小

场景图

\"image.png\"

\"image.png\"

时序图

关键参数

com.autonavi.gbl.map.layer.model.ScalePriority类

枚举值

注释

ScalePriorityLocal 

缩放方式本地优先,点图元自己的缩放比例

ScalePriorityGlobal

缩放方式全局优先,全局缩放比例

核心接口

//设置点的绘制缩放比例系数 该值决定最终显示overlay item的大小,值越大,显示越大\nvoid com.autonavi.gbl.map.layer.PointLayerItem.setScale(@ScalePriority.ScalePriority1 int priority, ScaleInfo3D scale)\t\n\n//获取点的绘制缩放比例系数\nScaleAttribute com.autonavi.gbl.map.layer.PointLayerItem.getScale()\n    \n//对所有pointOverlayItem 纹理缩放\nvoid com.autonavi.gbl.map.layer.LayerMgr.setAllPointLayerItemsScale(ScaleInfo3D scale)\n    

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

调用示例

更改所有点图元纹理显示大小

    boolean scaleUp = true;\n    ScaleInfo3D mPointItemsScale = new ScaleInfo3D();\n    if (scaleUp) {\n        mPointItemsScale.poiScale.x = 1.20;\n        mPointItemsScale.bgScale.x = 1.20;\n        mPointItemsScale.bubbleScale.x = 1.20;\n        mPointItemsScale.poiScale.y = 1.20;\n        mPointItemsScale.bgScale.y = 1.20;\n        mPointItemsScale.bubbleScale.y = 1.20;\n    } else {\n        mPointItemsScale.poiScale.x = 0.8;\n        mPointItemsScale.bgScale.x = 0.8;\n        mPointItemsScale.bubbleScale.x = 0.8;\n        mPointItemsScale.poiScale.y = 0.8;\n        mPointItemsScale.bgScale.y = 0.8;\n        mPointItemsScale.bubbleScale.y = 0.8;\n    }\n\n    //缩放所有点图元的纹理显示比例\n    mapView.getLayerMgr().setAllPointLayerItemsScale(mPointItemsScale);

更改单个点图元纹理显示大小

    BaseLayer mPointLayer = new BaseLayer("test", mapView);\n    mapView.getLayerMgr().addLayer(mPointLayer);\n    ...//添加图元等\n        \n    PointLayerItem itemScalePoi = (PointLayerItem) mPointLayer.getItem("id1");\n    ScaleInfo3D mItemScale3D = itemScalePoi.getScale().scale;\n    mItemScale3D.poiScale.x += 1.0;\n    mItemScale3D.poiScale.y += 1.0;\n\n    //这里设置的是当前item的scale,所以传入ScalePriorityLocal,并应用传入的scale值\n    //如果传入ScalePriorityGlobal,应用的scale值是由setAllPointLayerItemsScale传入的scale值\n    itemScalePoi.setScale(ScalePriority.ScalePriorityLocal, mItemScale3D);

附录

1、Auto显示比例尺计算策略

(X:屏幕长边像素,Y:屏幕短边像素)

如果是方屏:(1<=X/Y<1.3)

 a 若 600px Y 768px,按 1.0的缩放比缩放

 b 若 768px < Y < 1280px, 按照1.0~1.3的缩放比缩放;

 c 若 400px < Y < 600px, 按照1.0~0.6的缩放比缩放;

 c 若 Y 400px, 按照0.8的缩放比缩放;

d 其它,按1.3的缩放比缩放

否则:

a 若 Y < 400 px,按 0.8 倍基准效果显示。

b 若 400px Y < 600 px, 按照0.6~1.0的缩放比缩放;

c 若 Y ≥ 600 px:

     当 X/Y < 1.5 时,Y/750 倍基准效果,上限值为 2.0 倍;

     当 1.5 ≤ X/Y ≤ 1.6 时,3Y/2000 倍基准效果,上限值为 2.0 倍;

     当 1.6 < X/Y 时,Y/600 倍基准效果,上限值为 2.0 倍。

2、Auto显示比例尺代码示例

float getScaleByScreen(int screenWidth, int screenHeight)\n{\n    float scale = 1.0f;\n    int minLength = screenWidth < screenHeight ? screenWidth : screenHeight;\n    int maxLength = screenWidth > screenHeight ? screenWidth : screenHeight;\n    float ratio = (float)maxLength / (float)minLength;\n\n    if ( ratio >= 1.0 && ratio < 1.3 )\n    {\n        if ( minLength <= 400 )\n        {\n            scale = 0.8f;\n        }\n        else if ( minLength > 400 && minLength < 600 )\n        {\n            scale = 0.8f + ((minLength - 400) * 1.0 / (600 - 400)) * 0.2;\n        }\n        else if ( minLength >= 600 && minLength <= 768 )\n        {\n            scale = 1.0f;\n        }\n        else if ( minLength > 768 && minLength < 1280 )\n        {\n            scale = 1.0f + ((minLength - 768) * 1.0 / (1280 - 768)) * 0.3;\n        }\n        else\n        {\n            scale = 1.3f;\n        }\n    }\n    else\n    {\n        if (minLength < 400)\n        {\n            scale = 0.8f;\n        }\n        else if (minLength < 600 && minLength >= 400)\n        {\n            scale = (float)((minLength + 400) / 1000.0f);\n        }\n        else\n        {\n            float ratio = (float)maxLength / (float)minLength;\n\n            if (ratio < 1.5)\n            {\n                scale = (float)minLength / (float)750;\n            }\n            else if (ratio <= 1.6)\n            {\n                scale = (float)(minLength * 3) / (float)2000;\n            }\n            else\n            {\n                scale = (float)minLength / (float)600;\n            }\n\n            if (scale > 2.0f)\n            {\n                scale = 2.0f;\n            }\n        }\n    }\n}


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