function setLightSpot() {
// 获取两种点位数据
homepageQuery({
type: 1,
}).then((res: AnyObject) => {
if (res.code == 200) {
homepageQuery({
type: 2,
}).then((ret: AnyObject) => {
if (ret.code == 200) {
let features = [];
for (let item of res.data) {
let wkt = parse(item);
let feature = {
type: 'Feature',
properties: {
color: '#FFD86F',
},
geometry: wkt,
};
features.push(feature);
}
for (let item of ret.data) {
let wkt = parse(item);
let feature = {
type: 'Feature',
properties: {
color: '#cc7bff',
},
geometry: wkt,
};
features.push(feature);
}
addLuminousSpot(map, features);
} else {
Message.success(ret.msg);
}
});
} else {
Message.success(res.msg);
}
});
}
// 添加点位图层
function addLuminousSpot(map: any, features: AnyObject[]) {
if (map.getLayer('park-volcanoes')) {
map.removeLayer('park-volcanoes');
map.removeSource('park-volcanoes');
}
map.addLayer({
id: 'park-volcanoes',
type: 'circle',
source: {
type: 'geojson',
data: {
type: 'FeatureCollection',
features,
},
},
paint: {
'circle-radius': 2,
'circle-color': ['get', 'color'],
'circle-opacity': 0.8,
},
});
}
// 删除点位图层
function luminousSpotShow(map: any) {
if (map.getLayer('park-volcanoes')) {
map.removeLayer('park-volcanoes');
map.removeSource('park-volcanoes');
}
}
地图添加发光点效果
最新推荐文章于 2023-09-15 22:37:31 发布