Extjs 地理定位&x2B;距离测量

Extjs 地理定位&x2B;距离测量,extjs,sencha-touch-2,Extjs,Sencha Touch 2,你知道我如何测量两个目的地之间的距离吗?这两个目的地的纬度和经度都是已知的。。。。。。。。 此代码取自sencha touch2提供的示例,几乎没有修改。 这是为sencha touch 2准备的 尝试google.maps.geometry.spheremic.ComputedDistanceBeween(from:LatLng,to:LatLng,radius?:number) 半径是地球的半径=6371000米(平均)var distance=google.maps.geometry.sp

你知道我如何测量两个目的地之间的距离吗?这两个目的地的纬度和经度都是已知的。。。。。。。。 此代码取自sencha touch2提供的示例,几乎没有修改。 这是为sencha touch 2准备的


尝试
google.maps.geometry.spheremic.ComputedDistanceBeween(from:LatLng,to:LatLng,radius?:number)


半径是地球的半径=6371000米(平均)

var distance=google.maps.geometry.spheremic.ComputedDistanceBetween(中心,位置,6371000);您不需要输入半径,它有一个默认值,因此您也可以这样做:distance=google.maps.geometry.spherec.computedDistanceBeween(center,position);这回答了你的问题吗?
   launch: function() {
    // The following is accomplished with the Google Map API
    var position = new google.maps.LatLng(12.9833, 77.5833),  //Sencha HQ

        infowindow = new google.maps.InfoWindow({
            content: 'bengaluru'
        }),

        //Tracking Marker Image
        image = new google.maps.MarkerImage(
            'resources/images/point.png',
            new google.maps.Size(32, 31),
            new google.maps.Point(0, 0),
            new google.maps.Point(16, 31)
        ),

        shadow = new google.maps.MarkerImage(
            'resources/images/shadow.png',
            new google.maps.Size(64, 52),
            new google.maps.Point(0, 0),
            new google.maps.Point(-5, 42)
        ),

        trackingButton = Ext.create('Ext.Button', {
            iconMask: true,
            iconCls: 'locate'
        }),

        trafficButton = Ext.create('Ext.Button', {
            iconMask: true,
            pressed: true,
            iconCls: 'maps'
        }),

        toolbar = Ext.create('Ext.Toolbar', {
            docked: 'top',
            ui: 'light',
            defaults: {
                iconMask: true
            },
            items: [
                {
                    xtype:'button',
                    id:'calculate',
                    text:'calculate',
                    handler:function(){
                        alert('hello');
                    }
                }
            ]
        });

    var mapdemo = Ext.create('Ext.Map', {
        mapOptions : {
            center : new google.maps.LatLng(37.381592, 122.135672),  //nearby San Fran
            zoom : 12,
            mapTypeId : google.maps.MapTypeId.ROADMAP,
            navigationControl: true,
            navigationControlOptions: {
                style: google.maps.NavigationControlStyle.DEFAULT
            }
        },

        plugins : [
            new Ext.plugin.google.Tracker({
                trackSuspended: true,   //suspend tracking initially
                allowHighAccuracy: false,
                marker: new google.maps.Marker({
                    position: position,
                    title: 'My Current Location',
                    shadow: shadow,
                    icon: image
                })
            }),
            new Ext.plugin.google.Traffic()
        ],

        listeners: {
            maprender: function(comp, map) {
                var marker = new google.maps.Marker({
                    position: position,
                    title : 'Sencha HQ',
                    map: map
                });

                google.maps.event.addListener(marker, 'click', function() {
                    infowindow.open(map, marker);
                });

                setTimeout(function() {
                    map.panTo(position);
                }, 1000);
            }

        }
    });