# new Ships66.layers.IconfontLayer

new Ships66.layers.IconfontLayer(vectorOption,option)

IconfontLayer继承RenderLayer

参数 说明 类型 可选值 默认值
vectorOption layer/Vector (opens new window)配置项参数 Object - -
option 图层配置项 Object - -

option配置项属性说明

属性 说明 类型 可选值 默认值
fontStyle 图标大小样式 String - bold 16px iconfont
fontColor 图标颜色 String - #FFA500
text 字体图标Unicode码 String - -
labelMinZoom 在最小层级显示名称 Number - 15
labelStyle 显示名称的样式font String - bold 12px sans-serif
offsetY 图标名称Y偏移量 Number - -20
offsetX 图标名称X偏移量 Number - 0
iconType 图标类型 String - -
imgSrc 图标为图片的路径 String - -
iconOption 图标为图片的配置项 (opens new window) Object - -

事件说明
事件通过on('事件名','回调函数')触发,详情查阅openlayers (opens new window)

事件名 说明 回调参数
getData 地图移动和updateWhenIdle都会触发该函数 function(e){}
enter 鼠标悬停在图标(feature (opens new window))上一秒后触发 function(e){}
leave 鼠标离开图标触发(在成片的要素中该函数可能不会触发) function(e){}
click 点击图标触发 function(e){}

# 实例方法


# populate(res)

渲染入口函数
res格式如下:

{
  "data": [
    {
      "lon":"经度",
      "lat":"纬度",
      "id": "唯一值",
      "center":["经度","纬度"],
      "name":"名称",
      "type": "图标类型(与option中iconType一致)"
    }
  ]
}

TIP

如需显示不同颜色的图标,数据中添加fillColor属性名,值为颜色值


# findIcon(data,fly)

渲染单个图标
data格式见populate中res,data的对象格式
fly : 是否飞行定位到该图标位置