国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

uniapp 微信小程序?qū)崿F(xiàn)運動軌跡、行車軌跡、歷史軌跡、軌跡回放、不同速度有不同的路線顏色

這篇具有很好參考價值的文章主要介紹了uniapp 微信小程序?qū)崿F(xiàn)運動軌跡、行車軌跡、歷史軌跡、軌跡回放、不同速度有不同的路線顏色。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點擊"舉報違法"按鈕提交疑問。

先看效果

uniapp 微信小程序?qū)崿F(xiàn)運動軌跡、行車軌跡、歷史軌跡、軌跡回放、不同速度有不同的路線顏色

實現(xiàn)效果:

  1. 根據(jù)不同速度繪制不同顏色的軌跡
  2. 根據(jù)終點起點獲取地圖中心點,盡可能在屏幕內(nèi)完全展示軌跡
  3. 獲取最快的路段并顯示
  4. 自定義點圖標

實現(xiàn)步驟:

  1. map組件

view標簽部分

<template>
	<view>
		<map id="map1" 
		:longitude="longitude"
		:latitude="latitude"
		:markers="markers" 
		:scale="scale"
		:polyline="polyline"
		:style="{height: height,width:width}"
		></map>
	</view>
</template>

js部分


<script>
export default {
	props: {
		height: {
			type: String,
			default: '100vh'
		},
		width: {
			type: String,
			default: '100%'
		},
		points: {
			type: Array,
			default() {
				return []
			}
		},
	},
	data() {
		return {
			maxSpeed: null, // 最快速度的點
			scale: 3, // 地圖縮放比例
			markers: [], // 標記點集合
			polyline: [{  
				points: [],
			},], // 坐標點集合
			
			latitude: 39.806466,
			longitude: 98.226473,
			
			centerPoint: {
				latitude: 0,
				longitude: 0
			}, // 中間點
		}
	},
	watch: {
		points(e) {
			let that = this;
			if (that.points.length > 0) {
				that.setDateByPoints(that.points);
			}

		},
	},
	created: function () {
		let that = this;
		if (that.points.length > 0) {
			that.setDateByPoints(that.points);
		}
	},
	methods: {
		// 根據(jù)速度計算路線顏色
		computePointsSpeed(points) {
			let lineColor = '#ffd500'
			let list = []

			if (!points || !points.length) {
				return list
			}

			let lastArr = []
			let lastSpeed = 0
			for (let i = 0; i < points.length; i++) {
				let speed = this.covertSpeed(points[i].speed)
				if (!this.maxSpeed) {
					this.maxSpeed = points[i]
				} else {
					if (points[i].speed > this.maxSpeed.speed) {
						this.maxSpeed = points[i]
					}
				}
				if (i === points.length - 1 || !speed) {
					// 還剩最后一個不計入
					continue
				}
				let nextPoint = points[i + 1]
				let nextSpeed = this.covertSpeed(points[i + 1].speed)
				if (!nextSpeed) {
					continue
				}
				lastSpeed = speed
				if (!lastArr.length) {
					lastArr.push(points[i], nextPoint)
				} else {
					lastArr.push(nextPoint)
				}
				if (speed <= 20) {
					lineColor = '#ffd500'
					if (nextSpeed > 20) {
						// 清空
						list.push({
							points: lastArr,
							color: lineColor,
							arrowLine: true, //帶箭頭的線
							width: 8,
						})
						lastArr = []
					}
				}
				if (speed > 20 && speed <= 40) {
					lineColor = '#ff8800'
					if (nextSpeed <= 20 || nextSpeed > 40) {
						// 清空
						list.push({
							points: lastArr,
							color: lineColor,
							arrowLine: true, //帶箭頭的線
							width: 8,
						})
						lastArr = []
					}
				}
				if (speed > 40 && speed <= 60) {
					lineColor = '#ff5d00'
					if (nextSpeed <= 40 || nextSpeed > 60) {
						// 清空
						list.push({
							points: lastArr,
							color: lineColor,
							arrowLine: true, //帶箭頭的線
							width: 8,
						})
						lastArr = []
					}

				}
				if (speed > 60 && speed <= 80) {
					lineColor = '#ff4d00'
					if (nextSpeed <= 60 || nextSpeed > 80) {
						// 清空
						list.push({
							points: lastArr,
							color: lineColor,
							arrowLine: true, //帶箭頭的線
							width: 8,
						})
						lastArr = []
					}
				}
				if (speed > 80 && speed <= 100) {
					lineColor = '#ff3d00'
					if (nextSpeed <= 80 || nextSpeed > 100) {
						// 清空
						list.push({
							points: lastArr,
							color: lineColor,
							arrowLine: true, //帶箭頭的線
							width: 8,
						})
						lastArr = []
					}
				}
				if (speed > 100 && speed <= 120) {
					lineColor = '#ff2d00'
					if (nextSpeed <= 100 || nextSpeed > 120) {
						// 清空
						list.push({
							points: lastArr,
							color: lineColor,
							arrowLine: true, //帶箭頭的線
							width: 8,
						})
						lastArr = []
					}
				}
				if (speed > 120) {
					lineColor = '#ff1d00'
					if (nextSpeed <= 120) {
						// 清空
						list.push({
							points: lastArr,
							color: lineColor,
							arrowLine: true, //帶箭頭的線
							width: 8,
						})
						lastArr = []
					}
				}
			}
			this.centerPoint = points[Math.round(points.length / 2)]
			console.log("centerPoint", this.centerPoint)
			if (!list.length && lastArr.length) {
				list.push({
					points: lastArr,
					color: lineColor,
					arrowLine: true, //帶箭頭的線
					width: 8,
				})
			}
			return list
		},
		// 設(shè)置路線和點
		setDateByPoints(points) {
			let that = this;
			let color = "#ffd500"
			// 標記點集合
			that.polyline = this.computePointsSpeed(points)
			if (!that.polyline.length) {
				that.polyline = [{
					points: points,
					color: color,
					arrowLine: true, //帶箭頭的線
					width: 8,
				}]
			}
			if (that.maxSpeed) {
				that.maxSpeed.iconPath = '../../static/icon/map/flash.png'
				that.maxSpeed.width = 24
				that.maxSpeed.height = 24
				that.maxSpeed.id = 2
				that.maxSpeed.callout = {
					color: '#5d5d5d',
					fontSize: 14,
					borderRadius: 6,
					padding: 8,
					bgColor: '#fff',
					content: `極速 ${this.covertSpeed(this.maxSpeed.speed)} km/h`
				}
				that.markers.push(this.maxSpeed)
			}
			let start = points[0]
			let end = points[points.length - 1]
			start.id = 1
			start.width = 35
			start.height = 35
			start.iconPath = '../../static/icon/map/start.png'
			end.id = 3
			end.width = 35
			end.height = 35
			end.iconPath = '../../static/icon/map/end.png'
			that.markers.push(start, end);
			this.setCenterPoint(start, end)
		},
		// 地圖中心點 (計算3個點的中心點)
		setCenterPoint(start, end) {
			this.longitude = (start.longitude + this.centerPoint.longitude + end.longitude) / 3
			this.latitude = (start.latitude + this.centerPoint.latitude + end.latitude) / 3
			let distance1 = this.getDistance(start.latitude, start.longitude, this.centerPoint.latitude, this.centerPoint.longitude)
			let distance2 = this.getDistance(this.centerPoint.latitude, this.centerPoint.longitude, end.latitude, end.longitude)
			const distance = Number(distance1) + Number(distance2)
			console.log('計算兩點之間的距離', distance1, distance2, distance)
			if (distance < 200) {
				this.scale = 17
			}
			if (distance >= 200 && distance < 1000) {
				this.scale = 15
			}
			if (distance >= 1000 && distance < 5000) {
				this.scale = 13
			}
			if (distance >= 5000 && distance < 10000) {
				this.scale = 12
			}
			if (distance >= 10000 && distance < 15000) {
				this.scale = 11
			}
			if (distance >= 15000 && distance < 50000) {
				this.scale = 10
			}
			if (distance >= 50000 && distance < 200000) {
				this.scale = 8
			}
			if (distance > 200000) {
				this.scale = 5
			}
		},
		// 速度轉(zhuǎn)換 m/s -> km/h
		covertSpeed(ms) {
			if (ms <= 0) {
				return 0.00
			}
			const kmh = ms * (60 * 60)
			return parseFloat(String(kmh / 1000)).toFixed(2)
		},
		// 計算兩坐標點之間的距離
		getDistance: function (lat1, lng1, lat2, lng2) {
			let rad1 = lat1 * Math.PI / 180.0;
			let rad2 = lat2 * Math.PI / 180.0;
			let a = rad1 - rad2;
			let b = lng1 * Math.PI / 180.0 - lng2 * Math.PI / 180.0;
			let r = 6378137;
			return (r * 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) + Math.cos(rad1) * Math.cos(rad2) * Math.pow(Math
				.sin(b / 2), 2)))).toFixed(0)

		},

	},
}
</script>

