Sencha touch 2 - 在地图上显示当前位置 [英] Sencha touch 2 - Display current location on map
问题描述
我想显示我的当前位置并获取位置坐标以在附近搜索.从下面的代码开始,在地图上显示我的位置,但它不起作用.
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
}
推荐答案
我认为这是 ST2 中的一个错误.我在 Sencha 论坛中也问过(我认为你做了 :-))这个问题:http://www.sencha.com/forum/showthread.php?156501-Maps-with-sencha-touch
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:
index.html 文件如下所示:
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>
我的 ppl.js 看起来像这样:
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
}]
}]
}
});
如果我将 ppl.js 更改为以下内容:
If I change my ppl.js into the following:
Ext.define('PPL.App', {
extend: 'Ext.Map',
layout: 'fit',
config: {
items: [{
xtype: 'map',
useCurrentLocation: false
}]
}
});
然后就可以了!所以,我认为我们需要等到下一个版本,同时学习 ST2 :-)
Then it is working! So, I think we need to wait untill next release, in the mean time learn ST2 :-)
干杯!
这篇关于Sencha touch 2 - 在地图上显示当前位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!