Home > DeveloperSection > Forums > Sencha touch 2 - Display current location on map
jacob rasel
jacob rasel

Total Post:88

Points:616
Posted on    May-31-2013 1:38 AM

 Sencha Touch Sencha Touch 
Ratings:


 1 Reply(s)
 1698  View(s)
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! 


AVADHESH PATEL

Total Post:604

Points:4228
Posted on    June-01-2013 12:47 AM

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.


Don't want to miss updates? Please click the below button!

Follow MindStick