points 數(shù)據(jù)格式


points:[
	{
		latitude: 22,
		longitude: 98, 
		speed: 6.4352341234, //speed m/s
	},
	{
		latitude: 22,
		longitude: 98, 
		speed: 6.4352341234, //speed m/s
	},
	{
		latitude: 22,
		longitude: 98, 
		speed: 6.4352341234, //speed m/s
	}
]

注意:由于小程序會不斷更新迭代,源碼和體驗效果可能有一定的差異。

轉(zhuǎn)載務(wù)必說明出處文章來源地址http://www.zghlxwxcb.cn/news/detail-514109.html

到了這里,關(guān)于uniapp 微信小程序?qū)崿F(xiàn)運動軌跡、行車軌跡、歷史軌跡、軌跡回放、不同速度有不同的路線顏色的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務(wù),不擁有所有權(quán),不承擔相關(guān)法律責任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實不符,請點擊違法舉報進行投訴反饋,一經(jīng)查實,立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費用

相關(guān)文章

  • uniapp運動課程健身打卡系統(tǒng)微信小程序

    uniapp運動課程健身打卡系統(tǒng)微信小程序

    考慮到實際生活中在我來運動管理方面的需要以及對該系統(tǒng)認真的分析,將系統(tǒng)分為小程序端模塊和后臺管理員模塊,權(quán)限按管理員和用戶這兩類涉及用戶劃分。 (a) 管理員;管理員使用本系統(tǒng)涉到的功能主要有:首頁、個人中心、用戶管理、課程類別管理、運動課程管理、課

    2024年02月21日
    瀏覽(23)
  • uniapp微信小程序獲取微信運動步數(shù)(保姆級教程)

    uniapp微信小程序獲取微信運動步數(shù)(保姆級教程)

    官方文檔 https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/signature.html 可以先了解一下,然后下載對應(yīng)的解密文件 找到對應(yīng)的解密語言版本,老師這里用的uniapp,只能選擇node版 這里有具體的案例,可以參考一下,直接在代碼中導(dǎo)入,在上面的getStepInfo方法中直接實例化

    2024年02月06日
    瀏覽(94)
  • 微信小程序原生使用map組件實現(xiàn)軌跡、多邊形

    使用地圖本身的map組件實現(xiàn)地圖 初始化地圖: map組件的屬性 longitude 必須 Number 中心點經(jīng)度 latitude 必須 Number 中心點緯度 scale 選填 Number 地圖的縮放級別(縮放切換時使用) include-points 選填 Array. 縮放視野以展示所有坐標點 markers 選填 Array. 地圖展示的坐標點集合 polyline 選填

    2024年02月03日
    瀏覽(100)
  • 微信小程序校園運動場地預(yù)約系統(tǒng)設(shè)計與實現(xiàn)

    微信小程序校園運動場地預(yù)約系統(tǒng)設(shè)計與實現(xiàn)

    ?博主介紹 :黃菊華老師《Vue.js入門與商城開發(fā)實戰(zhàn)》《微信小程序商城開發(fā)》圖書作者,CSDN博客專家,在線教育專家,CSDN鉆石講師;專注大學(xué)生畢業(yè)設(shè)計教育和輔導(dǎo)。 所有項目都配有從入門到精通的基礎(chǔ)知識視頻課程,免費 項目配有對應(yīng)開發(fā)文檔、開題報告、任務(wù)書、

    2024年02月04日
    瀏覽(19)
  • 基于php微信小程序運動場地預(yù)約系統(tǒng)設(shè)計與實現(xiàn)

    基于php微信小程序運動場地預(yù)約系統(tǒng)設(shè)計與實現(xiàn)

    開發(fā)概要 開發(fā)操作系統(tǒng):windows10 + 4G內(nèi)存 + 500G 小程序開發(fā):微信開發(fā)者工具(MINA框架) 后臺環(huán)境:IIS +PHP 后臺開發(fā)語言:PHP 后臺開發(fā)工具:Dreamweaver +PhpStorm 數(shù)據(jù)庫:mysql8 數(shù)據(jù)庫管理工具:navicat 其他開發(fā)語言:html + css +javascript

    2024年02月11日
    瀏覽(25)
  • 基于Springboot+Mybatis+微信小程序?qū)崿F(xiàn)小型運動管理平臺

    基于Springboot+Mybatis+微信小程序?qū)崿F(xiàn)小型運動管理平臺

    此文主要功能包括:運動健康平臺登錄注冊、了解健康知識、查看管理運動的文章與詳情、每日登錄打卡、系統(tǒng)通知、留言管理、提交運動功能。使用Java作為后端語言進行支持,界面友好,開發(fā)簡單。 2.1、下載安裝IntelliJ IDEA(后端語言開發(fā)工具),Mysql數(shù)據(jù)庫,微信Web開發(fā)者工

    2024年02月02日
    瀏覽(21)
  • 微信小程序畢業(yè)設(shè)計作品成品(07)微信小程序校園體育館運動場地預(yù)約系統(tǒng)設(shè)計與實現(xiàn)

    微信小程序畢業(yè)設(shè)計作品成品(07)微信小程序校園體育館運動場地預(yù)約系統(tǒng)設(shè)計與實現(xiàn)

    博主介紹: 《Vue.js入門與商城開發(fā)實戰(zhàn)》《微信小程序商城開發(fā)》圖書作者,CSDN博客專家,在線教育專家,CSDN鉆石講師;專注大學(xué)生畢業(yè)設(shè)計教育和輔導(dǎo)。 所有項目都配有從入門到精通的基礎(chǔ)知識視頻課程,免費 項目配有對應(yīng)開發(fā)文檔、開題報告、任務(wù)書、PPT、論文模版

    2024年02月08日
    瀏覽(96)
  • 基于微信小程序的跑步運動計劃小程序設(shè)計與實現(xiàn)

    基于微信小程序的跑步運動計劃小程序設(shè)計與實現(xiàn)

    ??博主介紹:?全網(wǎng)粉絲10W+,CSDN全棧領(lǐng)域優(yōu)質(zhì)創(chuàng)作者,博客之星、掘金/華為云/阿里云等平臺優(yōu)質(zhì)作者。 ???? 精彩專欄 推薦訂閱???? 計算機畢業(yè)設(shè)計精品項目案例(持續(xù)更新) ?? 文末獲取源碼+數(shù)據(jù)庫+文檔 ?? 感興趣的可以先收藏起來,還有大家在畢設(shè)選題,項目以及

    2024年01月23日
    瀏覽(38)
  • 基于JSP微信小程序校園運動會報名系統(tǒng)設(shè)計與實現(xiàn)

    基于JSP微信小程序校園運動會報名系統(tǒng)設(shè)計與實現(xiàn)

    【后臺管理員功能】 錄入資訊:錄入資訊標題、內(nèi)容等信息 管理資訊:查看已錄入資訊列表,支持刪除和修改 會員列表:查看所有注冊會員信息,支持刪除 廣告設(shè)置:上傳圖片和設(shè)置小程序首頁輪播圖廣告地址 留言列表:所有用戶留言信息列表,支持刪除 錄入比賽項目:

    2024年02月12日
    瀏覽(92)
  • 基于微信小程序的高校運動會管理系統(tǒng)設(shè)計與實現(xiàn)

    基于微信小程序的高校運動會管理系統(tǒng)設(shè)計與實現(xiàn)

    ??博主介紹:?全網(wǎng)粉絲10W+,CSDN全棧領(lǐng)域優(yōu)質(zhì)創(chuàng)作者,博客之星、掘金/華為云/阿里云等平臺優(yōu)質(zhì)作者。 ???? 精彩專欄 推薦訂閱???? 計算機畢業(yè)設(shè)計精品項目案例(持續(xù)更新) ?? 文末獲取源碼+數(shù)據(jù)庫+文檔 ?? 感興趣的可以先收藏起來,還有大家在畢設(shè)選題,項目以及

    2024年01月20日
    瀏覽(31)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包