<!-- This is a helper file we created. It provides the registerWaypointCalculationFunction.-->
<script type="text/javascript" src="https://s3.amazonaws.com/drone-deploy-plugins/templates/waypoint-calculation-helper.js"></script>
<div>Waypoint Updates Count: <span id="count">0</span></div>
// This function needs to return a promise
function waypointCalculationFunction(currentPlan){
return new Promise((resolve) => {
const newWaypoints = currentPlan.waypoints.map((waypoint, index) => {
const alt = 50 + (index * 3) + (isEven(index) ? -10 : 10);
return {alt, lat: waypoint.lat, lng: waypoint.lng}
// Waypoints need to be recalculated everytime the user changes
// the geometry or other fields on the plan
// this is a helper function to assist in setting the waypoints on
registerWaypointCalculationFunction(waypointCalculationFunction)
.subscribe(function(successMessage){
document.querySelector('#count').innerHTML = parseInt(document.querySelector('#count').innerHTML) + 1;
console.log('Error:', e);