无法获取当前位置
我正在开发一个 Titanium 应用程序(目前针对 iPhone 部署,但最终旨在跨平台),它要求我识别多个机构位置并显示距手机当前位置到每个机构的距离。当我尝试使用 Titanium 的 Ti.Geolocation.getCurrentPosition()
API 确定我的当前位置时,我收到的只是以下消息:位置服务已禁用。
我正在 iPhone 模拟器中进行测试,并且我读到了关于位置服务是否可以在安装了 Xcode 4.x 的模拟器中工作(我正在运行 4.2)的相互矛盾的消息,所以我想我应该在这里询问更广泛的受众:
- 我应该能够使用 Xcode 4.2 识别我在模拟器中的当前位置吗?
- 如果是这样,我需要做什么才能启用定位服务?我还没有找到任何可以启用这些服务的东西。
无论它的价值如何,这里是我尝试运行的代码的相关片段:
// purpose is required for iPhone 3.2+
Ti.Geolocation.purpose = 'Determine the current distance to each Inova Health System location.';
Ti.Geolocation.getCurrentPosition( function( e ) {
alert( e.coords );
});
感谢您的帮助。
I'm working on a Titanium app (currently targeted for iPhone deployment, but ultimately intended to be cross-platform) that requires me to identify several institution locations and display the distance to each from the phone's current location. When I try to determine my current location using Titanium's Ti.Geolocation.getCurrentPosition()
API, all I get is this message: Location Services Disabled.
I'm testing in the iPhone simulator and I've read conflicting messages about whether location services work in the simulator with Xcode 4.x installed (I'm running 4.2) so I thought I'd ask a wider audience here:
- Should I be able to identify my current position in the simulator using Xcode 4.2?
- If so, what do I need to do to enable location services? I have yet to find anything that works to enable these services.
For whatever it may be worth, here's the relevant snippet of the code I'm trying to run:
// purpose is required for iPhone 3.2+
Ti.Geolocation.purpose = 'Determine the current distance to each Inova Health System location.';
Ti.Geolocation.getCurrentPosition( function( e ) {
alert( e.coords );
});
Thanks for your help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 Xcode 4.2,模拟器位置服务再次工作。所以是的,您甚至可以设置位置。调试->地点和清单应该有。
但您收到的消息看起来像是您的应用程序的位置服务可能被禁用,请检查模拟器中的设置应用程序,并在真实设备上检查。
With Xcode 4.2 the simulator location service worked again. So yes, you can even set the location. Debug -> Location and there should be a list.
But the message you got looks like the location service might be disabled for your app, go and check the settings app in the simulator and also check on a real device.