微信小程序绘制轨迹

1、map | uni-app官网

根据官网描述:通过从数据库获取POI数据,并通过 uni-id-common 内的路线规划API,计算路线、距离、时间。

2、

<map style="width:100%;height:96%;" id="myMap" :scale="scale" :longitude="longitude" :latitude="latitude"
					:markers="markers" :polyline="polyline"></map>

先绘制地图。

3、注意先添加腾讯地图的JS文件

import QQMapWX from '@/util/qqmap-wx-jssdk1.2/qqmap-wx-jssdk';

 4、轨迹和图标渲染

seelat(boxNo, orderContainerId) {
				const vm = this
				vm.$service.thirdTrackInfo({
					boxNo: boxNo,
					orderContainerId: orderContainerId,
					orderId: vm.transportOrderId
				}).then(res => {
					if (res.code == 200) {
						vm.latList = res.data ? res.data : []
						vm.polyline = []
						vm.markers = []
						if (vm.latList.length > 0) {
							let arrPosi = []
							let arrPloy = []
							this.longitude = vm.latList[0].lng
							this.latitude = vm.latList[0].lat
							vm.latList.forEach(item => {
								let obj = {
									latitude: item.lat,
									longitude: item.lng
								}
								arrPloy.push(obj)
							})
							this.polyline = [{
								points: arrPloy,
								color: '#FF0000DD',
								width: 4,
								dottedLine: false
							}];
							this.markers = [{
									iconPath: 'https:/front/end.png',
									id: 0,
									latitude: vm.latList[0].lat,
									longitude: vm.latList[0].lng,
									width: 50,
									height: 50
								},
								{
									iconPath: 'https:/back/start.png',
									id: 1,
									latitude:vm.latList.length > 0 ? vm.latList[vm.latList.length - 1].lat : '',
									longitude:vm.latList.length > 0 ? vm.latList[vm.latList.length - 1].lng: '',
									width: 50,
									height: 50
								}
							]
						}
					}
				})
			},

5、调用方法后地图轨迹就渲染出来啦

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值