2012-07-12 78 views
0

我試圖在sencha框架中編寫的應用程序上實現地理定位,但我真的不知道如何使用Sencha Touch 2和Google Maps Api實現地理定位。 我有以下代碼:使用谷歌地圖的Sencha Touch 2地理位置

Ext.define('App.view.WhereAmI', { 
    extend: 'Ext.Container', 
    xtype: 'whereAmI', 
    //? fullscreen: true, 

    requires: [ 
     'Ext.Map' 
    ], 

    config: { 
     layout: 'fit', 
     scrollable: true, 
     styleHtmlContent: true, 
     style: 'text-align: center; background-color:white;', 

     items: 
     [ 
      { 
       xtype: 'toolbar', 
       docked: 'top', 
       title: 'Where Am I?', 
       minHeight: '60px', 
       items: [ 
        { 
         ui: 'back', 
         xtype: 'button', 
         id: 'backButton', 
         text: 'Powrót', 
        }, 

        { 
         minHeight: '60px', 
         right: '5px', 
         html: ['<img src="resources/images/Image.png"/ style="height: 100%; ">',].join(""), 
        }, 
       ],   
      }, 
      { 
       xtype:'map', 
      }, 
     ] 
    }, 
    //launch : function() { }, 
}); 

什麼我究竟需要添加到這個視圖來實現標誌與我的當前位置?

感謝您的幫助!

+0

http://stackoverflow.com/questions/8203933/sencha-touch-2 -display-current-location-on-map 希望這會有所幫助。 – 2012-07-23 06:27:27

+0

我在寫這篇文章之後發現了這個帖子,但是感謝您的回答。 :) – kmb 2012-07-24 10:31:38

回答

0

嘗試使用地理位置:

 var geo = Ext.create('Ext.util.Geolocation', { 
     autoUpdate:false, 
     listeners:{ 
      locationupdate:function (geo) { 
       console.log('Current latitude: ' + geo.getLatitude() + 'Long: ' + geo.getLongitude()); 
      }, 
      locationerror:function (geo, bTimeout, bPermissionDenied, bLocationUnavailable, message) { 
       if (bTimeout) { 
        alert('Timeout occurred.'); 
       } else { 
        alert('Error occurred.'); 
       } 
      } 
     } 
    }); 

或添加

useCurrentLocation:true,

在煎茶觸摸地圖