当前位置: 首页 > news >正文

郑州市做网站公司a汉狮网页制作与网站建设宝典 pdf

郑州市做网站公司a汉狮,网页制作与网站建设宝典 pdf,图片生成器下载,软件开发与网站开发的区别这篇讲的是使用Draw绘制图形时根据绘制形状设置不同颜色。 根据下拉框中的值在styles对象中取对应的颜色对象,new Draw的时候将其设置为style参数。 const styles {Point: {"circle-radius": 5,"circle-fill-color": "red",},LineS…

这篇讲的是使用Draw绘制图形时根据绘制形状设置不同颜色。

根据下拉框中的值在styles对象中取对应的颜色对象,new Draw的时候将其设置为style参数。

 const styles = {Point: {"circle-radius": 5,"circle-fill-color": "red",},LineString: {"circle-radius": 5,"circle-fill-color": "red","stroke-color": "yellow","stroke-width": 2,},Polygon: {"circle-radius": 5,"circle-fill-color": "red","stroke-color": "yellow","stroke-width": 2,"fill-color": "blue",},Circle: {"circle-radius": 5,"circle-fill-color": "red","stroke-color": "blue","stroke-width": 2,"fill-color": "yellow",},};const typeSelect = document.getElementById("type");let draw; function addInteraction() {const value = typeSelect.value;if (value !== "None") {draw = new Draw({source: source,type: typeSelect.value,style: styles[value],});map.addInteraction(draw);}}

 需要注意的是这个style是绘制过程中的颜色,如果需要设置绘制完成后的颜色还得在图层中设置

  const source = new VectorSource({ wrapX: false });const vector = new VectorLayer({source: source,style:style});

 完整代码:

<template><div class="box"><h1>Drawing Features Style绘制不同颜色的图形</h1><div id="map"></div><div class="row"><div class="col-auto"><span class="input-group"><label class="input-group-text" for="type">Geometry type:</label><select class="form-select" id="type"><option value="Point">Point</option><option value="LineString">LineString</option><option value="Polygon">Polygon</option><option value="Circle">Circle</option><option value="None">None</option></select></span></div></div></div>
</template><script>
import Draw from "ol/interaction/Draw.js";
import Map from "ol/Map.js";
import View from "ol/View.js";
import { OSM, Vector as VectorSource } from "ol/source.js";
import { Tile as TileLayer, Vector as VectorLayer } from "ol/layer.js";
export default {name: "",components: {},data() {return {map: null,};},computed: {},created() {},mounted() {const raster = new TileLayer({source: new OSM(),});const source = new VectorSource({ wrapX: false });const vector = new VectorLayer({source: source,});const map = new Map({layers: [raster, vector],target: "map",view: new View({center: [-11000000, 4600000],zoom: 4,}),});const styles = {Point: {"circle-radius": 5,"circle-fill-color": "red",},LineString: {"circle-radius": 5,"circle-fill-color": "red","stroke-color": "yellow","stroke-width": 2,},Polygon: {"circle-radius": 5,"circle-fill-color": "red","stroke-color": "yellow","stroke-width": 2,"fill-color": "blue",},Circle: {"circle-radius": 5,"circle-fill-color": "red","stroke-color": "blue","stroke-width": 2,"fill-color": "yellow",},};const typeSelect = document.getElementById("type");let draw; function addInteraction() {const value = typeSelect.value;if (value !== "None") {draw = new Draw({source: source,type: typeSelect.value,style: styles[value],});map.addInteraction(draw);}}typeSelect.onchange = function () {map.removeInteraction(draw);addInteraction();};addInteraction();},methods: {},
};
</script><style lang="scss" scoped>
#map {width: 100%;height: 500px;
}
.box {height: 100%;
}#info {width: 100%;height: 24rem;overflow: scroll;display: flex;align-items: baseline;border: 1px solid black;justify-content: flex-start;
}
</style>

http://www.yayakq.cn/news/133094/

相关文章:

  • 做公众号的网站有哪些功能企业建设企业网站的好处有哪些
  • wordpress+仿站步骤十大最好玩网页游戏
  • 网站定制营销的过程做殡葬名片的网站
  • 如何做网站建设团队建设京东网上商城书店官网
  • 杭州网站建站平台wordpress 手机发文章
  • 免费推广网站途径有哪些网站编辑培训学校
  • 淘宝网做宝贝详情用哪个网站免费网站建设步骤
  • 做彩票网站代理犯法吗6顺庆移动网站建设
  • 宁波市奉化区建设局网站0基础学网站设计
  • 魏县审批建设的网站国内做新闻比较好的网站有哪些
  • 自己建网站写小说可行吗产品策划书范文案例
  • 网站开发项目视频教程在家开网店怎么开
  • wordpress 导入模板个人网站seo入门
  • 北京的做网站公司访问的网站显示建设中
  • 浦东做营销网站wordpress 多域名
  • 联赛网站建设不足福建龙岩网站制作公司
  • 成都如何做网站海外网站免费建设
  • 自己做网站 最好的软件wordpress打造cms
  • 山东聊城做网站怎么做降落伞制作方法
  • 网站建设完成情况工作总结富阳网站建设洛洛科技
  • 网站商城设计公司网上推广平台
  • 销售型企业网站有哪些wordpress主题页面底部编辑
  • 网站页面关键字在哪里免费制作壁纸的app
  • 中国互联网协会网站深圳个人网站设计
  • 做网站许昌网站建设外包必须注意几点
  • 优质做网站公司网站对齐原则
  • 襄樊网站建设学做网站教学百度网盘
  • 模板展示网站源码asp.net网站开发流程
  • 著名的设计企业网站北京企业展示网站建设
  • 海州区建设局网站二级域名租用