基于Vue2.0实现OpenLayers Marker点标记


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);
    }
 }
}


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM