SENCHA TOUCH 2 - DISPLAY CURRENT LOCATION ON MAP

jacob rasel

Total Post:88

Points:616
Posted by  jacob rasel
 2002  View(s)
Ratings:
Rate this:
Hi Expert!

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.

{
  xtype: 'map',
  useCurrentLocation: true
}

Thanks in advance! 
  1. AVADHESH PATEL

    Post:604

    Points:4228
    Re: Sencha touch 2 - Display current location on map

    Hi Jacob!


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

    The index.html file looks like this:

    <!DOCTYPE html>
    <html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <title>Sample app</title>

        <script type="text/javascript" src="lib/touch/sencha-touch-all-debug.js"></script>
        <link href="lib/touch/resources/css/sencha-touch.css" rel="stylesheet" type="text/css" />
        <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script>

        <script type="text/javascript">
            Ext.Loader.setConfig({
                enabled : true,
                path    : {
                    PPL : 'ppl.js'
                }
            });

            Ext.setup({
                tabletStartupScreen : 'tablet_startup.png',
                phoneStartupScreen  : 'phone_startup.png',
                icon                : 'phone_startup.png',
                onReady             : function() {
                    Ext.create('PPL.App', {
                        fullscreen : true
                    });
                }
            })
        </script>
    </head>
    <body>
    </body>
    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 :-)

    I hope it helpful for you.

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!