final fix

This commit is contained in:
Pablo Ferreiro 2024-10-17 20:29:22 +02:00
parent 7468d74b92
commit b15207d18d
3 changed files with 15 additions and 9 deletions

View File

@ -5,7 +5,7 @@ import Navbar from "../partials/Navbar";
import Loader from "../partials/Loader"; import Loader from "../partials/Loader";
import Api from "../helpers/Api"; import Api from "../helpers/Api";
import Card from "../partials/Card"; import Card from "../partials/Card";
import { FaSolidLocationDot, FaSolidMapLocationDot, FaSolidWater } from "solid-icons/fa"; import { FaSolidCircleInfo, FaSolidLocationDot, FaSolidMapLocationDot, FaSolidWater } from "solid-icons/fa";
import OpenWeather from "../helpers/OpenWeather"; import OpenWeather from "../helpers/OpenWeather";
interface CustomParams extends Params { interface CustomParams extends Params {

View File

@ -25,7 +25,7 @@ function Home() {
<span>Malackathon</span> <span>Malackathon</span>
</span> </span>
</p> </p>
<div class="buttons"> <div class="buttons is-centered">
<A class="button is-primary" href="/embalses">Todos los embalses</A> <A class="button is-primary" href="/embalses">Todos los embalses</A>
<A class="button is-primary" href="/embalses/nearby">Buscar</A> <A class="button is-primary" href="/embalses/nearby">Buscar</A>
</div> </div>

View File

@ -2,8 +2,11 @@ import { onMount } from "solid-js";
import L from 'leaflet'; import L from 'leaflet';
import Embalse from "../interfaces/Embalse"; import Embalse from "../interfaces/Embalse";
import Api from "../helpers/Api"; import Api from "../helpers/Api";
import { useNavigate } from "@solidjs/router";
import Navbar from "../partials/Navbar";
function Viewer() { function Viewer() {
const navigate = useNavigate();
let map: L.Map; let map: L.Map;
let embalses: Embalse[] = []; let embalses: Embalse[] = [];
@ -21,17 +24,20 @@ function Viewer() {
const getEmbalses = async () => { const getEmbalses = async () => {
embalses = await Api.embalses(); embalses = await Api.embalses();
embalses.forEach(embalse => { embalses.forEach(c => {
L.marker([parseFloat(embalse.x), parseFloat(embalse.y)]).addTo(map); L.marker([parseFloat(c.x), parseFloat(c.y)]).on('click', () => navigate('/embalses/' + c.id)).addTo(map);
}); });
} }
return ( return (
<div class="container"> <>
<div id="map" style={{ <Navbar />
height: '70vh' <div class="container has-text-centered">
}}></div> <div id="map" style={{
</div> height: '70vh'
}}></div>
</div>
</>
); );
} }