在ng repeate中使用angularjs获得两个lat之间距离的最佳方法

在ng repeate中使用angularjs获得两个lat之间距离的最佳方法,angularjs,Angularjs,在angularjs ng repeat中,我必须使用谷歌地图显示设备和地点之间的距离。我正在共享我所做的代码,但它不起作用,但当我在断点中检查它时,它会得到距离,但不会在占位符“{Show_distance(place[3],place[4])}”中更新 HTML页面: <ons-row ng-repeat="place in PlacesList" style="border-bottom:solid 6px orange;"> <ons-col> <o

在angularjs ng repeat中,我必须使用谷歌地图显示设备和地点之间的距离。我正在共享我所做的代码,但它不起作用,但当我在断点中检查它时,它会得到距离,但不会在占位符“{Show_distance(place[3],place[4])}”中更新

HTML页面:

<ons-row ng-repeat="place in PlacesList" style="border-bottom:solid 6px orange;">
<ons-col>
    <ons-button modifier="clean" ng-click="showPlacesDetails($index)">
        <img src="{{ place[1] }}">
        <div style="position:absolute; bottom:0; width:100%;">
            {{ Show_Distance(place[3], place[4]) }}
        </div>
    </ons-button>
</ons-col>
我们将感谢您的帮助

编辑: 位置列表内容(1个位置):

1福雷斯塔厨房和酒吧福雷斯塔厨房是个不错的地方26.9209795.7939344图片/PlacesMedia/1_01.jpg

如果你想得到经度和纬度之间的距离,但这没有任何意义,你必须使用两个点,每个点都有自己的经度和纬度,然后计算距离。下面是一个实际例子: x:经度y:纬度

您能否提供一个plunkr,以便我们可以方便地编辑您的代码。另外,请分享您的PlaceList Json
getDistanceMatrix
是异步的,从函数返回原语后将更新原语。原语不具有继承性,而是使用对象或从中返回承诺function@charlietfl…谢谢你的回复,你能给我看一下这种情况下的承诺函数的例子吗?事实上,我对angularjs是新手,在google上找不到合适的例子。请看angular$q文档
$scope.Show_Distance = function (lat, lng) {
     var Distance = Get_Distance(lat, lng);
     return Distance;
};

function Get_Distance(lat, lng) {
        //*********DISTANCE AND DURATION**********************//
        var Distance = 'Distance: N.A.';
        var service = new google.maps.DistanceMatrixService();
        service.getDistanceMatrix({
            origins: [new google.maps.LatLng($rootScope.deviceLatitude, $rootScope.deviceLongitude)],
            destinations: [new google.maps.LatLng(lat, lng)],
            travelMode: google.maps.TravelMode.DRIVING,
            avoidHighways: false,
            avoidTolls: false
        },
        function (response, status) {
            if (status == google.maps.DistanceMatrixStatus.OK && response.rows[0].elements[0].status != "ZERO_RESULTS") {
                Distance = response.rows[0].elements[0].distance.text;
                //alert(Distance);
            }
        });
        return Distance;
    }
<Value><string>1</string><string>Forresta Kitchen & Bar</string><string>Forresta Kitchen is nice place</string><string>26.920979</string><string>75.793934</string><string>4</string><string>images/PlacesMedia/1_01.jpg</string></Value>