先把代码贴出来,注释以后有时间再写(需要留意一下这里图标的引入方式,函数内相同路径无法找到图片)

import sk from "../../assets/img/home/sk-active.png";
import hd from "../../assets/img/home/river-active.png";
  // 雨量站  状态:颜色标识 点
switch (status) {
case 0: status = '#a8eba8'
break;
case 1: status = '#69befe'
break;
case 2: status = '#ea29fb'
break;
case 3: status = '#ea29fb'
break;
}
function style(names) {
return new Style({
image: names === 'yl' ? new Circle({
radius: 5,
fill: new Fill({
color: '#05ab57',
}),
stroke: new Stroke({
color: status,
width: 16
}),
}) : new Icon({
anchor: [0.5, 30],
anchorOrigin: 'bottom-right',
anchorXUnits: 'fraction',
anchorYUnits: 'pixels',
scale: 0.45,
src: names === 'sk' ? sk : hd,
}),
text: new Text({
textAlign: "center", // 位置
textBaseline: "center", // 基准线
offsetX: 0,
offsetY: 30,
text: name,
fill: new Fill({
color: "#333",// 文本填充样式(即文字颜色)
}),
stroke: new Stroke({
color: "#Fff",
}),
zIndex: 9
})
})
}
var ylStyle = style('yl')
var skStyle = style('sk')
var hdStyle = style('hd')
  // var ylStyle = new Style({
// image: new Circle({
// radius: 5,
// fill: new Fill({
// color: '#05ab57',
// }),
// stroke: new Stroke({
// color: status,
// width: 16
// }),
// }),
// text: new Text({
// textAlign: "center", // 位置
// textBaseline: "top", // 基准线
// offsetX: 0,
// offsetY: 20,
// text: name,
// fill: new Fill({
// color: "#000",// 文本填充样式(即文字颜色)
// }),
// stroke: new Stroke({
// color: "#Fff",
// width: 1,
// }),
// zIndex: 9
// })
// }) // // 水库 点
// var skStyle = new Style({
// image: new Icon({
// anchor: [0.5, 30],
// anchorOrigin: 'bottom-right',
// anchorXUnits: 'fraction',
// anchorYUnits: 'pixels',
// // offsetOrigin: 'bottom-center',
// scale: 0.45,
// src: sk, // }),
// text: new Text({
// textAlign: "center", // 位置
// textBaseline: "center", // 基准线
// offsetX: 0,
// offsetY: 30,
// // font: "normal 12px 微软雅黑", // 文字样式
// text: name,
// fill: new Fill({
// color: "#333",// 文本填充样式(即文字颜色)
// }),
// stroke: new Stroke({
// color: "#Fff",
// }),
// zIndex: 9
// })
// }) // // 河道 点
// var hdStyle = new Style({
// image: new Icon({
// anchor: [0.5, 26],
// anchorXUnits: 'fraction',
// anchorYUnits: 'pixels',
// scale: 0.48,
// src: hd,
// }),
// text: new Text({
// textAlign: "center", // 位置
// textBaseline: "center", // 基准线
// offsetX: 0,
// offsetY: 30,
// // font: "normal 12px 微软雅黑", // 文字样式
// text: name,
// fill: new Fill({
// color: "#333",// 文本填充样式(即文字颜色)
// }),
// stroke: new Stroke({
// color: "#Fff",
// }),
// zIndex: 9
// })
// })
return {
ylStyle,
skStyle,
hdStyle
}

