DroneDeploy
Search…
Measurement API Example
1
<!DOCTYPE html>
2
<html lang="en">
3
<head>
4
<meta charset="UTF-8">
5
<title>Document</title>
6
7
<!-- Only included for easy geometry manipulation -->
8
<script src="https://unpkg.com/[email protected]/dist/leaflet.js"
9
integrity="sha512-lInM/apFSqyy1o6s89K4iQUKg6ppXEgsVxT35HbzUupEVRh2Eu9Wdl4tHj7dZO0s1uvplcYGmt3498TtHq+log=="
10
crossorigin=""></script>
11
</head>
12
<body>
13
14
<div>Measurement.getElevationOfPoint</div>
15
<textarea id="Measurement-getelevationofpoint"></textarea>
16
17
<div>Measurement.getElevationOfPoints</div>
18
<textarea id="Measurement-getelevationofpoints"></textarea>
19
20
<div>Measurement.getElevationOfLine</div>
21
<textarea id="Measurement-getelevationofline"></textarea>
22
23
<div>Measurement.getVolume</div>
24
<textarea id="Measurement-getvolume"></textarea>
25
26
27
<script>
28
new DroneDeploy({version: 1}).then(function(dronedeploy){
29
dronedeploy.Plans.getCurrentlyViewed().then(function(plan){
30
// All measurements need to occur within the bounds of the map
31
var shrunkBounds = scaleBounds(plan.geometry, -0.45);
32
33
dronedeploy.Measurement.getElevationOfPoint(plan.id, shrunkBounds[0])
34
.then(drawResultsOnElement('#Measurement-getelevationofpoint'));
35
36
dronedeploy.Measurement.getElevationOfPoints(plan.id, shrunkBounds)
37
.then(drawResultsOnElement('#Measurement-getelevationofpoints'));
38
39
dronedeploy.Measurement.getElevationOfLine(plan.id, [shrunkBounds[0], shrunkBounds[1]])
40
.then(drawResultsOnElement('#Measurement-getelevationofline'));
41
42
dronedeploy.Measurement.getVolume(plan.id, shrunkBounds)
43
.then(drawResultsOnElement('#Measurement-getvolume'));
44
});
45
});
46
47
function drawResultsOnElement(textareaSelector){
48
return function renderResults(jsonResults){
49
document.querySelector(textareaSelector).value = JSON.stringify(jsonResults);
50
}
51
}
52
53
function scaleBounds(geometry, factor){
54
var latLngs = geometry.map((latLng) => [latLng.lat, latLng.lng]);
55
var scaledBounds = L.latLngBounds(latLngs).pad(factor)
56
var toPoint = function(latLng){
57
return {lat: latLng.lat, lng: latLng.lng};
58
}
59
60
return [
61
toPoint(scaledBounds.getNorthEast()),
62
toPoint(scaledBounds.getSouthEast()),
63
toPoint(scaledBounds.getSouthWest()),
64
toPoint(scaledBounds.getNorthWest()),
65
];
66
}
67
68
</script>
69
70
</body>
71
</html>
Copied!
Last modified 2yr ago
Copy link