|
|
|
|
@ -7,13 +7,13 @@
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
import maplibregl from "maplibre-gl";
|
|
|
|
|
import { markRaw, onMounted, onUnmounted, shallowRef, } from "vue";
|
|
|
|
|
import { markRaw, onMounted, onUnmounted, reactive, shallowRef, } from "vue";
|
|
|
|
|
export default {
|
|
|
|
|
name: "map-component",
|
|
|
|
|
setup(_props, context) {
|
|
|
|
|
const mapContainer = shallowRef(null);
|
|
|
|
|
const map = shallowRef(null);
|
|
|
|
|
let currentFadr = { "fadr": "Any" };
|
|
|
|
|
let currentFadr = reactive({ "fadr": [] });
|
|
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
|
const apiKey = "pk.eyJ1IjoiZ2hlcm1hbnQiLCJhIjoiY2pncDUwcnRmNDQ4ZjJ4czdjZXMzaHZpNyJ9.3rFyYRRtvLUngHm027HZ7A";
|
|
|
|
|
@ -103,40 +103,38 @@ export default {
|
|
|
|
|
.setLngLat(e.lngLat)
|
|
|
|
|
.setHTML(JSON.stringify(e.features[0].properties))
|
|
|
|
|
.addTo(map.value);
|
|
|
|
|
let fadr = {
|
|
|
|
|
"fadr": e.features[0].properties["fadr"]
|
|
|
|
|
};
|
|
|
|
|
fadr = currentFadr["fadr"] == fadr["fadr"] ?
|
|
|
|
|
{ "fadr": "Any" } :
|
|
|
|
|
fadr;
|
|
|
|
|
|
|
|
|
|
// check if we need to remove any old paint
|
|
|
|
|
if (currentFadr["fadr"] !== "Any") {
|
|
|
|
|
let newFadr = e.features[0].properties["fadr"];
|
|
|
|
|
|
|
|
|
|
let newFadrFound = currentFadr["fadr"].indexOf(newFadr)
|
|
|
|
|
if (newFadrFound > -1) {
|
|
|
|
|
//remove old paint
|
|
|
|
|
map.value.setFeatureState(
|
|
|
|
|
{
|
|
|
|
|
source: 'samples',
|
|
|
|
|
sourceLayer: 'public.geodata',
|
|
|
|
|
id: currentFadr["fadr"]
|
|
|
|
|
id: newFadr
|
|
|
|
|
},
|
|
|
|
|
{ beenClicked: false }
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// check if we need to apply any new paint
|
|
|
|
|
if (fadr["fadr"] !== "Any") {
|
|
|
|
|
// remove from filters
|
|
|
|
|
currentFadr["fadr"].splice(newFadrFound, 1)
|
|
|
|
|
} else {
|
|
|
|
|
// apply new paint
|
|
|
|
|
map.value.setFeatureState(
|
|
|
|
|
{
|
|
|
|
|
source: 'samples',
|
|
|
|
|
sourceLayer: 'public.geodata',
|
|
|
|
|
id: fadr["fadr"]
|
|
|
|
|
id: newFadr
|
|
|
|
|
},
|
|
|
|
|
{ beenClicked: true }
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
currentFadr = fadr;
|
|
|
|
|
// add to filters
|
|
|
|
|
currentFadr["fadr"].push(newFadr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
context.emit('mapClick', fadr);
|
|
|
|
|
context.emit('mapClick', currentFadr);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|