From 91a3e75125a3f1cdf0a7b080de2d41082b1f6359 Mon Sep 17 00:00:00 2001 From: Ana Marija Atanasovska Date: Mon, 12 Feb 2024 11:22:01 +0100 Subject: [PATCH] improvements --- src/components/MapWidget.tsx | 19 +++++++++++++------ src/stores/locationStore.ts | 8 ++++---- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/components/MapWidget.tsx b/src/components/MapWidget.tsx index 9e3a2bf..eb75a81 100644 --- a/src/components/MapWidget.tsx +++ b/src/components/MapWidget.tsx @@ -1,16 +1,23 @@ import { useLocationStore } from "@stores/locationStore"; -import {Text, View} from "react-native" import {WebView} from "react-native-webview" +import LoadingSpinner from "./LoadingSpinner"; const MapWidget = () => { const latitude = useLocationStore((state) => state.latitude); const longitude = useLocationStore((state) => state.longitude); - const prep_uri = 'www.google.com/maps/dir/'+latitude+','+longitude+'/Faculty+of+Computer+Science+%26+Engineering,+Rugjer+Boshkovikj,+Skopje/'+ - '@44.8831698,13.6218345,4z/data=!3m1!4b1!4m9!4m8!1m1!4e1!1m5!1m1!1s0x13541443605aa4ab:0x33d56647e5b87264!2m2!1d21.4095479!2d42.0041182?entry=ttu' - return + if(latitude != null && longitude != null) + { + const prep_uri = 'www.google.com/maps/dir/'+latitude+','+longitude+'/Faculty+of+Computer+Science+%26+Engineering,+Rugjer+Boshkovikj,+Skopje/'+ + '@44.8831698,13.6218345,4z/data=!3m1!4b1!4m9!4m8!1m1!4e1!1m5!1m1!1s0x13541443605aa4ab:0x33d56647e5b87264!2m2!1d21.4095479!2d42.0041182?entry=ttu' + return + } + else + { + return + } } export default MapWidget; \ No newline at end of file diff --git a/src/stores/locationStore.ts b/src/stores/locationStore.ts index 1fb732a..821786f 100644 --- a/src/stores/locationStore.ts +++ b/src/stores/locationStore.ts @@ -1,15 +1,15 @@ import { create } from "zustand"; type LocationStore = { - latitude: number, - longitude: number, + latitude: number | null, + longitude: number | null, setLatitude: (latitude: number) => void; setLongitude: (longitude: number) => void; }; export const useLocationStore = create((set) => ({ - latitude: 0, - longitude: 0, + latitude: null, + longitude: null, setLatitude: (latitude: number) => set({ latitude }), setLongitude: (longitude: number) => set({ longitude }) }));