Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding export to goog maps <DO NOT MERGE> #108

Draft
wants to merge 7 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions app_vue/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions app_vue/src/assets/base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ li {
list-style: none;
margin: 16px 0;
}

3 changes: 3 additions & 0 deletions app_vue/src/assets/images/gmaps.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
50 changes: 33 additions & 17 deletions app_vue/src/components/sensorRouteBlock.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useRouteStore } from '@/stores/route_store';
import { v4 as uuidv4 } from 'uuid';
import { getMinutesString, getKmFromMeterString } from '@/utils/formattingHelper';
import draggable from 'vuedraggable';
import GmapsIcon from '@/assets/images/gmaps.svg';

const props = defineProps({
selectedRouteList: {
Expand Down Expand Up @@ -43,6 +44,17 @@ watch(
}
);

function exportToGmaps() {
// everything needs to be URL-encoded
const apiVer = '1';
const origin = encodeURIComponent(state.startPointAddress);
const destination = encodeURIComponent(state.endPointAddress);
let wayPoints = state.selectedRouteList.map((route) => `${route.lat},${route.long}`).join('|');
wayPoints = encodeURIComponent(wayPoints);
const url = `https://www.google.com/maps/dir/?api=${apiVer}&origin=${origin}&destination=${destination}&travelmode=driving&waypoints=${wayPoints}`;
window.open(url, '_blank');
}

function draggedRoute() {
state.drag = false;
routeStore.setSelectedRouteList(state.selectedRouteList); // update state with new route order
Expand Down Expand Up @@ -180,23 +192,27 @@ function exportToCSV() {
</div>

<!-- route related call-to-actions -->
<div
class="d-flex align-center"
:class="{
'justify-space-between': state.selectedRouteList && state.selectedRouteList.length > 1,
'justify-end': state.selectedRouteList && state.selectedRouteList.length <= 1
}"
>
<div v-if="state.selectedRouteList && state.selectedRouteList.length > 1">
<v-btn
class="pa-0 route-display__export"
variant="plain"
@click="exportToCSV"
>
Export route
<vue-feather type="upload"></vue-feather>
</v-btn>
</div>
<div class="d-flex flex-column align-start">
<v-btn
v-if="state.selectedRouteList && state.selectedRouteList.length > 1 && state.selectedRouteList.length <= 9"
class="pa-0 route-display__export"
variant="plain"
@click="exportToGmaps()"
>
<span class="mr-1">Open in Google Maps</span>
<GmapsIcon></GmapsIcon>
</v-btn>

<v-btn
v-if="state.selectedRouteList && state.selectedRouteList.length > 1"
class="pa-0 route-display__export"
variant="plain"
@click="exportToCSV"
>
Export route
<vue-feather type="upload"></vue-feather>
</v-btn>

<v-btn
class="route-display__delete pl-0 align-self-end"
variant="plain"
Expand Down
2 changes: 1 addition & 1 deletion app_vue/src/components/sensorSideBarRoutes.vue
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ function updateEndPoint(value) {
></SensorRouteBlock>
</section>

<!-- start and end point entry -->
<!-- start and end point entry and find routes button -->
<section v-else>
<PointAddressField
v-model="state.startPointAddress"
Expand Down
Loading