{"version":"0.1.0","code":"0000","result":true,"message":"处理成功","errdetail":"","timestamp":1671516312680,"data":{"id":71711937,"title":"2.5.4.8 开放图层设置","slug":"rdbfkc","format":"lake","bookId":26046811,"body":null,"body_draft":null,"body_html":"
目前地图上的交通事件扎标,属开放图层。点击图标,可获取事件详情:
开放图层事件包括:封路、拥堵、车祸、施工、在建、新能源充电站
开放图层支持显示多种类型的图层,默认不显示,需要调用接口显示对应的图层,调用示例见下方调用示例
final int com.autonavi.gbl.map.layer.model.OpenLayerID.OpenLayerID9003 = 9003
final int com.autonavi.gbl.map.layer.model.OpenLayerID.OpenLayerID9004 = 9004
final int com.autonavi.gbl.map.layer.model.OpenLayerID.OpenLayerIDRouteTraffic = 9005
final int com.autonavi.gbl.map.layer.model.OpenLayerID.OpenLayerIDChargingStation = 200001
void com.autonavi.gbl.map.showOpenLayer(@OpenLayerID.OpenLayerID1 int nLayerID, boolean bShow)
void com.autonavi.gbl.map.OperatorBusiness.appendOpenLayer(byte[] pBuffer)
void com.autonavi.gbl.map.OperatorBusiness.deleteOpenLayerr(@OpenLayerID.OpenLayerID1 int nLayerID)
说明:函数详情,请复制函数名称到在线API搜索
// mapview 初始化\n...\n\n// 添加开放图层\nstring layerStr = "{\\"update_period\\": 300, \\"cachemode\\":1, \\"url\\": \\"http://maps.amap.com/ws/mps/lyrdata/ugc\\",\\"bounds\\":[{\\"y1\\": 122421247,\\"x2\\": 235405312, \\"x1\\": 188874751, \\"y2\\": 85065727}], \\"sublyr\\": [{\\"type\\": 4, \\"sid\\": 9000004, \\"zlevel\\": 2}], \\"minzoom\\": 6, \\"maxzoom\\": 19, \\"id\\": 9001}";\nbyte[] layerBytes = layerStr.getBytes();\nmapview.getOperatorBusiness().appendOpenLayer(layerBytes);\n\n// 显示开放图层\nmapview.getOperatorBusiness().showOpenLayer(OpenLayerID.OpenLayerID9003, true);\n\n//隐藏开放图层\nmapview.getOperatorBusiness().showOpenLayer(OpenLayerID.OpenLayerID9003, false);\n\n//删除开放图层\nmapview.getOperatorBusiness().deleteOpenLayer(OpenLayerID.OpenLayerID9003);