vue项目使用openlayers来添加地图标注,标注样式设置的简要模板的更多相关文章

  1. 将vue项目部署在Linux的Nginx下,并设置为局域网内访问

    1. 下载 wget http://nginx.org/download/nginx-1.12.2.tar.gz 2. 解压缩 tar -zxvf linux-nginx-1.12.2.tar.gz ...

  2. vue项目中使用腾讯地图

    最近在使用腾讯地图api(以下以位置数据可视化API为例),在初建项目之后,按照官网的说法,直接引入 再将官网的初始化例子放一个方法 在mounted中调用即可看到腾讯地图,但是我引入之后,一直报TM ...

  3. vue项目、路由

    目录 Vue项目创建 pycharm配置并启动vue项目 vue项目目录结构分析 js原型补充 vue项目生命周期 页面组件 配置自定义全局样式 路由逻辑跳转 路由重定向 组件的生命周期钩子 路由传参 ...

  4. Vue学习——使用vue-cli搭建一个简单的本地vue项目

    前提 安装好node.js.npm.vue-cli.为什么要先安装这些,建议查看https://www.cnblogs.com/jixue/p/10673875.html,这个对于vue-cli理解很 ...

  5. vue项目中打包编译后,CSS样式【-webkit-box-orient: vertical】打包后丢失问题

    最近在做vue项目的时候页面处理多行文本样式时用到了-webkit-box-orient: vertical这个属性,本地跑项目没问题,但是打包放到服务器后发现这个属性丢失了.如下图: 后来在网上查了 ...

  6. vue 百度地图多标注展示和点击标注进行的提示

    index.html中加入script <script type="text/javascript" src="http://api.map.baidu.com/a ...

  7. 如何在VUE项目中添加ESLint

    如何在VUE项目中添加ESLint 1. 首先在项目的根目录下 新建 .eslintrc.js文件,其配置规则可以如下:(自己小整理了一份),所有的代码如下: // https://eslint.or ...

  8. 为 VUE 项目添加 PWA 解决发布后刷新报错问题

    为什么要给 VUE 项目添加 PWA 为什么要添加?因为不管是部署在 IIS,还是 nginx,每次应用部署后,再次访问因为旧的 js 已经不存在,所以页面访问的时候会整个报错,报错的结果就是一个白屏 ...

  9. 如何为你的 Vue 项目添加配置 Stylelint

    如何为你的 Vue 项目添加配置 Stylelint 现在已经是 9102 年了,网上许多教程和分享帖都已经过期,照着他们的步骤来会踩一些坑,如 stylelint-processor-html 已经 ...

随机推荐

  1. CPU排行-台式

    此文已经于2017年11月1日更新!来源于极速空间 实际对比: intel i3-7100(双核四线程) CPU性能远超过 AMD X4 860K(四核四线程) intel i5-7500(四核四线程 ...

  2. LC 869. Reordered Power of 2

    Starting with a positive integer N, we reorder the digits in any order (including the original order ...

  3. 发布机制-灰度发布-例子:QZone

    ylbtech-发布机制-灰度发布-例子:QZone QZone是另外一个采用灰度发布的例子.大家都知道,QZone在过去的一年中改进是巨大的,从以前慢悠悠的老爷爷变成了一个充满青春活力的小伙子.其中 ...

  4. easyUI之Accordion(分类)

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <hea ...

  5. Hadoop HDFS命令学习笔记

    cat Usage: hadoop fs -cat [-ignoreCrc] URI [URI ...] Copies source paths to stdout. Options The -ign ...

  6. Python 内置函数 -- zip(), sorted(), filter()和map()

    内置函数1. zip() 打包(木桶效应)描述: zip() 函数用于将可迭代的对象作为参数, 将对象中对应的元素打包成一个个元组, 然后返回由这些元组组成的列表语法: zip([iterable, ...

  7. Netcat—瑞士军刀

    netcat是网络工具中的瑞士军刀,它能通过TCP和UDP在网络中读写数据.通过与其他工具结合和重定向,你可以在脚本中以多种方式使用它.使用netcat命令所能完成的事情令人惊讶. netcat所做的 ...

  8. Linux配置文件的修改

    在很多时候,我们需要对Linux的配置文件进行修改.此时就涉及到了不同Linux发行版的修改配置问题.下面就以主流的几个操作系统(Unix:Solaris,Linux:Ubuntu,Redhat)作为 ...

  9. python urllib2 实现大文件下载

    使用urllib2下载并分块copy: # from urllib2 import urlopen # Python 2 from urllib.request import urlopen # Py ...

  10. Mac下使用sshpass让iterm2支持多ssh登录信息保存

    mac下没有xshell等连接linux服务器的工具,当需要管理的服务器越来越多之后,密码管理就成了一个很头疼的问题,每次都需要去复制粘贴密码,浪费了很多时间,在网上查了不少资料,发现mac下可以使用 ...