{"version":"0.1.0","code":"0000","result":true,"message":"处理成功","errdetail":"","timestamp":1671516358709,"data":{"id":71712572,"title":"6.3.3.3多边形图元","slug":"iftu6a","format":"lake","bookId":26046811,"body":null,"body_draft":null,"body_html":"

效果图

\"image.png\"

\"image.png\"

\"image.png\"

说明:多边形图元PolygonLayerItem是基础图层中的基础元素之一,本身派生于基础图元LayerItem,使用多边形图元可以绘制矩形、不规则多边形等。PolygonLayerItem还派生了CustomPolygonLayerItem自定义多边形图元供客户端个性化场景下使用多边形绘制特别的,目前仅支持颜色的配置。

时序图

核心参数

字段

含义

com.autonavi.gbl.map.layer.BaseLayer

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

com.autonavi.gbl.map.layer.PolygonLayerItem

多边形图元

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

图元类型:多边形类型

核心接口

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


void com.autonavi.gbl.map.layer.PolygonLayerItem.setColor(long color) 

 

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


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

 

long com.autonavi.gbl.map.layer.PolygonLayerItem.getColor()


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

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

代码示例

 ...\n \n /**<  添加多边形图元 */\npublic void addPolygonLayerItem() {\n\tPolygonLayerItem polygonItem = new PolygonLayerItem();\n\tpolygonItem.setID("id3");\n\tpolygonItem.setPriority(3);\n    polygonItem.setBusinessType(BusinessTypePolygonXXX); // 可以为客户端定义的多边形业务类型常量\n\tArrayList<Coord3DDouble> points = new ArrayList<Coord3DDouble>();\n\tCoord3DDouble start = new Coord3DDouble(116.475536, 39.992828, 0.0);\n\tCoord3DDouble mid = new Coord3DDouble(116.478883,39.994776, 0.0);\n\tCoord3DDouble end = new Coord3DDouble(116.47884,39.992737, 0.0);\n\tpoints.add(start);\n\tpoints.add(mid);\n\tpoints.add(end);\n\tpolygonItem.setPoints(points);\n\tmBaseLayer.addItem(polygonItem); // 基础图层内添加图元\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.LayerItemPolygonType:\n                ... // 按需对businessType进行判断,获取指定的json串\n\t\t\t\tstrStyleJson = getStyleBeanJson("polygon_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}\n\n...


JSON配置

关键字说明

设置项

函数

说明

优先级

priority

如果没有指定优先级,使用默认优先级(非必填)

颜色

color

RGBA颜色值,如0x7700ab81,紫色

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

{\n    "polygon_layer_item_style":{\n        "priority":0,             //优先级,可不设\n        "color":"0x7700ab81"      //颜色\n    }\n}

精简版示例(只配置颜色)

    "polygon_search_end_area":{\n        "polygon_layer_item_style":{\n            "color":"0x5990b8f5"\n        }\n    }


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