Question is for the DroneDeploy platform.
By now my approach is getting the max difference in lat or lng, assign a zoom according to how big is the difference and get a tile:
..
var maxLat, minLat, maxLng, minLng, zoom;
plan.geometry.map(function(node){
maxLat==undefined ? maxLat=node.lat : (node.lat > maxLat ? maxLat = node.lat : false)
minLat==undefined ? minLat=node.lat : (node.lat < minLat ? minLat = node.lat : false)
maxLng==undefined ? maxLng=node.lng : (node.lng > maxLng ? maxLng = node.lng : false)
minLng==undefined ? minLng=node.lng : (node.lng < minLng ? minLng = node.lng : false)
})
if (maxLat-minLat > maxLng-minLng){
if ((maxLat-minLat)*1000>1 && (maxLat-minLat)*1000<2){ zoom = 17; }
// other scopes for zoom levels here
else if ((maxLat-minLat)*100>1 && (maxLat-minLat)*100<9){ zoom = 8; }
}else{
if ((maxLng-minLng)*1000>1 && (maxLng-minLng)*1000<2){ zoom = 17; }
// other scopes for zoom levels here
else if ((maxLng-minLng)*100>1 && (maxLng-minLng)*100<9){ zoom = 8; }
}
dronedeploy.Tiles.get({planId: plan.id, layerName: 'ortho', zoom: zoom})
.then(function(tileInformation){
const tiles = getTilesFromGeometry(plan.geometry, tileInformation.template, zoom); // getTileFromGeometry function take from https://dronedeploy.gitbooks.io/dronedeploy-apps/content/tiles/example-tiles-as-array.html
console.log(tiles);
});
..
- Is there a better way to get a preview? When one get email from DroneDeploy about map being shared with you, there is a map preview embedded in the email. My guess that they use some undocumented APIs for that or the same approach which I described above.
- It works only if I am the owner of the map, not in case the map is shared with me. I get using the returned path:
<Error> <Code>AccessDenied</Code> <Message>Access Denied</Message> <RequestId>774DCD7F4D31201F</RequestId> <HostId> 8dVjSI4yj/Ag3AJlV9NOZrZES8IXnCDp5kwmN7qjsoOX91+325FM6xlHUQ5QIsH9ZcMYTZwBym4= </HostId> </Error>
Is there a workaround for such case?