openlayers3线段添加闪烁_openlayers 标记点闪烁

Document

var beijing = ol.proj.fromLonLat([116.28, 39.54]);

var map = new ol.Map({

target: 'map',

layers: [

new ol.layer.Tile({

source: new ol.source.OSM()

})

],

view: new ol.View({

center: beijing,

zoom: 4

})

});

//实例化矢量点要素,通过矢量图层添加到地图容器中

//这样就实现了预先加载图文标注

var iconFeature = new ol.Feature({

geometry: new ol.geom.Point(beijing),

name: '北京市', //名称属性

population: 2115 //人口数(万)

});

//设置点要素样式

iconFeature.setStyle(createLabelStyle(iconFeature));

//矢量标注的数据源

var vectorSource = new ol.source.Vector({

features: [iconFeature]

});

//矢量标注图层

var vectorLayer = new ol.layer.Vector({

source: vectorSource,

visible: false

});

map.addLayer(vectorLayer);

//矢量标注样式设置函数,设置image为图标ol.style.Icon

function createLabelStyle(feature){

console.log(feature);

return new ol.style.Style({

image: new ol.style.Icon({

anchor: [0.5, 60], //锚点

anchorOrigin:'top-right', //锚点源

anchorXUnits: 'fraction', //锚点X值单位

anchorYUnits: 'pixels', //锚点Y值单位

offsetOrigin: 'top-right', //偏移原点

opacity: 0.75,

scale: 0.05,

src: 'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1594359193211&di=1d6bb819a5daa724ff65cc4d011d4d42&imgtype=0&src=http%3A%2F%2Fku.90sjimg.com%2Felement_pic%2F17%2F10%2F27%2F05dc60e54e3aa5d093cdc32611303643.jpg' //图标的URL

}),

});

}

var flag=true

setInterval(() => {

flag=!flag

vectorLayer.setVisible(flag)

}, 300);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值