Spaces:
Runtime error
Runtime error
Commit
·
53b2d2f
1
Parent(s):
a68b13b
Add marker on map to full content mode
Browse files- frontend/src/components/Map.js +3 -0
- main.py +9 -2
frontend/src/components/Map.js
CHANGED
@@ -102,6 +102,9 @@ const Map = ( { onMapClick, searchQuery, contentType } ) => {
|
|
102 |
title: data.title,
|
103 |
content: data.content
|
104 |
});
|
|
|
|
|
|
|
105 |
}
|
106 |
} catch (error) {
|
107 |
console.error("Error fetching Wikipedia content:", error);
|
|
|
102 |
title: data.title,
|
103 |
content: data.content
|
104 |
});
|
105 |
+
if (data && data.latitude && data.longitude) {
|
106 |
+
setMarkerPosition([data.latitude, data.longitude]);
|
107 |
+
}
|
108 |
}
|
109 |
} catch (error) {
|
110 |
console.error("Error fetching Wikipedia content:", error);
|
main.py
CHANGED
@@ -52,9 +52,16 @@ def search_wiki(full_page: str):
|
|
52 |
content={"error": "Page not found"},
|
53 |
status_code=404
|
54 |
)
|
55 |
-
|
|
|
|
|
56 |
return JSONResponse(
|
57 |
-
content={
|
|
|
|
|
|
|
|
|
|
|
58 |
status_code=200
|
59 |
)
|
60 |
except Exception as e:
|
|
|
52 |
content={"error": "Page not found"},
|
53 |
status_code=404
|
54 |
)
|
55 |
+
|
56 |
+
coords = loc.geocode(full_page)
|
57 |
+
|
58 |
return JSONResponse(
|
59 |
+
content={
|
60 |
+
"title": full_page,
|
61 |
+
"content": str(response.text),
|
62 |
+
"latitude": coords.latitude if coords else None,
|
63 |
+
"longitude": coords.longitude if coords else None
|
64 |
+
},
|
65 |
status_code=200
|
66 |
)
|
67 |
except Exception as e:
|