Sencha touch 2 - 在地图上显示当前位置 [英] Sencha touch 2 - Display current location on map

查看:109
本文介绍了Sencha touch 2 - 在地图上显示当前位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想显示我当前的位置,并获取位置坐标来搜索附近。从下面的代码开始,在地图上显示我的位置,但不起作用。

  {
xtype:' map',
useCurrentLocation:true
}


解决方案>

我认为这是ST2中的一个错误。我问(我想你做了:-))这个问题也在Sencha论坛: http://www.sencha.com/forum/showthread.php?156501-Maps-with-sencha-touch



我的该论坛的代码没有起作用。我使用的代码如下:



index.html文件如下所示:

 <!DOCTYPE html> 
< html>
< head>
< meta http-equiv =Content-Typecontent =text / html; charset = utf-8>
< title>示例应用< / title>

< script type =text / javascriptsrc =lib / touch / sencha-touch-all-debug.js>< / script>
< link href =lib / touch / resources / css / sencha-touch.css =stylesheettype =text / css/>
< script type =text / javascriptsrc =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',
图标:'phone_startup.png',
onReady:function(){
Ext.create('PPL.App',{
fullscreen:true
});
}
})
< / script>
< / head>
< body>
< / body>
< / html>

我的ppl.js如下所示:

  Ext.define('PPL.App',{
extends:'Ext.Panel',
layout:'vbox ',

config:{
items:[{
xtype:'toolbar',
title:'Sample MAP'
},{
xtype:'panel',
layout:'fit',
items:[{
xtype:'map',
useCurrentLocation:true
}]
}]
}
});

如果我将ppl.js更改为以下内容:

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

然后它正在工作!
所以,我想我们需要等待下一个版本,同时学习ST2: - )



干杯!


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
}

解决方案

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:

<!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>
</html>

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!

这篇关于Sencha touch 2 - 在地图上显示当前位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