This commit is contained in:
xiaozhiyong
2023-09-04 14:04:28 +08:00
parent 20728f6e13
commit 3d13ebb01d
3 changed files with 55 additions and 50 deletions

View File

@@ -152,7 +152,6 @@
}, },
methods: { methods: {
showSite() { showSite() {
console.log('footerScroll this.markers',this.markers)
let markers = encodeURIComponent(JSON.stringify(this.markers)) let markers = encodeURIComponent(JSON.stringify(this.markers))
uni.navigateTo({ uni.navigateTo({
url:`/BagStation/pages/newRoutePlanning/siteList?markers=${markers}` url:`/BagStation/pages/newRoutePlanning/siteList?markers=${markers}`

View File

@@ -7,8 +7,8 @@
:selePrice='selePrice' @dragMap='dragMap' :details='details' :polyline="polyline" :selePrice='selePrice' @dragMap='dragMap' :details='details' :polyline="polyline"
@mapEventListeners='mapEventListeners' :markers="markers" /> @mapEventListeners='mapEventListeners' :markers="markers" />
<view class="map_body"> <view class="map_body">
<map @bindregionchange='bindregionchange' @tap='poitap' @updated='mapUpdated' :scale='mapScale' <map @tap='poitap' @updated='mapUpdated' :scale='mapScale' @callouttap='callouttap'
@callouttap='callouttap' :enable-scroll='enableScroll' @markertap='markertap' :polyline="polyline" :enable-scroll='enableScroll' @markertap='markertap' :polyline="polyline"
subkey="UTXBZ-BUH6D-TQD44-HCEG4-UKOFT-U2BDN" layer-style='2' id="map_Id" :show-location="true" subkey="UTXBZ-BUH6D-TQD44-HCEG4-UKOFT-U2BDN" layer-style='2' id="map_Id" :show-location="true"
:markers="markers" class="map_xx" :latitude="coordinate.latitude" :longitude="coordinate.longitude"> :markers="markers" class="map_xx" :latitude="coordinate.latitude" :longitude="coordinate.longitude">
<cover-view slot="callout"> <cover-view slot="callout">
@@ -72,7 +72,8 @@
details: {}, details: {},
spareMarkers: [], spareMarkers: [],
selePrice: null, selePrice: null,
mapScale: 16 mapScale: 16,
firstLocation: {}
} }
}, },
onLoad(e) { onLoad(e) {
@@ -92,21 +93,18 @@
perspectives(item) { perspectives(item) {
let { let {
latitude, latitude,
longitude longitude,
siteId
} = item } = item
setTimeout(() => { setTimeout(() => {
this.newMapMoveToLocation(longitude, latitude, 'reset') this.newMapMoveToLocation(longitude, latitude, 'reset')
}, 500) }, 500)
}, },
bindregionchange(e) {
console.log(e, '***********')
},
mapUpdated(e) { mapUpdated(e) {
let that = this this.mapContext.getScale({
console.log('更新', e);
that.mapContext.getScale({
success: function(e) { success: function(e) {
console.log(e, '当前缩放比例') console.log('地图渲染回调,当前缩放系数:', e)
} }
}) })
}, },
@@ -147,6 +145,7 @@
this.spareMarkers = this.locationProcessing(markerList); this.spareMarkers = this.locationProcessing(markerList);
this.markers = await this.filterMarkers(JSON.parse(JSON.stringify(this.spareMarkers))); this.markers = await this.filterMarkers(JSON.parse(JSON.stringify(this.spareMarkers)));
this.mapScale = 10
break; break;
case 'localScreen': case 'localScreen':
// 手动筛选 备份下数据 // 手动筛选 备份下数据
@@ -179,7 +178,6 @@
this.markers = this.filterMarkers(this.markers,this.$refs.footerScroll.filter()); this.markers = this.filterMarkers(this.markers,this.$refs.footerScroll.filter());
},0) },0)
*/ */
break; break;
case 'MoveToLocation': case 'MoveToLocation':
arguments[1] ? (this.newMapMoveToLocation(this.Route.start.longitude, this.Route.start arguments[1] ? (this.newMapMoveToLocation(this.Route.start.longitude, this.Route.start
@@ -198,7 +196,7 @@
// 更新路线规划 // 更新路线规划
async mapRoutePlanning(start = this.Route.start, end = this.Route.end, strategy = 'LEAST_TIME') { async mapRoutePlanning(start = this.Route.start, end = this.Route.end, strategy = 'LEAST_TIME') {
// 获取路径 // 获取路径
let res = await this.getMapRoutePlanning(start, end, strategy); let res = await this.getMapRoutePlanning(start, end);
//处理数据 //处理数据
this.polyline = this.RoutePlanningHandle(res); this.polyline = this.RoutePlanningHandle(res);
//缩放显示所有经纬度 //缩放显示所有经纬度
@@ -266,7 +264,11 @@
}) })
}, },
//获取路线规划 //获取路线规划
getMapRoutePlanning(start, end, strategy = 'LEAST_TIME') { getMapRoutePlanning(start, end) {
let {
seleIndex
} = this.$refs.footerScroll.$data
var _this = this; var _this = this;
return new Promise(function(res, rej) { return new Promise(function(res, rej) {
_this.TXSDK.direction({ _this.TXSDK.direction({
@@ -274,7 +276,7 @@
mode: 'driving', mode: 'driving',
from: start, from: start,
to: end, to: end,
policy: strategy, policy: seleIndex || 'LEAST_TIME',
success: function(e) { success: function(e) {
console.log('获取路线规划成功') console.log('获取路线规划成功')
res(e) res(e)
@@ -324,12 +326,6 @@
zoomRoutePlanning(points, padding) { zoomRoutePlanning(points, padding) {
let that = this let that = this
let system = uni.getSystemInfoSync().platform; let system = uni.getSystemInfoSync().platform;
// setTimeout(()=>{
// uni.showToast({
// title: system,
// icon: 'none'
// })
// },1000)
try { try {
let paddingTop = this.$refs.addressSelector.getElement(); let paddingTop = this.$refs.addressSelector.getElement();
this.mapContext.includePoints({ this.mapContext.includePoints({
@@ -361,14 +357,20 @@
}, },
//更新markers点 //更新markers点
async mapUpdateMarkers(points = this.polyline[0].points, oilProductCode = '0#', juLi = '5', siteChannel = '') { async mapUpdateMarkers(points = this.polyline[0].points, oilProductCode = '0#', juLi = '5', siteChannel = '') {
//标记
let {
latitude,
longitude
} = this.firstLocation
let data = { let data = {
geoList: points, geoList: points,
oilProductCode: oilProductCode ? oilProductCode : '0#', oilProductCode: oilProductCode ? oilProductCode : '0#',
juLi: juLi ? juLi : '5', juLi: juLi ? juLi : '5',
siteChannel: siteChannel, siteChannel: siteChannel,
countJuLi: points[0].distance, countJuLi: points[0].distance,
latitude: this.coordinate.latitude, latitude: latitude || this.coordinate.latitude,
longitude: this.coordinate.longitude longitude: longitude || this.coordinate.longitude
} }
let taht = this; let taht = this;
return new Promise(function(re, rj) { return new Promise(function(re, rj) {
@@ -393,11 +395,10 @@
}, },
//定位处理 //定位处理
locationProcessing(markerList) { locationProcessing(markerList) {
// console.log(markerList, '----')
markerList.forEach((item, index) => { markerList.forEach((item, index) => {
let configure = { let configure = {
siteId: item.id, siteId: item.id,
id: Number(`${index}`), id: Number(`${index}`), //2023.08.30 在此处踩坑 一作这b竟然把id重新赋值了
imgCustomCallout: this.olitype(item.siteChannel), imgCustomCallout: this.olitype(item.siteChannel),
iconPath: '../../static/img/tt.png', iconPath: '../../static/img/tt.png',
width: 5, width: 5,
@@ -417,13 +418,11 @@
//点击气泡事件 //点击气泡事件
async callouttap(e) { async callouttap(e) {
let seleMark = this.markers.filter(item => item.id == e.detail.markerId); let seleMark = this.markers.filter(item => item.id == e.detail.markerId);
// this.enableScroll = true
let details = await oilSiteApi.getSiteDetails({ let details = await oilSiteApi.getSiteDetails({
latitude: String(this.coordinate.latitude), latitude: String(this.firstLocation.latitude),
longitude: String(this.coordinate.longitude), longitude: String(this.firstLocation.longitude),
siteId: seleMark[0].siteId siteId: seleMark[0].siteId
}); });
// console.log(details, '***')
if (details.code !== 20000) { if (details.code !== 20000) {
uni.showToast({ uni.showToast({
title: details.msg, title: details.msg,
@@ -441,16 +440,25 @@
}, },
//获取当前位置 //获取当前位置
getCurrentLocation() { getCurrentLocation() {
let that = this // let that = this
uni.getLocation({ uni.getLocation({
type: 'gcj02', type: 'gcj02',
success: function(res) { success: (res) => {
({ // ({
latitude: that.coordinate.latitude, // latitude: that.coordinate.latitude,
longitude: that.coordinate.longitude // longitude: that.coordinate.longitude
} = res); // } = res);
that.myLocation = res; let {
that.Route.start = Object.assign(that.Route.start, that.coordinate); latitude,
longitude
} = res
this.coordinate.latitude = latitude
this.firstLocation.latitude = latitude
this.coordinate.longitude = longitude
this.firstLocation.longitude = longitude
this.myLocation = res;
this.Route.start = Object.assign(this.Route.start, this.coordinate);
} }
}); });
}, },
@@ -460,19 +468,18 @@
this.mapContext.moveToLocation({ this.mapContext.moveToLocation({
longitude: longitude, longitude: longitude,
latitude: latitude, latitude: latitude,
success(e) { success: (e) => {
console.log(`移动 坐标→ ${longitude}-${latitude}`); console.log(`移动 坐标→ ${longitude}-${latitude}`);
if (type) { if (type) {
that.coordinate.latitude = latitude this.coordinate.latitude = latitude
that.coordinate.longitude = longitude this.coordinate.longitude = longitude
that.mapContext.getScale({
success: function(e) { this.mapContext.getScale({
setTimeout(() => { success: res => {
that.mapScale = e.scale; this.mapScale = res.scale
setTimeout(() => { this.$nextTick(() => {
that.mapScale = 13 this.mapScale = 13
}, 500) })
}, 500)
} }
}) })
} }

View File

@@ -36,7 +36,6 @@
if (!options.markers) return if (!options.markers) return
let markers = JSON.parse(decodeURIComponent(options.markers)) let markers = JSON.parse(decodeURIComponent(options.markers))
this.siteList = markers this.siteList = markers
console.log('site markers', markers)
}, },
filters: { filters: {
adjust(val) { adjust(val) {