update maps et plein de truc
This commit is contained in:
parent
b70530ca8d
commit
728d52db56
@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
export interface Props {
|
export interface Props {
|
||||||
values: Array<{label:String, name:string}>
|
values: Array<{label:String, name:string, checked?:boolean | undefined}>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -12,7 +12,7 @@ const fields = Astro.props.values
|
|||||||
<>
|
<>
|
||||||
<div class="flex, flex-col">
|
<div class="flex, flex-col">
|
||||||
{fields.map(value => (
|
{fields.map(value => (
|
||||||
<input type="radio" id={value.name} name="note-min" value={value.name}>
|
<input type="radio" id={value.name} name="note-min" value={value.name} checked={value.checked}>
|
||||||
<label for={value.name} class="ml-1">{value.label}</label><br>
|
<label for={value.name} class="ml-1">{value.label}</label><br>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
@ -18,7 +18,7 @@ const metadata = {
|
|||||||
<div class="w-full h-96 grow" id="map" />
|
<div class="w-full h-96 grow" id="map" />
|
||||||
<Button id="test-btn">test</Button>
|
<Button id="test-btn">test</Button>
|
||||||
</div>
|
</div>
|
||||||
|
<!-- TODO: faire en sort que le style soit propre -->
|
||||||
<!-- for remouve footer -->
|
<!-- for remouve footer -->
|
||||||
<!-- <div slot="footer"></div> -->
|
<!-- <div slot="footer"></div> -->
|
||||||
<!-- penser a rm 11 au rem au dessus pour la taille -->
|
<!-- penser a rm 11 au rem au dessus pour la taille -->
|
||||||
@ -77,7 +77,6 @@ const metadata = {
|
|||||||
console.log("route trouvé")
|
console.log("route trouvé")
|
||||||
console.log(e)
|
console.log(e)
|
||||||
})
|
})
|
||||||
const pouet = "pouet"
|
|
||||||
document.querySelector<HTMLButtonElement>('#test-btn')?.addEventListener('click', () => {
|
document.querySelector<HTMLButtonElement>('#test-btn')?.addEventListener('click', () => {
|
||||||
routing.setWaypoints(
|
routing.setWaypoints(
|
||||||
[L.latLng(46.6705431, -1.4269698),L.latLng(47.218536, -1.554075)]
|
[L.latLng(46.6705431, -1.4269698),L.latLng(47.218536, -1.554075)]
|
||||||
|
@ -2,9 +2,8 @@
|
|||||||
import Layout from 'layouts/PageLayout.astro'
|
import Layout from 'layouts/PageLayout.astro'
|
||||||
import 'leaflet/dist/leaflet.css'
|
import 'leaflet/dist/leaflet.css'
|
||||||
import 'leaflet-geosearch/dist/geosearch.css'
|
import 'leaflet-geosearch/dist/geosearch.css'
|
||||||
import FormContainer from 'components/ui/Form.astro'
|
import CheckBox from 'components/CheckBox.astro'
|
||||||
import Input from 'components/Input.astro'
|
import Radios from 'components/Radios.astro'
|
||||||
import Button from 'components/ui/Button.astro'
|
|
||||||
|
|
||||||
const metadata = {
|
const metadata = {
|
||||||
title: 'Maps',
|
title: 'Maps',
|
||||||
@ -14,9 +13,41 @@ const metadata = {
|
|||||||
|
|
||||||
<Layout metadata={metadata}>
|
<Layout metadata={metadata}>
|
||||||
|
|
||||||
<div class="h-[calc(100vh-16rem)] flex flex-col">
|
<div class="h-[calc(100vh-16rem)] flex flex-row">
|
||||||
|
<div class="w-1/5 flex flex-col">
|
||||||
|
<p id="message" class="hidden text-center mb-3">pouet</p>
|
||||||
|
<p class="text-center text-2xl mb-3">Filtre :</p>
|
||||||
|
<div class="grow">
|
||||||
|
<p>note minimal :</p>
|
||||||
|
<Radios
|
||||||
|
values={[
|
||||||
|
{name: "1", label: "1", checked: true},
|
||||||
|
{name: "2", label: "2"},
|
||||||
|
{name: "3", label: "3"},
|
||||||
|
{name: "1h", label: "1h"},
|
||||||
|
{name: "2h", label: "2h"},
|
||||||
|
{name: "3h", label: "3h"},
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
<p class="text-center text-xl mb-3">Type POI :</p>
|
||||||
|
<CheckBox
|
||||||
|
label="Bar, Pub, Café,..."
|
||||||
|
name="drink"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<p class="text-center text-xl mb-3">Source :</p>
|
||||||
|
<CheckBox
|
||||||
|
label="Open Trip Maps"
|
||||||
|
name="otm"
|
||||||
|
checked
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="flex flex-col grow">
|
||||||
<div class="w-full h-96 grow" id="map" />
|
<div class="w-full h-96 grow" id="map" />
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
<!-- TODO: faire en sort que le style soit propre -->
|
<!-- TODO: faire en sort que le style soit propre -->
|
||||||
|
|
||||||
<!-- for remouve footer -->
|
<!-- for remouve footer -->
|
||||||
@ -25,7 +56,7 @@ const metadata = {
|
|||||||
</Layout>
|
</Layout>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import L, { geoJSON, Icon, Popup, type LatLngTuple } from 'leaflet'
|
import L, {Popup} from 'leaflet'
|
||||||
import markerShadow from "leaflet/dist/images/marker-shadow.png"
|
import markerShadow from "leaflet/dist/images/marker-shadow.png"
|
||||||
import markerIcon from "leaflet/dist/images/marker-icon.png"
|
import markerIcon from "leaflet/dist/images/marker-icon.png"
|
||||||
import { OpenStreetMapProvider } from 'leaflet-geosearch'
|
import { OpenStreetMapProvider } from 'leaflet-geosearch'
|
||||||
@ -33,9 +64,7 @@ const metadata = {
|
|||||||
|
|
||||||
const icon = {icon: new L.Icon({iconUrl: markerIcon.src, shadowUrl: markerShadow.src, iconAnchor: [13,41]})}
|
const icon = {icon: new L.Icon({iconUrl: markerIcon.src, shadowUrl: markerShadow.src, iconAnchor: [13,41]})}
|
||||||
|
|
||||||
const BACK_URL = "http://localhost:3001/"
|
const BACK_URL = "http://localhost:3001/" //XXX : mettre url de prod
|
||||||
|
|
||||||
let mapsCenter : L.LatLngTuple
|
|
||||||
|
|
||||||
// declare map
|
// declare map
|
||||||
const map = L.map('map', {
|
const map = L.map('map', {
|
||||||
@ -54,7 +83,6 @@ const metadata = {
|
|||||||
position: 'bottomleft'
|
position: 'bottomleft'
|
||||||
}).addTo(map);
|
}).addTo(map);
|
||||||
|
|
||||||
|
|
||||||
const provider = new OpenStreetMapProvider()
|
const provider = new OpenStreetMapProvider()
|
||||||
|
|
||||||
map.addControl(
|
map.addControl(
|
||||||
@ -67,7 +95,7 @@ const metadata = {
|
|||||||
)
|
)
|
||||||
|
|
||||||
let poiMarkers = new Array<L.Marker>
|
let poiMarkers = new Array<L.Marker>
|
||||||
|
let minimalNote = "1";
|
||||||
// run api search
|
// run api search
|
||||||
function searchBox(){
|
function searchBox(){
|
||||||
const nordWest = map.getBounds().getNorthWest()
|
const nordWest = map.getBounds().getNorthWest()
|
||||||
@ -78,6 +106,9 @@ const metadata = {
|
|||||||
params.append("lat1", nordWest.lat.toString())
|
params.append("lat1", nordWest.lat.toString())
|
||||||
params.append("lon2", southEast.lng.toString())
|
params.append("lon2", southEast.lng.toString())
|
||||||
params.append("lat2", southEast.lat.toString())
|
params.append("lat2", southEast.lat.toString())
|
||||||
|
params.append("rate", minimalNote);
|
||||||
|
|
||||||
|
console.log(params);
|
||||||
|
|
||||||
fetch(`${BACK_URL}otm/box?${params.toString()}`,{method: 'GET',headers: {'Content-Type': 'application/json'}}).then(function (response) {
|
fetch(`${BACK_URL}otm/box?${params.toString()}`,{method: 'GET',headers: {'Content-Type': 'application/json'}}).then(function (response) {
|
||||||
return response.json();
|
return response.json();
|
||||||
@ -85,6 +116,7 @@ const metadata = {
|
|||||||
poiMarkers.forEach(element => {
|
poiMarkers.forEach(element => {
|
||||||
element.remove();
|
element.remove();
|
||||||
});
|
});
|
||||||
|
console.log(data)
|
||||||
data.features.forEach(element => {
|
data.features.forEach(element => {
|
||||||
const prop = element.properties
|
const prop = element.properties
|
||||||
const popup: Popup = new Popup()
|
const popup: Popup = new Popup()
|
||||||
@ -131,4 +163,18 @@ const metadata = {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
document.querySelectorAll("input").forEach(e =>{
|
||||||
|
e.addEventListener("click", () => {
|
||||||
|
console.log("checked : ", e.checked)
|
||||||
|
console.log("val ", e.value)
|
||||||
|
console.log("name: ", e.name)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
document.querySelectorAll<HTMLInputElement>('input[name="note-min"]').forEach(e => {
|
||||||
|
e.addEventListener("click", () => {
|
||||||
|
minimalNote = e.value
|
||||||
|
})
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user