Skip to content

Commit

Permalink
fixes issue with manually inputing coordinates on tour guide app
Browse files Browse the repository at this point in the history
  • Loading branch information
filipeximenes committed Aug 27, 2024
1 parent 6ccecb7 commit a080ec2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
1 change: 0 additions & 1 deletion example/assets/js/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import "@mantine/notifications/styles.css";

import React, { useEffect, useState } from "react";
import {
Button,
Container,
createTheme,
List,
Expand Down
23 changes: 10 additions & 13 deletions example/assets/js/components/TourGuide/TourGuide.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import "@mantine/core/styles.css";
import { Container, TextInput, Button } from "@mantine/core";
import { useState } from "react";
import { useEffect, useState } from "react";
import classes from "./TourGuide.module.css";

export function TourGuide() {
Expand All @@ -9,16 +9,15 @@ export function TourGuide() {
const [attractions, setAttractions] = useState([]);
const [loading, setLoading] = useState(false);

navigator.geolocation.getCurrentPosition(
(position: any) => {
if (latitude && longitude) {
return;
}
setLatitude(position.coords.latitude);
setLongitude(position.coords.longitude);
},
(error) => console.log(error)
);
useEffect(() => {
navigator.geolocation.getCurrentPosition(
(position: any) => {
setLatitude(position.coords.latitude);
setLongitude(position.coords.longitude);
},
(error) => console.log(error)
);
}, []);

function findAttractions() {
if (!latitude || !longitude) {
Expand All @@ -42,7 +41,6 @@ export function TourGuide() {
<span className={classes.inputBlock}>
Latitude:
<TextInput
type="text"
value={latitude}
onChange={(e) => setLatitude(e.target.value)}
className={classes.coordinateInput}
Expand All @@ -51,7 +49,6 @@ export function TourGuide() {
<span className={classes.inputBlock}>
Longitude:
<TextInput
type="text"
value={longitude}
onChange={(e) => setLongitude(e.target.value)}
className={classes.coordinateInput}
Expand Down

0 comments on commit a080ec2

Please sign in to comment.