Display a polyline with the previous positions

This commit is contained in:
Lucas Verney 2018-07-09 15:25:18 +02:00
parent 3d134d438d
commit ae9f3892c7
2 changed files with 5 additions and 1 deletions

View File

@ -7,6 +7,7 @@
<v-lcirclemarker v-else :lat-lng="positionLatLng" :color="markerOptions.color" :fillColor="markerOptions.fillColor" :fillOpacity="1.0" :weight="markerOptions.weight" :radius="markerRadius"></v-lcirclemarker> <v-lcirclemarker v-else :lat-lng="positionLatLng" :color="markerOptions.color" :fillColor="markerOptions.fillColor" :fillOpacity="1.0" :weight="markerOptions.weight" :radius="markerRadius"></v-lcirclemarker>
<v-lcircle v-if="shouldDisplayAccuracy" :lat-lng="positionLatLng" :radius="radiusFromAccuracy"></v-lcircle> <v-lcircle v-if="shouldDisplayAccuracy" :lat-lng="positionLatLng" :radius="radiusFromAccuracy"></v-lcircle>
<v-lpolyline :latLngs="polyline" :opacity="0.6" color="#00FF00"></v-lpolyline>
<ReportMarker v-for="marker in markers" :key="marker.id" :marker="marker"></ReportMarker> <ReportMarker v-for="marker in markers" :key="marker.id" :marker="marker"></ReportMarker>
</v-lmap> </v-lmap>
@ -58,6 +59,7 @@ export default {
heading: Number, heading: Number,
markers: Array, markers: Array,
onPress: Function, onPress: Function,
polyline: Array,
positionLatLng: Array, positionLatLng: Array,
}, },
computed: { computed: {

View File

@ -10,7 +10,7 @@
<v-layout v-else row wrap fill-height> <v-layout v-else row wrap fill-height>
<ReportCard></ReportCard> <ReportCard></ReportCard>
<v-flex xs12 fill-height v-if="latLng"> <v-flex xs12 fill-height v-if="latLng">
<Map :positionLatLng="latLng" :heading="heading" :accuracy="accuracy" :markers="reportsMarkers" :onPress="showReportDialog"></Map> <Map :positionLatLng="latLng" :polyline="positionHistory" :heading="heading" :accuracy="accuracy" :markers="reportsMarkers" :onPress="showReportDialog"></Map>
<v-btn <v-btn
absolute absolute
dark dark
@ -83,6 +83,7 @@ export default {
isIntro: true, isIntro: true,
latLng: null, latLng: null,
noSleep: null, noSleep: null,
positionHistory: [],
reportLat: null, reportLat: null,
reportLng: null, reportLng: null,
watchID: null, watchID: null,
@ -138,6 +139,7 @@ export default {
} }
} }
this.latLng = [position.coords.latitude, position.coords.longitude]; this.latLng = [position.coords.latitude, position.coords.longitude];
this.positionHistory.push(this.latLng);
this.heading = Object.prototype.hasOwnProperty.call(position.coords, 'heading') ? position.coords.heading : null; this.heading = Object.prototype.hasOwnProperty.call(position.coords, 'heading') ? position.coords.heading : null;
this.accuracy = position.coords.accuracy ? position.coords.accuracy : null; this.accuracy = position.coords.accuracy ? position.coords.accuracy : null;
}, },