Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"@solidjs/router": "^0.15.1",
"array-shuffle": "^3.0.0",
"autoprefixer": "^10.4.20",
"leaflet": "^2.0.0-alpha.1",
"medium-zoom": "^1.1.0",
"mqtt": "^5.14.0",
"postcss": "^8.5.6",
Expand Down
65 changes: 65 additions & 0 deletions frontend/src/pages/map/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import styles from "./styles.module.css"

import { For, createSignal, Show, onMount, createResource } from "solid-js"
import L, { Map, TileLayer, Marker, Circle, Polygon, Popup } from "leaflet"

import "leaflet/dist/leaflet.css"
import { getObjects } from "../../../../lib/ecotaxa"

// https://github.com/ecotaxa/ecotaxa_back/issues/64
const api_url = new URL("http://example.com/ecotaxa/api/")
api_url.hostname = document.location.hostname

// No need for CORS for <img/>
const vault_url = "https://ecotaxa.obs-vlfr.fr/vault/"

export default function MapPage() {
let div_map

onMount(() => {
const map = new Map(div_map)
// map.setZoom(2)
.setView([48.587410962886686, -3.8383494867168175], 2)

const tile_layer = new TileLayer(
"https://tile.openstreetmap.org/{z}/{x}/{y}.png",
{
maxZoom: 19,
attribution:
'&copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>',
},
)
tile_layer.addTo(map)

getObjects({
api_url,
vault_url,
project_id: 15730,
window_start: 0,
window_size: 5000,
}).then((result) => {
console.log(result)
result.objects.forEach((object) => {
if (object.latitude && object.longitude) {
const market = new Marker([object.latitude, object.longitude])
market.addTo(map)
}
})
})

// const marker = new Marker([48.587410962886686, -3.8383494867168175])
// marker.addTo(map)
})

return (
<>
<header>
<h1>Map</h1>
</header>

<main>
<div ref={div_map} class={styles.map}></div>
</main>
</>
)
}
9 changes: 9 additions & 0 deletions frontend/src/pages/map/styles.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*:global(html) {
background-color: #f3f3f3;
}*/

.map {
/*height: 180px;*/
/*width: 100%;*/
height: 1024px;
}
6 changes: 6 additions & 0 deletions lib/ecotaxa.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ export async function getObjects({
"img.thumb_width",
"img.thumb_height",
"txo.display_name",
"obj.latitude",
"obj.longitude",
]

url.search = new URLSearchParams({
Expand Down Expand Up @@ -61,12 +63,16 @@ export async function getObjects({
const thumb_width = details[idx][4]
const thumb_height = details[idx][5]
const label = details[idx][6]
const latitude = details[idx][7]
const longitude = details[idx][8]

const url = new URL(file_name, vault_url)
const thumb_url = new URL(thumb_file_name || file_name, vault_url)

return {
label,
latitude,
longitude,
file: {
url: url,
width,
Expand Down
Loading