import { Vector as SourceVec } from 'ol/source'
import { Feature } from 'ol'
import { Point } from 'ol/geom'
import { Style,Icon} from 'ol/style'
import { Vector as LayerVec } from 'ol/layer'
export default {
mounted(){
this.vectorTileLayer()
}
methods: {
vectorTileLayer(){
// 创建矢量容器
var vectorSource = new SourceVec({})
//创建图标特性
var iconFeature = new Feature({
geometry: new Point([117.12783185600281,36.674042472179686], "XY")
})
//将图标特性添加进矢量中
vectorSource.addFeature(iconFeature)
//创建图标样式
var iconStyle = new Style({
image: new Icon({
opacity: 0.75,
src: "图标地址"
})
})
//创建矢量层
var vectorLayer = new LayerVec({
source: vectorSource,
style: iconStyle
});
//添加进map
map.addLayer(vectorLayer);
}
}
}