{"version":"0.1.0","code":"0000","result":true,"message":"处理成功","errdetail":"","timestamp":1671516361246,"data":{"id":71712548,"title":"6.3.3.6 3D车标模型图元","slug":"fwwf94","format":"lake","bookId":26046811,"body":null,"body_draft":null,"body_html":"

场景图

\"image.png\"

说明:3D模型图元MapModelLayerItem是基础图层中的基础元素之一,本身派生于基础图元LayerItem,其具备3D效果,目前应用场景为3D车标。Item必须通过AddItem的方式依附在BaseLayer上


时序图


关键参数

字段

含义

com.autonavi.gbl.map.layer.BaseLayer

基础图层,item必须附加在Layer上

com.autonavi.gbl.map.layer.MapModelLayerItem

3D模型图元

com.autonavi.gbl.map.layer.model.LayerItemType.LayerItem3DModelType

图元类型:3D模型


核心接口

/* 回调获取3D模型json串 */\nString com.autonavi.gbl.map.layer.observer.IPrepareLayerStyle.getLayerStyle(BaseLayer pLayer, LayerItem pItem, boolean forJava)\n\n/* 回调获取3D模型id */\nint com.autonavi.gbl.map.layer.observer.IPrepareLayerStyle.get3DModelId(BaseLayer pLayer, LayerItem pItem, String str3DModelId)\n\n/* 加载3D模型数据 */\nboolean com.autonavi.gbl.map.MapView.addLayer3DModel(Layer3DModel modelParam)\n\n/* 设置3D模型位置 */\nvoid com.autonavi.gbl.map.layer.MapModelLayerItem.setPos(Coord3DDouble pos)\nvoid com.autonavi.gbl.map.layer.MapModelLayerItem.setPos3D(Coord3DDouble pos)\n\n/* 设置模型缩放系数 */\nvoid com.autonavi.gbl.map.layer.MapModelLayerItem.setScale(float scale)\n\n/* 设置是否需要远近遮挡的效果 */\n/* 说明:远近遮挡的效果,即近处的不会被远处遮挡,不设置默认为false */\nvoid com.autonavi.gbl.map.layer.MapModelLayerItem.setDepthMask(boolean needDepthTest)\n\n/* 设置调节仰角时,底部旋转轴的位置 */\n/* 说明:offset 偏移值,相对图片左上角,单位:图片像素。例如:小车模型以底盘图片底部作为旋转轴,偏移值为底盘图片的高度 */\nvoid com.autonavi.gbl.map.layer.MapModelLayerItem.setMaxPitchAxisOffset(float offset)

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


调用示例

...\n/*< 创建MapModelLayerItem并添加到图层 */\nBaseLayer pLayer = new BaseLayer("layerName", mapView);   // 创建BaseLayer\npLayer.setStyle(prepareLayerStyle);   // 设置样式回调\nmapView.getLayerMgr.addLayer(pLayer); // 将图层添加到管理器中\nMapModelLayerItem pItem = new MapModelLayerItem();   // 创建MapModelLayerItem\npLayer.addItem(pItem);                // 添加item到layer中\n\npItem.setPos(pos2D);    // 设置2D位置\npItem.setPos3D(pos3D);  // 设置3D位置\npLayer.updateStyle();   // 更新样式\n\n/* 回调获取3D模型json,回调获取modelID */\npublic class MapPrepareLayerStyle implements IPrepareLayerStyle {\n\t...\n\t@Override\n    public String getLayerStyle(final BaseLayer pLayer, LayerItem layerItem, boolean b) {\n\t\tString strStyleJson = "";\n\t\tint itemType = layerItem.getItemType();\n        int businessType = layerItem.getBusinessType();\n\t\tswitch (itemType) {\n\t\t\tcase LayerItemType.LayerItem3DModelType:\n                ... // 按需对businessType进行判断,获取指定的json串\n\t\t\t\tstrStyleJson = getStyleBeanJson("3dcar_style");\n\t\t\t\tbreak;\n\t\t\tcase LayerItemType.xxx:\n\t\t\t\tbreak;\n\t\t}\n\t\treturn strStyleJson;\n\t}\t\n\t...\t\n\t@Override\n    public int get3DModelId(BaseLayer pLayer, LayerItem pItem, String str3DModelId) {\n        int modelId = -1;\n        str3DModelId = str3DModelId.trim();\n        if (str3DModelId.isEmpty()) {\n            return modelId;\n        }\t\n\t\t...\n\t\tint itemType = layerItem.getItemType();\n        int businessType = layerItem.getBusinessType();\n\t\t\n\t\tswitch (itemType) {\n\t\t\tcase LayerItemType.LayerItem3DModelType:\n                ... // 按需对businessType进行判断\n                //判断3D模型信息,若未加载则通过addLayer3DModel加载3D模型\n\t\t\t\tmodelId = addLayer3DModel(modelParam);\n\t\t\t\tbreak;\n\t\t\tcase LayerItemType.xxx:\n\t\t\t\tmodelId = -1;\n                break;\n\t\t}\n\t\treturn modelId;\n\t}\t\n}

JSON配置

JSON全量配置(各字段说明)

{\n    "3dmodel_layer_item_style":{\n        "priority":0,           // 重要度,可不设\n        "model_id":"autocar"    // 模型ID,要加载的3D模型\n    }\n}

精简版示例(只配置模型信息)

    "3dcar_style":{\n        "3dmodel_layer_item_style":{\n            "model_id":"autocar"\n        }\n    }


注意事项

1、MapModelLayerItemItemType为LayerItem3DModelType(图元类型:3D模型)

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