高徳地図APIはPolygonポリゴンを描画してクリアします
1039 ワード
今日は、与えられた座標のセットに基づいて多くの多角形を描き、1つのイベントですべての形状をクリアするシーンについて議論します.私は高徳地図apiを使っています.詳細や構想はドキュメントの中で迅速に明確な説明を見つけることができません.以下のコードを見て、画像を描くことを啓発したいと思っています.
画像をクリア:
items.map(item => {
let { fenceid, fence } = item;
const pathPoint = fence.map(value => {
return [x, y];
});
let polygon = new AMap.Polygon({
path: pathPoint,
strokeWeight: 1,
strokeColor: '#ff8f1f',
strokeOpacity: 0.9,
fillColor: '#4876FF',
fillOpacity: 0,
map: this.map
});
this.cache[fenceid] = {
fence,
polygon
};
polygon.setMap(this.map);
});
画像をクリア:
clearFence = ()=>{
if(this.cache){
for(let i in this.cache){
var _i = i;
this.cache[i].polygon.hide();
}
this.cache = {};
}
return;
}