Skip to content

Commit a2c87da

Browse files
authored
Merge pull request #315 from Prisma501/master
added Drones (on,- and offline) to map
2 parents f401645 + 6a34643 commit a2c87da

2 files changed

Lines changed: 40 additions & 0 deletions

File tree

public/img/drone-icon.png

1.27 MB
Loading

src/components/SdtdMap.vue

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,13 @@ const vehicleIcon = L.icon({
4747
popupAnchor: [0, -20],
4848
});
4949
50+
const droneIcon = L.icon({
51+
iconUrl: "img/drone-icon.png",
52+
iconSize: [50, 50],
53+
iconAnchor: [12, 24],
54+
popupAnchor: [0, -20],
55+
});
56+
5057
const traderIcon = L.icon({
5158
iconUrl: "img/shopping-cart.png",
5259
iconSize: [25, 25],
@@ -401,6 +408,39 @@ export default {
401408
vehiclesLayer.addLayer(marker);
402409
}
403410
},
411+
getDrones() {
412+
return fetch(`/api/getdrones`)
413+
.then(function(response) {
414+
return response.json();
415+
})
416+
.then(function(data) {
417+
return data;
418+
});
419+
},
420+
async drawDrones() {
421+
if (!this.hasPermission("ClaimCreator.getdrones")) {
422+
return;
423+
}
424+
425+
const currentDrones = await this.getDrones();
426+
let dronesLayer = this.layers["Drones"];
427+
if (!dronesLayer) {
428+
this.layers["Drones"] = new L.LayerGroup();
429+
dronesLayer = this.layers["Drones"];
430+
}
431+
432+
dronesLayer.clearLayers();
433+
for (const drone of currentDrones.Drones) {
434+
const marker = L.marker([drone.posX, drone.posZ], {
435+
icon: droneIcon,
436+
}).bindPopup(
437+
`Drone: ${drone.name} <br> Position: ${drone.posX} ${
438+
drone.posY
439+
} ${drone.posZ}`
440+
);
441+
dronesLayer.addLayer(marker);
442+
}
443+
},
404444
getHomes() {
405445
return fetch(`/api/getplayerhomes`)
406446
.then(function(response) {

0 commit comments

Comments
 (0)