Vue+OpenLayer為地圖添加風(fēng)場效果
一個簡單的小demo,就是在一個openlayers地圖上面添加風(fēng)場效果。
話不多說,直接進入正題。
首先我們需要安裝一個插件。
npm install ol-windy --save
然后我們需要一個數(shù)據(jù)來繪制風(fēng)場,我在文件最后上傳一下文件。
接下來很簡單,就是下面的代碼。
<template> <div class="home"> <div id="map" ref="map"></div> </div> </template> <script> import 'ol/ol.css'; import Draw from 'ol/interaction/Draw'; import Map from 'ol/Map'; import Overlay from 'ol/Overlay'; import View from 'ol/View'; import { Circle as CircleStyle, Fill, Stroke, Style } from 'ol/style'; import { LineString, Polygon } from 'ol/geom'; import { OSM, Vector as VectorSource } from 'ol/source'; import { Tile as TileLayer, Vector as VectorLayer } from 'ol/layer'; import { getArea, getLength } from 'ol/sphere'; import { unByKey } from 'ol/Observable'; import { WindLayer } from 'ol-wind' import gfs from './gfs.json' var map = null export default { name: "Home", data() { return { } }, mounted() { this.initMap() }, methods: { // 初始化地圖 initMap() { map = new Map({ layers: [ new TileLayer({ source: new OSM(), }), ], target: 'map', view: new View({ center: [120, 35], zoom: 5, maxZoom: 18, projection: 'EPSG:4326', }), }); this.addWindyLayer() }, // 添加風(fēng)流粒子 addWindyLayer() { const windLayer = new WindLayer(gfs, { foceRender: false, windOptions: { globalAlpha: 0.9, // 粒子透明度 maxAge: 10, // 存活最大幀數(shù) velocityScale: 1/100, // 粒子速度 frameRate: 20, // 每50貞繪制一次 paths: 5000, // 粒子數(shù)量 colorScale: () => { return "#00b3ef" }, width: 3, } }) map.addLayer(windLayer) }, }, }; </script> <style scoped> .home { width: 100%; height: 100%; background-color: aliceblue; position: relative; } #map { height: 100%; width: 100%; } </style>
其中 gfs 文件就是風(fēng)場數(shù)據(jù)。
gfs文件下載【點這里】
然后看效果~
到此這篇關(guān)于Vue+OpenLayer為地圖添加風(fēng)場效果的文章就介紹到這了,更多相關(guān)Vue OpenLayer風(fēng)場效果內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
使用vue-infinite-scroll實現(xiàn)無限滾動效果
vue-infinite-scroll插件可以無限滾動實現(xiàn)加載更多,其作用是是當(dāng)滾動條滾動到距離底部的指定高度時觸發(fā)某個方法。這篇文章主要介紹了用vue-infinite-scroll實現(xiàn)無限滾動效果,需要的朋友可以參考下2018-06-06vue項目如何實現(xiàn)前端預(yù)覽word與pdf格式文件
最近項目中需要在線預(yù)覽WORD文檔,所以給大家總結(jié)下,這篇文章主要給大家介紹了關(guān)于vue項目如何實現(xiàn)前端預(yù)覽word與pdf格式文件的相關(guān)資料,需要的朋友可以參考下2023-03-03element?el-tooltip實現(xiàn)自定義修改樣式
本文主要介紹了element?el-tooltip實現(xiàn)自定義修改樣式,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2023-07-07解決vue加scoped后就無法修改vant的UI組件的樣式問題
這篇文章主要介紹了解決vue加scoped后就無法修改vant的UI組件的樣式問題,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-09-09vue學(xué)習(xí)之Vue-Router用法實例分析
這篇文章主要介紹了vue學(xué)習(xí)之Vue-Router用法,結(jié)合實例形式分析了Vue-Router路由原理與常見操作技巧,需要的朋友可以參考下2020-01-01