骑行轨迹展示

This commit is contained in:
dzl 2025-05-20 14:30:52 +08:00
parent c09de480a1
commit 9083f88541
5 changed files with 90 additions and 53 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@ -869,6 +869,8 @@ const viewOrderInfo = (record) => {
ebikeCode: record['ebikeCode'], ebikeCode: record['ebikeCode'],
startTime: record['startTime'], startTime: record['startTime'],
endTime: record['endTime'], endTime: record['endTime'],
ridePoint: record['ridePoint'],
returnPoint: record['returnPoint'],
} }
formModelOrderInfo.value.openForm(params); formModelOrderInfo.value.openForm(params);
} else { } else {

View File

@ -5,23 +5,30 @@
> >
<tlbs-map <tlbs-map
ref="mapRef" ref="mapRef"
:api-key="config.map.apiKey" api-key="OB4BZ-D4W3U-B7VVO-4PJWW-6TKDJ-WPB77"
:center="center" :center="center"
zoom="16" :zoom="zoom"
:control="control" :control="control"
:options="options" @click="onClick"
@map_inited="onMapInited" @map_inited="onMapInited"
> >
<tlbs-geometry-editor <tlbs-multi-polyline
ref="editorRef" ref="polylineRef"
action-mode="draw" :geometries="geometriesLine"
selectable :styles="styles"
@draw_complete="onDrowComplet" :options="options"
@draw_error="onDrawError"
@adjust_complete="onAdjustComplete"
@adjust_error="onAdjustError"
@delete_complete="onDeleteComplete"
/> />
<tlbs-multi-marker
ref="markerRef"
:geometries="geometriesPoint"
:styles="styles"
:options="options"
/>
<div class="control-container">
<button @click.stop="getLayerInstance">
打印折线实例
</button>
</div>
</tlbs-map> </tlbs-map>
</div> </div>
</template> </template>
@ -44,11 +51,42 @@ const props = defineProps({
}); });
const mapRef = ref(null); const mapRef = ref(null);
const center = ref(config.map.center); const polylineRef = ref(null);
const control = ref({ scale: {}, zoom: { position: 'topRight', }, }); const center = ref({ lat: 0, lng: 0 });
const options = ref({ renderOptions: { renderOptions: true, } }); const zoom = ref(16);
const editorRef = ref(null);
const points = ref([]) const control = ref({
scale: {},
zoom: {
position: 'topRight',
},
});
const geometriesLine = ref([]);
const geometriesPoint = ref([]);
const styles = ref({
polyline: {
color: '#2C68FF', // 线
borderWidth: 1, // 线
borderColor: '#004EE1', // 线
},
markerStart: {
width: 40,
height: 40,
src: '/src/assets/startPoint.png'
},
markerEnd: {
width: 40,
height: 40,
src: '/src/assets/endPoint.png'
},
});
const options = ref({
zIndex: 1,
});
const onMapInited = () => { const onMapInited = () => {
if (mapRef.value) { if (mapRef.value) {
const windowWidth = window.innerWidth; const windowWidth = window.innerWidth;
@ -71,47 +109,42 @@ const onMapInited = () => {
return return
} }
if (res.data) { if (res.data) {
points.value = res.data center.value = { lat: props.orderParams.ridePoint.split(",")[1], lng: props.orderParams.ridePoint.split(",")[0] }
loadGeometry(); const trajectory = [{ lat: props.orderParams.ridePoint.split(",")[1], lng: props.orderParams.ridePoint.split(",")[0] }];
res.data.map(item => {
trajectory.push({ lat: item['latitude'], lng: item['longitude'] })
})
trajectory.push({ lat: props.orderParams.returnPoint.split(",")[1], lng: props.orderParams.returnPoint.split(",")[0] })
geometriesLine.value = [
{
id: 'polyline1',
styleId: 'polyline',
paths: trajectory,
properties: {
title: 'polyline',
},
}
]
geometriesPoint.value = [
{
styleId: 'markerStart', position: {
lat: parseFloat(props.orderParams.ridePoint.split(",")[1]),
lng: parseFloat(props.orderParams.ridePoint.split(",")[0])
}
},
{
styleId: 'markerEnd', position: {
lat: parseFloat(props.orderParams.returnPoint.split(",")[1]),
lng: parseFloat(props.orderParams.returnPoint.split(",")[0])
}
},
]
} }
}); });
} }
} }
}; };
const loadGeometry = () => {
if (points.value.length > 0) {
const circleGeometries = [];//editorRef.value.circle.getGeometries();
if (circleGeometries.length > 0) {
circleGeometries.forEach((geometry) => {
editorRef.value.circle.remove(geometry); //
});
}
const trajectory = points.value.map(item => {
return new TMap.LatLng(item['latitude'], item['longitude'])
})
const shapeId = getGUID()
circleGeometries.push({
id: shapeId,
style: new TMap.PolylineStyle({
'color': '#blue', //线
'width': 6, //线
'borderWidth': 5, //线
'borderColor': 'red', //线
'lineCap': 'round' //线
}),
paths: trajectory,
center: new TMap.LatLng(points.value[0].latitude, points.value[0].longitude),
});
editorRef.value.circle.setGeometries(circleGeometries);
//
const mycircle = editorRef.value.circle.getGeometryById(shapeId);
const boundary = TMap.geometry.computeBoundingRectangle(mycircle.paths);
mapRef.value.map.fitBounds(boundary, {
padding: 100, //
});
}
}
</script> </script>

View File

@ -43,6 +43,8 @@ const openForm = (params = {}) => {
orderParams.value['ebikeCode'] = params['ebikeCode']; orderParams.value['ebikeCode'] = params['ebikeCode'];
orderParams.value['startTime'] = params['startTime']; orderParams.value['startTime'] = params['startTime'];
orderParams.value['endTime'] = params['endTime']; orderParams.value['endTime'] = params['endTime'];
orderParams.value['ridePoint'] = params['ridePoint'];
orderParams.value['returnPoint'] = params['returnPoint'];
} }
}; };