mapbox層級(jí)變小,部分圖標(biāo)+文字不進(jìn)行繪制問(wèn)題
mapbox層級(jí)變小后,可能由于碰撞算法,有些位置的圖標(biāo)要素比較多時(shí),會(huì)出現(xiàn)少繪制/不繪制的情況
查閱官網(wǎng)后,發(fā)現(xiàn)參數(shù)icon-ignore-placement 解釋:If true, other symbols can be visible even if they collide with the icon.(如果設(shè)置成true,即使其他要素有碰撞的情況下,依然可以顯示)
但是設(shè)置 icon-ignore-placement:true 后;
發(fā)現(xiàn)比之前繪制的要素多了,但還是沒(méi)有全部繪制出來(lái),
于是,text-allow-overlap 解釋:If true, the text will be visible even if it collides with other previously drawn symbols(如果設(shè)置為true,文字依舊顯示,即使和已繪制的其他要素有碰撞)
設(shè)置后,圖標(biāo)+文字都可以繪制出來(lái)啦
mapbox.addLayer({ id: "id", type: "symbol", source: { type: "geojson", data: { type: "FeatureCollection", features: [] } }, paint: { "text-color": "white" }, layout: { "icon-image": ["get", "icon"], "icon-ignore-placement": true, "icon-allow-overlap": true, "icon-size": 0.7, "icon-offset": [-1, -1], "text-field": ["get", "name"], "text-size": 13, "text-offset": [0, 0], "text-anchor": "top", "text-allow-overlap": true } });

浙公網(wǎng)安備 33010602011771號(hào)