Skip to content
This repository has been archived by the owner on Jan 27, 2024. It is now read-only.

Commit

Permalink
Merge branch 'master' of https://github.com/Arquisoft/lomap_en2b
Browse files Browse the repository at this point in the history
  • Loading branch information
andrrsin committed May 2, 2023
2 parents 3863baf + 2e80ece commit 7efdf17
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 6 deletions.
35 changes: 29 additions & 6 deletions webapp/src/pages/addLandmark/AddLandmark.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ export default function AddLandmark() {
const [isButtonEnabled, setIsButtonEnabled] = useState<boolean>(false);
const {session} = useSession();

let picture : string = "";

const setPicture = (e : string) => {
picture = e;
}

const setCoordinates = async (latitude : number, longitude : number) => {
setIsButtonEnabled(false);
(map.current as L.Map).panTo([latitude, longitude]);
Expand All @@ -48,12 +54,12 @@ export default function AddLandmark() {
let longitude : number = coords[1];

let description : string | undefined = (document.getElementById("description") as HTMLInputElement).value;
if (description.trim() === "") {
return;
}

let pictures : string[] = [];
let picture : string | undefined = (document.getElementById("images") as HTMLInputElement).value;
pictures.concat(picture);
if(picture !== "") {
pictures.push(picture);
}


let landmark : Landmark = {
name : name,
Expand Down Expand Up @@ -120,7 +126,24 @@ export default function AddLandmark() {
</FormControl>
<FormControl>
<Typography style={{color:"#FFF"}}>Add an image</Typography>
<input type="file" id="images" accept=".jpg"/>
<input type="file" id="images" accept=".jpg" onChange={function (e) {
const target = e.target as HTMLInputElement;
if (target.files == null){
return;
}
const file = target.files[0];

if (!file) {
return;
}

const reader = new FileReader();
reader.onload = (event) => {
const result = event.target?.result as string;
setPicture(result);
};
reader.readAsDataURL(file);
}}/>
</FormControl>
</Grid>
{isButtonEnabled
Expand Down
1 change: 1 addition & 0 deletions webapp/src/pages/home/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ function Home(): JSX.Element {
let element = <Marker position={[landmark.latitude, landmark.longitude]} icon={new Icon({iconUrl: markerIcon})}>
<Popup>
{landmark.name} - {landmark.category}
<img src ={landmark.pictures === undefined ? "" :landmark.pictures[0] } alt = "No images" width={200} height={200}></img>
</Popup>
</Marker>;
array.push(element);
Expand Down

0 comments on commit 7efdf17

Please sign in to comment.