Sencha touch 2 - Display current location on map

后端 未结 4 556
难免孤独
难免孤独 2021-01-07 06:27

I want to display my current location and get location coordinates to search nearby. Starting with the code below to display my location on the map, but its not working.

4条回答
  •  佛祖请我去吃肉
    2021-01-07 07:01

    I think this is a bug in ST2. I asked (I think you did :-) ) this question also in Sencha Forums: http://www.sencha.com/forum/showthread.php?156501-Maps-with-sencha-touch

    My code in that forum did not worked. The code that I was using is as follows:

    The index.html file looks like this:

    
    
    
        
        Sample app
    
        
        
        
    
        
    
    
    
    
    

    And my ppl.js looks like this:

    Ext.define('PPL.App', {
        extend: 'Ext.Panel',
        layout: 'vbox',
    
        config: {
            items: [{
                xtype: 'toolbar',
                title: 'Sample MAP'
            }, {
                xtype: 'panel',
                layout: 'fit',
                items: [{
                    xtype: 'map',
                    useCurrentLocation: true
                }]
            }]
        }
    });
    

    If I change my ppl.js into the following:

    Ext.define('PPL.App', {
        extend: 'Ext.Map',
        layout: 'fit',
        config: {
            items: [{
                xtype: 'map',
                useCurrentLocation: false
            }]
        }
    });
    

    Then it is working! So, I think we need to wait untill next release, in the mean time learn ST2 :-)

    Cheers!

提交回复
热议问题