我想用打字稿写this代码:
我得到正确的visibleRegion,但是我不明白如何编写代码Location.distanceBetween(..)来计算距离。
我有此代码:
this.gMap = event.object.gMap;
var visibleRegion = this.gMap.getProjection().getVisibleRegion();
var farRight = visibleRegion.farRight;
var farLeft = visibleRegion.farLeft;
var nearRight = visibleRegion.nearRight;
var nearLeft = visibleRegion.nearLeft;
var diagonalDistance = new float[1]; //Cannot find name 'float'.ts(2304)
var farLeft = visibleRegion.farLeft;
var nearRight = visibleRegion.nearRight;
Location.distanceBetween( //Property 'distanceBetween' does not exist on type '{ new (): Location; prototype: Location; }'.ts(2339)
farLeft.latitude,
farLeft.longitude,
nearRight.latitude,
nearRight.longitude,
diagonalDistance
);
return diagonalDistance[0] / 2;
请问您有什么想法吗?我不会用打字稿代码写。 Nativescript / Angular