DroneDeploy
Search…
Annotation create and delete
1
<html>
2
<head>
3
<title></title>
4
<script>
5
let planGeometry = {};
6
7
var dd = new DroneDeploy({
8
version: 1
9
});
10
11
dd.then(function(api){
12
let select = document.getElementById('planSelect');
13
select.innerHTML = '';
14
15
api.Plans.all().then(function(plans){
16
for(let plan of plans) {
17
let option = document.createElement('option');
18
option.innerText = plan.name;
19
option.value = plan.id;
20
select.appendChild(option);
21
planGeometry[plan.id] = {
22
location: plan.location,
23
geometry: plan.geometry
24
}
25
}
26
});
27
});
28
29
function drawOutline(){
30
let planId = document.getElementById('planSelect').value;
31
32
dd.then(function(api){
33
api.Plans.getCurrentlyViewed().then(function(plan){
34
api.Annotations.createMarker(
35
plan.id,
36
planGeometry[planId].location
37
);
38
39
api.Annotations.createArea(
40
plan.id,
41
planGeometry[planId].geometry
42
);
43
});
44
});
45
};
46
47
function clearAnnotations(){
48
dd.then(function(api){
49
api.Plans.getCurrentlyViewed().then(function(plan){
50
api.Annotations.get(plan.id).then(function(annotations){
51
annotations.forEach(function(ann){
52
console.log(ann)
53
api.Annotations.delete(ann.id);
54
})
55
});
56
});
57
})
58
}
59
60
</script>
61
</head>
62
<body>
63
<p>
64
<label>
65
Select a plan outline to draw <br / >
66
<select id="planSelect"></select>
67
</label>
68
</p>
69
70
<button onclick="drawOutline()">
71
Draw outline of selected plan
72
</button>
73
<button onclick="clearAnnotations()">
74
Delete all annotations on currently viewed plan
75
</button>
76
</body>
77
</html>
Copied!
Last modified 2yr ago
Copy link