Show raw features json in popup
This commit is contained in:
@@ -47,9 +47,21 @@ const lib = new function () {
|
|||||||
|
|
||||||
const contextmenu = new maplibregl.Popup()
|
const contextmenu = new maplibregl.Popup()
|
||||||
.setLngLat(coordinates)
|
.setLngLat(coordinates)
|
||||||
.setHTML('<button id="btn-start">start</button></br><button id="btn-via">via</button></br><button id="btn-finish">finish</button>')
|
.setHTML('<button id="btn-feat">feature</button></br><button id="btn-start">start</button></br><button id="btn-via">via</button></br><button id="btn-finish">finish</button>')
|
||||||
.addTo(map);
|
.addTo(map);
|
||||||
|
|
||||||
|
let featbtn = document.getElementById("btn-feat");
|
||||||
|
featbtn.onclick = function () {
|
||||||
|
contextmenu.remove();
|
||||||
|
const features = map.queryRenderedFeatures(e.point);
|
||||||
|
const prop = features.map(function (feat) {
|
||||||
|
return feat["properties"];
|
||||||
|
});
|
||||||
|
const featPopup = new maplibregl.Popup()
|
||||||
|
.setLngLat(coordinates)
|
||||||
|
.setHTML(JSON.stringify(prop))
|
||||||
|
.addTo(map);
|
||||||
|
};
|
||||||
let startbtn = document.getElementById("btn-start");
|
let startbtn = document.getElementById("btn-start");
|
||||||
startbtn.onclick = function () {
|
startbtn.onclick = function () {
|
||||||
contextmenu.remove();
|
contextmenu.remove();
|
||||||
|
|||||||
Reference in New Issue
Block a user