1

だから私の問題は単純に思えますが、神の愛のために私はそれを理解することができません. だから私はあなたの助けを求めています。ショップを含むモバイルアプリケーションに単純なリストがあります。マップの中心からの距離でそれらを短くしたい。

カスタムソート機能が必要なようですが、その中で何をしなければならないかわかりません。

私は使っている

testDist.setLatLng(propertyList.selectedItem.lat,propertyList.selectedItem.lng);

dist.text=""+GeodesicCalculatorUtil.calculateGeodesicDistance(FlexGlobals.topLevelApplication.currentLatLng2,testDist,DistanceUnits.KILOMETERS)

店の距離を取得するには、次の店と比較する必要があります。ただし、比較機能でそれを行う方法がわかりません。誰かが私を助けてくれたらうれしいです。

4

1 に答える 1

1

これはマッピング システムとして MapQuest を使用している人々にとって一般的な問題であるように思われるため、任意のリストまでの距離でカスタム POI をソートするソリューションを提供します。これはモバイル アプリケーション向けのソリューションであり、データグリッド上でリストを使用する理由です。

protected function sort_clickHandler():void
            {               

                var dataSortField:SortField = new SortField();
                dataSortField.numeric = true;

                /* Create the Sort object and add the SortField object created earlier to the array of fields to sort on. */
                var numericDataSort:Sort = new Sort();

                numericDataSort.compareFunction=sortFunction;

                /* Set the ArrayCollection object's sort property to our custom sort, and refresh the ArrayCollection. */
                getAllMarkersResult.lastResult.sort = numericDataSort;
                getAllMarkersResult.lastResult.refresh();
            }

            private function sortFunction(a:Object, b:Object, array:Array = null):int
            {

                var aPoi:LatLng = new LatLng(a.lat,a.lng);
                var bPoi:LatLng = new LatLng(b.lat,b.lng);

                var i:Number=GeodesicCalculatorUtil.calculateGeodesicDistance(FlexGlobals.topLevelApplication.currentLatLng2,aPoi,DistanceUnits.KILOMETERS);
                var j:Number=GeodesicCalculatorUtil.calculateGeodesicDistance(FlexGlobals.topLevelApplication.currentLatLng2,bPoi,DistanceUnits.KILOMETERS);


                return ObjectUtil.numericCompare(i, j);


            }
于 2012-05-14T13:50:09.823 に答える