{"version":"0.1.0","code":"0000","result":true,"message":"处理成功","errdetail":"","timestamp":1671508823054,"data":{"id":71713185,"title":"3.4.2 动态纹理生成","slug":"ebw6lr","format":"lake","bookId":26046811,"body":null,"body_draft":null,"body_html":"
卡片动态纹理支持通过flex布局和css属性将预期的卡片纹理布局实现在xml文件中,添加纹理时卡片会根据xml的内容进行布局。
目前卡片支持的 flex布局 请 点击这里 了解。
目前卡片支持的 css属性 请 点击这里 了解。
说明:如图中的多备选路线标签是通过卡片生成的动态纹理。
com.autonavi.gbl.card.model.CustomTextureParam
成员 | 含义 |
markerKey | 决定纹理ID的关键参数,该参数不同会重新生成纹理数据 |
attrs | 自定义纹理其他属性 |
updateList | 需要更新的信息 |
boolean com.autonavi.gbl.map.layer.BaseLayer.addItem(LayerItem item)
int com.autonavi.gbl.map.layer.observer.IPrepareLayerStyle.getMarkerId(BaseLayer pLayer,
LayerItem pItem, String strMarkerId, String strMarkerInfo)
int com.autonavi.gbl.card.ITextureManager.addCustomTexture(CustomTextureParam texturePara)
void com.autonavi.gbl.map.layer.BaseLayer.updateStyle()
int com.autonavi.gbl.card.ITextureManager.updateCustomTexture(int markerId,CustomUpdateParam updateInfo)
void com.autonavi.gbl.map.layer.observer.ILayerClickObserver.onNotifyClick(BaseLayer layer, LayerItem \tpItem, ClickViewIdInfo clickViewIds)
注意:
1) xml中对应控件ID设置"_click"后缀后,才会在clickViewIds收到对应控件ID,如布局文件示例中的"time_diff_text_click"。
2) xml中对应控件ID设置"_ignore"后缀后,则将改控件设置为不可点击区域,如布局文件示例中的"div2_ignore"。
说明:函数详情,请复制函数名称到在线API搜索
\npublic class MapPrepareLayerStyle implements IPrepareLayerStyle {\n\t...\t\n\t@Override \t纹理ID获取监听回调\n public int getMarkerId(BaseLayer pLayer, LayerItem pItem, String strMarkerId, String strMarkerInfo) {\n int markerId = -1;\n \n /*< 获取卡片管理器 */\n ITextureManager textureManager;\n\t\t...\n\n /*< 添加动态纹理 */\n if (addCustomTexture)\n {\n \t/*< 读取布局文件内容 */\n String xmlStr;\n ...\n \n CustomTextureParam customParam = new CustomTextureParam();\n customParam.markerKey.setMarkerKey(0x1234);/**< 自定义纹理标识,该参数不同会重新生成纹理数据*/\n customParam.markerKey.setCustomXmlStr(xmlStr);\n customParam.attrs.setIsNightForAsvg(true);\n customParam.attrs.scaleFactor = 1.0f;\n customParam.attrs.anchorType = LayerIconAnchor.LayerIconAnchorBottom;\n customParam.attrs.xRatio = 0.0;\n customParam.attrs.yRatio = 0.0;\n customParam.attrs.isRepeat = true;\n customParam.attrs.isGenMipmaps = false;\n customParam.attrs.isPreMulAlpha = false;\n\n markerId = textureManager.addCustomTexture(customParam);\n }\n /*< 更新动态纹理 */\n else if (updateCustomTexture)\n {\n /*< 获取要更新的纹理ID */\n int poiMarkerId;\n ...\n\n CustomUpdateParam updateInfo = new CustomUpdateParam();\n updateInfo.scaleFactor = 1.5;\n\n CustomUpdatePair updatePara1 = new CustomUpdatePair();\n updatePara1.idStr = "time_diff_text"; //对应布局文件中的"id"字段\n updatePara1.newValue = "快5分钟"; //对应布局文件中的"src"字段\n updateInfo.updateList.add(updatePara1);\n\n CustomUpdatePair updatePara2 = new CustomUpdatePair();\n updatePara2.idStr = "distance_diff_text";\n updatePara2.newValue = "多500米";\n updatePara2.newStyle = "color:#FF0000;";//对应布局文件中的"style"字段\n updateInfo.updateList.add(updatePara2);\n\n markerId = textureManager.updateCustomTexture(poiMarkerId, updateInfo);\n }\n\t\treturn markerId;\n\t}\t\n}
<div id='guide_label_pop' style='width:auto;height:auto;background-image:navi_bg_route_label_left_up_day;display:flex;flex-direction:column;justify-content:center;align-items:flex-start;'>\n <label id='time_diff_text_click' style='color:#000000;font-size:20px;justify-content:flex-start;' text='快3分钟'/>\n <div id='div2_ignore' style='flex-direction:row;justify-content:flex-start;align-items:center;margin-top:5px;'>\n <label id='distance_diff_text' style='color:#000000;font-size:16px;justify-content:flex-start;' text='多1公里'/>\n <image id='traffic_light_image' style='margin-left:6px;' src='daohang_50'/>\n <label id='traffic_light_text' style='color:#000000;font-size:16px;justify-content:flex-start;' text='少3个'/>\n </div>\n</div>