日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 前端技术 > vue >内容正文

vue

Vue+Openlayers创建热力图

發(fā)布時(shí)間:2024/1/1 vue 20 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Vue+Openlayers创建热力图 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
  • Vue+Openlayers創(chuàng)建熱力圖,參考文檔學(xué)習(xí)地址
  • https://www.jianshu.com/p/3cd6f6439512
  • openlayers: https://openlayers.org/en/latest/apidoc/module-ol_Feature-Feature.html
  • 直接看代碼 initMap() 方法
<template><section><!-- 地圖展示 --><common-mapref="map":district-layer="false":street-layer="false":comm-layer="false":unit-layer="false":work-layer="false":duty-layer="false"style="height: calc(100vh - 100px)"></common-map><area-bar :map="map"@get-area-score-point="getAreaScorePoint"></area-bar></section> </template><script> import { commandMapMixin } from '../mixins/commandMapMixin' import areaBar from './area-bar' import umEventApi from '@questionApi/umEvent' // import { Point } from 'ol/geom' // import { Feature } from 'ol' // import VectorSource from 'ol/source/Vector' // import { Heatmap as HeatmapLayer } from 'ol/layer' // import Map from 'ol/Map.js' // import View from 'ol/View.js' // import KML from 'ol/format/KML.js' import VectorSource from 'ol/source/Vector.js' import { Heatmap as HeatmapLayer } from 'ol/layer.js' import Feature from 'ol/Feature' import Point from 'ol/geom/Point' // import {fromLonLat} from 'ol/proj' // import VectorSource from 'ol/source/Vector.js' // import { transform } from 'ol/proj' // import GeoJSON from 'ol/format/GeoJSON'export default {name: 'command-area-index',mixins: [commandMapMixin],components: {areaBar},data() {return {PostPointDatail: '',PointDatailList: '',showPointDetail: false,currentTab: 'area',selectionCase: [],showSelectionCase: false,treeLoading: false,listQuery: {page: true,params: []},caseSetList: [],center: [118.281041, 33.962096],// 熱力圖假數(shù)據(jù)heatData: {type: 'FeatureCollection',features: [{ type: 'Point', 'coordinates': [118.281041, 33.962096], count: 100 },{ type: 'Point', 'coordinates': [118.299685, 34.004628], count: 19 },{ type: 'Point', 'coordinates': [118.2833, 33.960444], count: 419 }]},heatMapLayer: null}},computed: {},created() {},mounted() {this.map = this.$refs.map.mapthis.initMap(this.heatData)// this.addHeatMap()},methods: {initMap(heatData) {// 新生成圖層源,用于存放熱力圖圖層const source = new VectorSource({})const features = []heatData.features.forEach((item) => {const feature = new Feature({geometry: new Point(item.coordinates),weight: item.count})source.addFeature(feature)// features.push(feature)})source.addFeatures(features)// 創(chuàng)建一個熱力圖層this.heatMapLayer = new HeatmapLayer({source,blur: 20, // 模糊尺寸radius: 20, // 熱點(diǎn)半徑weight: (feature) => {const count = Number(feature.get('weight')) // 獲取feature的weight參數(shù)值const magnitude = count / 1return magnitude},zIndex: 99999999})console.log('熱力圖加載中------------', this.heatMapLayer)this.map.addLayer(this.heatMapLayer) // 將熱力圖添加在地圖上console.log('熱力圖加載成功!!!!!!!!!!')},clear() {this.map.removeLayer(this.heatLayer) // 將熱力圖從地圖上移除},// addHeatMap() {// const data = [// {// 'total': 69,// 'address': '',// 'lng': '118.281041',// 'idle': 56,// 'contactName': '',// 'busy': 13,// 'name': '豪域西巷(洪澤湖路至駱馬湖路)',// 'keyId': '117',// 'contactPhone': '',// 'lat': '33.962096'// }, {// 'total': 69,// 'address': '',// 'lng': '118.294699',// 'idle': 62,// 'contactName': '',// 'busy': 7,// 'name': '黃河路(八一路至洪澤湖路)西',// 'keyId': '60',// 'contactPhone': '',// 'lat': '33.959553'// }, {// 'total': 67,// 'address': '',// 'lng': '118.274658',// 'idle': 54,// 'contactName': '',// 'busy': 13,// 'name': '\t浦東路(發(fā)展大道至人民大道)',// 'keyId': '57',// 'contactPhone': '',// 'lat': '33.934377'// }, {// 'total': 58,// 'address': '',// 'lng': '118.276189',// 'idle': 58,// 'contactName': '',// 'busy': 0,// 'name': '發(fā)展大道(深圳路至汕頭路)東',// 'keyId': '87',// 'contactPhone': '',// 'lat': '33.92138'// }, {// 'total': 56,// 'address': '',// 'lng': '0',// 'idle': 24,// 'contactName': '',// 'busy': 32,// 'name': '洪澤湖路(世紀(jì)大道至迎賓大道)南側(cè)',// 'keyId': '38',// 'contactPhone': '',// 'lat': '0'// }, {// 'total': 54,// 'address': '',// 'lng': '118.278193',// 'idle': 37,// 'contactName': '',// 'busy': 17,// 'name': '發(fā)展大道(洞庭湖路至微山湖路)西',// 'keyId': '86',// 'contactPhone': '',// 'lat': '33.954016'// }, {// 'total': 54,// 'address': '',// 'lng': '118.292301',// 'idle': 24,// 'contactName': '',// 'busy': 30,// 'name': '飲馬堤路(項(xiàng)王路至楊公路)西',// 'keyId': '179',// 'contactPhone': '',// 'lat': '33.939144'// }, {// 'total': 54,// 'address': '',// 'lng': '118.295568',// 'idle': 35,// 'contactName': '',// 'busy': 19,// 'name': '黃河路(城北路至宿支路)西',// 'keyId': '135',// 'contactPhone': '',// 'lat': '33.974985'// }, {// 'total': 54,// 'address': '',// 'lng': '118.331987',// 'idle': 19,// 'contactName': '',// 'busy': 35,// 'name': '江山大道(洪澤湖路至五臺山路)東',// 'keyId': '77',// 'contactPhone': '',// 'lat': '33.95569'// }, { // 118.302559,34.052019// 'total': 300,// 'lng': '118.302559',// 'lat': '34.052019',// 'idle': 43,// 'keyId': '85'// }, { // 118.299685,34.004628// 'total': 10,// 'lng': '118.299685',// 'lat': '34.004628',// 'idle': 35,// 'busy': 16,// 'keyId': '86'// }, { // 118.272664,34.009895// 'total': 10,// 'lng': '118.272664',// 'lat': '34.009895',// 'idle': 35,// 'busy': 16,// 'keyId': '87'// }, { // 118.241331,33.960205// 'total': 10,// 'lng': '118.241331',// 'lat': '33.960205',// 'idle': 35,// 'busy': 16,// 'keyId': '88'// }, { // 118.228539,33.953617// 'total': 10,// 'lng': '118.228539',// 'lat': '33.953617',// 'idle': 35,// 'busy': 16,// 'keyId': '88'// }, { // 118.259872,33.952898// 'total': 10,// 'lng': '118.259872',// 'lat': '33.952898',// 'idle': 35,// 'busy': 16,// 'keyId': '88'// }, { // 118.24399,33.905751// 'total': 10,// 'lng': '118.24399',// 'lat': '33.905751',// 'idle': 35,// 'busy': 16,// 'keyId': '88'// }, { // 118.18039,33.948826// 'total': 10,// 'lng': '118.18039',// 'lat': '33.948826',// 'idle': 35,// 'busy': 16,// 'keyId': '88'// }// ]// // 熱力圖// const option = {// blur: 20,// radius: 20,// weightCallBack: (e) => { return Number(e.get('data')['total']) } // 70// }//// const createFeature = (e) => {// return new Feature({// geometry: new Point(e.lnglat || [e.lng, e.lat] || e.position),// data: e// })// }//// const features = []//// for (const i in data) {// features.push(createFeature(data[i]))// }// const source = new VectorSource({})// source.addFeatures(features)//// this.heatMapLayer = new HeatmapLayer({// source: source,// blur: option.blur || 5,// radius: option.radius || 10,// weight: (e) => {// if (option.weightCallBack) {// return option.weightCallBack(e)// }// },// zIndex: 9999999// })//// this.map.addLayer(this.heatMapLayer)// },/*** @Description 點(diǎn)擊評價(jià)回調(diào)* @Date 2019/11/18 16:17*/getAreaScorePoint(feature, event) {this.$router.push({path: '/strategy/evaluation/evaluate/area'})},/*** @Description 監(jiān)聽地圖鼠標(biāo)移動事件* @Date 2019/11/18 15:04*/pointerMove(event) {const feature = this.map.getClickFeature(event)if (feature !== undefined && feature.get('target') === 'area_score') {this.layerMap.getTargetElement().style.cursor = 'pointer'} else {this.layerMap.getTargetElement().style.cursor = 'auto'}},/*** @Date: 2019-11-04 18:08:40* @description: pointDetail組件通信獲取搜索到=出來的興趣點(diǎn)list*/handleUpdataPointList(data) {this.PointDatailList = data},/*** @date 2019/03/28 09:38:06* @Description: 查詢案件*/handleLoadAndQuery() {this.listQuery.params = []this.listQuery.params.push({key: 'position',value: this.caseQuery.position.trim(),cond: 'like'},{key: 'caseTitle',value: this.caseQuery.search_key.trim(),cond: 'like'})if (this.caseQuery.areaCode !== '-1') {this.listQuery.params.push({key: 'areaCode',value: this.caseQuery.areaCode,cond: 'like'})}if (this.caseQuery.caseSet !== '-1') {this.listQuery.actDefId = this.caseQuery.caseSet} else {delete this.listQuery.actDefId}const { current, limit } = this.pageconst listQuery = Object.assign({}, { current, limit }, this.listQuery)this.tableLoading = trueumEventApi.listEventData(listQuery).then((ret) => {this.tableLoading = falsethis.dataCollection = ret.datathis.page.total = ret.totalconst feature = this.createCaseFeature(ret.data)this.addLayerMapMarkers(feature, { isCluster: false })}).catch(() => {this.tableLoading = falsethis.dataCollection = []})},/*** @date 2019/04/02 11:16:29* @Description: 開始地圖的框選*/startMapSelect() {this.startLayerMapSelect((features) => {if (features.length > 0) {const rets = features.map((feature) => {return feature.get('id')})this.showSelectionCase = truethis.selectionCase = rets}})}} } </script>

總結(jié)

以上是生活随笔為你收集整理的Vue+Openlayers创建热力图的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。