{"version":"0.1.0","code":"0000","result":true,"message":"处理成功","errdetail":"","timestamp":1671516360429,"data":{"id":71712567,"title":"6.3.3.5箭头图元","slug":"vcd22g","format":"lake","bookId":26046811,"body":null,"body_draft":null,"body_html":"

效果图

\"image.png\"

\"image.png\"

\"image.png\"

说明:箭头图元ArrowLayerItem是基础图层中的基础元素之一,本身派生于基础图元LayerItem,用于绘制箭头,如导航路线上的箭头。ArrowLayerItem还派生了CustomArrowLayerItem自定义箭头图元供客户端个性化场景下使用。

时序图

核心参数

字段

含义

com.autonavi.gbl.map.layer.BaseLayer

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

com.autonavi.gbl.map.layer.ArrowLayerItem

箭头图元

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

图元类型:箭头类型

核心接口

void com.autonavi.gbl.map.layer.ArrowLayerItem.setPoints(ArrayList< Coord3DDouble > points)


void com.autonavi.gbl.map.layer.ArrowLayerItem.setPoints3D(ArrayList< Coord3DDouble > points)


void com.autonavi.gbl.map.layer.ArrowLayerItem.updateStyle()


void com.autonavi.gbl.map.layer.ArrowLayerItem.setAnimationPlayState(ArrowAnimationPlayState

playState)


void com.autonavi.gbl.map.layer.ArrowLayerItem.setGrownAnimation(int duration, int times, long userData)


void com.autonavi.gbl.map.layer.ArrowLayerItem.setGrownAnimation(int duration, int times)


boolean com.autonavi.gbl.map.layer.ArrowLayerItem.addGrownAnimationObserver(

ILayerItemAnimationObserver pObserver)


boolean com.autonavi.gbl.map.layer.ArrowLayerItem.removeGrownAnimationObserver(

ILayerItemAnimationObserver pObserver)


LayerItemType com.autonavi.gbl.map.layer.ArrowLayerItem.getItemType()


ArrowLayerItemStyle  com.autonavi.gbl.map.layer.ArrowLayerItem.getStyle()


ArrowAnimationPlayState com.autonavi.gbl.map.layer.ArrowLayerItem.getAnimationPlayState()


其他核心接口能力,继承自基础图元LayerItem,不再逐一列举。

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

代码示例


 ...\n \n /**<  添加箭头图元 */\npublic void addArrowLayerItem() {\n\tArrowLayerItem arrowItem = new ArrowLayerItem();\n\tarrowItem.setID("id4");\n\tarrowItem.setPriority(4);\n    arrowItem.setBusinessType(BusinessTypeArrowXXX); // 可以为客户端定义的箭头业务类型常量\n\tArrayList<Coord3DDouble> points = new ArrayList<Coord3DDouble>();\n\tCoord3DDouble start = new Coord3DDouble(116.470735, 39.992745, 0.0);\n\tCoord3DDouble mid = new Coord3DDouble(116.47236, 39.993411, 0.0);\n\tpoints.add(start);\n\tpoints.add(mid);\n\tarrowItem.setPoints(points);\n\tarrowItem.setPoints3D(points);\n\tmBaseLayer.addItem(arrowItem);\n}\n\n/* 回调获取箭头元json,回调获取markerID */\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.LayerItemArrowType:\n                ... // 按需对businessType进行判断,获取指定的json串\n\t\t\t\tstrStyleJson = getStyleBeanJson("arrow_layer_item_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 getMarkerId(BaseLayer pLayer, LayerItem pItem, String strMarkerId, String strMarkerInfo) {\n        int markerId = -1;\n        strMarkerId = strMarkerId.trim();\n        if (strMarkerId.isEmpty()) {\n            return markerId;\n        }   \n        ...\n        int itemType = layerItem.getItemType();\n        int businessType = layerItem.getBusinessType();\n\t\t\n\t\tswitch (itemType) {\n\t\t\tcase LayerItemType.LayerItemArrowType:\n                ... // 按需对businessType进行判断\n                //判断纹理信息,若未加载则通过addLayerTexture加载纹理\n\t\t\t\tmarkerId = addLayerTexture(texture);\n\t\t\t\tbreak;\n\t\t\tcase LayerItemType.xxx:\n\t\t\t\tmarkerId = -1;\n                break;\n\t\t}\n\t\treturn markerId;\n\t}\t\n}    

JSON配置

关键字说明

设置项

函数

说明

2D箭头纹理参数

arrow_2d_texture_info

use_cap是否使用线帽

use_color是否使用颜色

draw_cover是否绘制遮挡

can_be_coveredbylabel是否能被label遮挡

solid_arrow_in2dmap在2D模式下是否显示立体箭头

fill_texture填充纹理

border_texture边框纹理

texture_info填充纹理信息

cap_texture_info线帽纹理信息

3D箭头纹理参数

arrow_3d_texture_info

draw_3d_arrow是否绘制立体箭头,1打开

bias_width箭头偏移宽度     

auto_zoomer_width是否根据比例尺自动缩放宽度

solid_res_marker_id立体箭头纹理名称

solid_res_marker_info立体箭头纹理属性描述

solid_top_face_color立体箭头拔高体顶点颜色

solid_side_face_color立体箭头拔高侧面颜色

solid_shadow_color立体箭头拔高体底部颜色

solid_height": 立体箭头拔高高度

solid_thickness": 立体箭头厚度

solid_border_line_top_line_width立体箭头拔高体顶部描边宽度

solid_border_line_side_line_width立体箭头拔高体侧面描边宽度

solid_border_line_bottom_line_width立体箭头拔高体底部描边宽度

solid_border_line_top_line_color立体箭头拔高体顶部描边颜色

solid_border_line_side_line_color立体箭头拔高体侧面描边颜色

solid_border_line_bottom_line_color立体箭头拔高体底部描边颜色                  

solid_arrow_header_param立体箭头头部参数

solid_texture_info立体箭头纹理信息

solid_cap_texture_info立体箭头线帽纹理信息

solid_header_texture_info立体箭头头部纹理信息

精美箭头纹理参数

arrow_fine_texture_info

head_angle//箭头头部三角形夹角,360度制,数值范围:[20,160]

width//箭头身体宽度

head_width_ratio//头部底部和宽度的比例

height_width_ratio//箭头厚度与width之比

hang_width_ratio//悬空高度与width之比

purfle_width_ratio_1//(从内到外)第一条镶边的宽度与width之比,可以为0,为0就没有第一条镶边

purfle_width_ratio_2//(从内到外)第二条镶边的宽度与width之比,不建议为0,为0会使边沿不圆润

shadow_purfle_width_ratio//阴影镶边的宽度与width之比

purfle_color_1//(从内到外)第一条镶边的颜色,格式:ARGB

purfle_color_2//(从内到外)第二条镶边的颜色,格式:ARGB

surface_color//上表面内部的颜色,格式:ARGB

wall_color//墙体的颜色,格式:ARGB

shadow_color//阴影的颜色,格式:ARGB

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

{\n    "arrow_layer_item_style":{\n        "arrow_2d_texture_info":{          //箭头2D纹理信息\n            "use_cap":1,                   //是否使用线帽\n            "use_color":1,                 //是否使用颜色\n            "draw_cover":1,                //是否绘制遮挡\n            "can_be_coveredbylabel":0,     //是否能够被label遮挡\n            "solid_arrow_in2dmap":0,       //设置在二维地图下是否显示立体箭头\n            "fill_texture":{               //填充线的纹理信息\n                "marker_id":"fill",        //线资源id\n                "marker_info":"",          //线资源属性描述,一般用于描述纹理加载要用的信息(如锚点相关)\n                "color":"0xffffffff",      //线颜色\n                "width":40                 //线宽\n            },\n            "border_texture":{             //描边线的纹理信息\n                "marker_id":"border",      //线资源id\n                "marker_info":"",          //线资源属性描述,一般用于描述纹理加载要用的信息(如锚点相关)\n                "color":"0xff0b6fc4",      //线颜色\n                "width":40                 //线宽\n            },\n            "texture_info":{               //纹理信息\n                "x1":0.12,                 //纹理信息左上角x值,屏幕坐标系\n                "y1":0.77,                 //纹理信息左上角y值,屏幕坐标系\n                "x2":0.88,                 //纹理信息右下角x值,屏幕坐标系\n                "y2":0.77,                 //纹理信息右下角y值,屏幕坐标系\n                "texture_len":0            //纹理长度,仅在绘制虚线线型时设置\n            },\n            "cap_texture_info":{           //线帽纹理信息\n                "x1":0.12,                 //纹理信息左上角x值,屏幕坐标系\n                "y1":0.85,                 //纹理信息左上角y值,屏幕坐标系\n                "x2":0.88,                 //纹理信息右下角x值,屏幕坐标系\n                "y2":1                     //纹理信息右下角y值,屏幕坐标系\n            }\n        },\n        "arrow_3d_texture_info":{                               //箭头3D纹理信息\n            "draw_3d_arrow":1,                                  //是否绘制立体箭头\n            "bias_width":0,                                     //箭头偏移宽度(主要用于掉头箭头的掰开),不设置默认为0,为0不进行偏移\n            "auto_zoomer_width":1,                              //立体箭头是否根据比例尺自动缩放宽度\n            "solid_res_marker_id":"solid",                      //立体箭头纹理资源 \n            "solid_res_marker_info":"",                         //立体箭头纹理资源属性描述,一般用于描述纹理加载要用的信息(如锚点相关)\n            "solid_top_face_color":"0xff5aebce",                //立体箭头拔高体顶面颜色\n            "solid_side_face_color":"0xff00ae94",               //立体箭头拔高体侧面颜色\n            "solid_shadow_color":"0x59000000",                  //立体箭头拔高体底部颜色 \n            "solid_height":3,                                   //立体箭头拔高高度\n            "solid_thickness":10,                               //立体箭头厚度\n            "solid_border_line_top_line_width":2,               //立体箭头拔高体顶部描边宽度\n            "solid_border_line_side_line_width":2,              //立体箭头拔高体侧面描边宽度(侧面线又称垂直线)\n            "solid_border_line_bottom_line_width":2,            //立体箭头拔高体底部描边宽度\n            "solid_border_line_top_line_color":"0xff506cc9",    //立体箭头拔高体顶部描边颜色\n            "solid_border_line_side_line_color":"0xff1c3575",   //立体箭头拔高体侧面描边颜色(侧面线又称垂直线)\n            "solid_border_line_bottom_line_color":"0xff1c3575", //立体箭头拔高体底部描边颜色\n            "solid_arrow_header_param":{                        //立体箭头构造所需要的信息\n                "header_angle":80,                              //立体箭头头部三角形夹角\n                "header_width_rate":3                           //立体箭头头部底边和宽度的比例 正常是3倍\n            },\n            "solid_texture_info":{                              //设置立体箭头纹理信息\n                "x1":0.35,                                      //纹理信息左上角x值,屏幕坐标系\n                "y1":0.625,                                     //纹理信息左上角y值,屏幕坐标系\n                "x2":0.65,                                      //纹理信息右下角x值,屏幕坐标系\n                "y2":0.625,                                     //纹理信息右下角y值,屏幕坐标系\n                "texture_len":32                                //纹理长度,仅在绘制虚线线型时设置\n            },\n            "solid_cap_texture_info":{                          //线帽纹理信息\n                "x1":0.35,                                      //纹理信息左上角x值,屏幕坐标系\n                "y1":0.75,                                      //纹理信息左上角y值,屏幕坐标系\n                "x2":0.65,                                      //纹理信息右下角x值,屏幕坐标系\n                "y2":0.82                                       //纹理信息右下角y值,屏幕坐标系\n            },\n            "solid_header_texture_info":{                       //立体箭头头部纹理信息\n                "x1":0.1,                                       //纹理信息左上角x值,屏幕坐标系\n                "y1":0.75,                                      //纹理信息左上角y值,屏幕坐标系\n                "x2":0.9,                                       //纹理信息右下角x值,屏幕坐标系\n                "y2":0.1                                        //纹理信息右下角y值,屏幕坐标系\n            }\n        },\n\t\t\t\t"arrow_fine_texture_info":\n\t\t\t\t{\n\t\t\t\t\t"head_angle": 75.0,  \t\t\t\t\t\t\t\t\t\t//箭头头部三角形夹角,360度制,数值范围:[20,160]\n\t\t\t\t\t"width": 100.0,  \t\t\t\t\t\t\t\t\t\t\t\t//箭头身体宽度\n\t\t\t\t\t"head_width_ratio": 3.0,  \t\t\t\t\t\t\t//头部底部和宽度的比例\n\t\t\t\t\t"height_width_ratio": 1.0,  \t\t\t\t\t\t//箭头厚度与width之比\n\t\t\t\t\t"hang_width_ratio": 0.4,  \t\t\t\t\t\t\t//悬空高度与width之比\n\t\t\t\t\t"purfle_width_ratio_1": 0.15,  \t\t\t\t\t//(从内到外)第一条镶边的宽度与width之比,可以为0,为0就没有第一条镶边\n\t\t\t\t\t"purfle_width_ratio_2": 0.2,  \t\t\t\t\t//(从内到外)第二条镶边的宽度与width之比,不建议为0,为0会使边沿不圆润\n\t\t\t\t\t"shadow_purfle_width_ratio": 0.6,  \t\t\t//阴影镶边的宽度与width之比\n\t\t\t\t\t"purfle_color_1": "0xff222222",  \t\t\t\t//(从内到外)第一条镶边的颜色,格式:ARGB\n\t\t\t\t\t"purfle_color_2": "0xff3333ff",  \t\t\t\t//(从内到外)第二条镶边的颜色,格式:ARGB\n\t\t\t\t\t"surface_color": "0xffddddee",  \t\t\t\t//上表面内部的颜色,格式:ARGB\n\t\t\t\t\t"wall_color": "0xff1111bb",  \t\t\t\t\t\t//墙体的颜色,格式:ARGB\n\t\t\t\t\t"shadow_color": "0xbb0000ff"  \t\t\t\t\t//阴影的颜色,格式:ARGB\n\t\t\t\t}\n    }\n}

示例

2d箭头

    "arrow_route_arrow_style":{\n        "arrow_layer_item_style":{\n            "arrow_2d_texture_info":{\n                "use_cap":1,\n                "use_color":1,\n                "draw_cover":1,\n                "can_be_coveredbylabel":1,\n                "solid_arrow_in2dmap":1,\n                "fill_texture":{\n                    "marker_id":"arrow_line_inner",\n                    "color":"0xffffffff",\n                    "width":48\n                },\n                "border_texture":{\n                    "marker_id":"arrow_line_outer",\n                    "color":"0xff0b6fc4",\n                    "width":40\n                },\n                "texture_info":{\n                    "x1":0.12,\n                    "y1":0.77,\n                    "x2":0.88,\n                    "y2":0.77,\n                    "texture_len":0\n                },\n                "cap_texture_info":{\n                    "x1":0.12,\n                    "y1":0.85,\n                    "x2":0.88,\n                    "y2":1\n                }\n            }\n        }\n    }


3D箭头

"arrow_route_arrow_style":{\n        "arrow_layer_item_style":{\n            "arrow_3d_texture_info":{\n                "draw_3d_arrow":1,\n                "bias_width":0,\n                "auto_zoomer_width":0,\n                "solid_res_marker_id":"threed_arrow_line_shadow",\n                "solid_top_face_color":"0xfff0f9ff",\n                "solid_side_face_color":"0xff2c428a",\n                "solid_shadow_color":"0x4d000000",\n                "solid_height":5,\n                "solid_thickness":10,\n                "solid_border_line_top_line_width":3,\n                "solid_border_line_side_line_width":0,\n                "solid_border_line_bottom_line_width":0,\n                "solid_border_line_top_line_color":"0xff506cc9",\n                "solid_border_line_side_line_color":"0xff1c3575",\n                "solid_border_line_bottom_line_color":"0xff1c3575",\n                "solid_arrow_header_param":{\n                    "header_angle":55,\n                    "header_width_rate":2.8\n                },\n                "solid_texture_info":{\n                    "x1":0.3,\n                    "y1":0.77,\n                    "x2":0.7,\n                    "y2":0.77,\n                    "texture_len":0.01\n                },\n                "solid_cap_texture_info":{\n                    "x1":0.3,\n                    "y1":0.8,\n                    "x2":0.7,\n                    "y2":1\n                },\n                "solid_header_texture_info":{\n                    "x1":0.12,\n                    "y1":0.75,\n                    "x2":0.88,\n                    "y2":0\n                }\n            }\n        }\n    }

精美箭头

"arrow_route_arrow_style":{\n\t\t"arrow_layer_item_style":{\n\t\t\t"arrow_fine_texture_info":{\n\t\t\t\t\t"head_angle": 75.0,\n          "width": 100.0,\n\t\t\t\t\t"head_width_ratio": 3.0,\n\t\t\t\t\t"height_width_ratio": 1.0,\n\t\t\t\t\t"hang_width_ratio": 0.4,\n\t\t\t\t\t"purfle_width_ratio_1": 0.15,\n\t\t\t\t\t"purfle_width_ratio_2": 0.2,\n\t\t\t\t\t"shadow_purfle_width_ratio": 0.6,\n\t\t\t\t\t"purfle_color_1": "0xff222222",\n\t\t\t\t\t"purfle_color_2": "0xff3333ff",\n\t\t\t\t\t"surface_color": "0xffddddee",\n\t\t\t\t\t"wall_color": "0xff1111bb",\n\t\t\t\t\t"shadow_color": "0xbb0000ff"\n        }\n\t\t\t}\n    }

注意事项

1、图元类型


2、箭头的效果配置

2D箭头效果:

json中只配置"arrow_2d_texture_info"的时候,则绘制结果为2D箭头

"arrow_3d_texture_info"和"arrow_fine_texture_info"才会生效

3D箭头效果:

json中配置"arrow_3d_texture_info"的时候,且"draw_3d_arrow":1 ,则绘制结果为3D箭头

"arrow_fine_texture_info"才会生效

精美箭头效果:

json中只要有配置"arrow_fine_texture_info",则绘制结果为精美箭头

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