问题标签 [location-provider]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
2 回答
4240 浏览

angularjs - AngularJS:打开 html5mode(true) 时,相对链接路径被破坏

我一直在寻找,我找到了这个问题的“解决方案”,但我仍然无法让它正常工作。

场景:

我正在使用 UI 路由器构建一个 Angular(1.2 版)网站,并在 localhost 的节点服务器上运行它。我试图通过 $locationProvider 并打开 html5(true) 使其具有“漂亮”的 url。我的网站在单击时工作正常,但是当我尝试导航到相对链接路径或刷新链接路径时,页面会中断。我还打算在完成后将此 webapp 部署到 Heroku:

相对链接路径:

页输出结果


我采取的步骤:

1.)在我的“index.html”<head> 中,我将基本 url 设置为:

2.)在我的 app.js 文件(对于 Angular)中,我将其编写如下:

3.)在我的导航中,我的 html 写成:

4.)我的 server.js 文件(节点服务器)

最好的解决方案是什么?在此先感谢您的帮助。

0 投票
1 回答
486 浏览

angularjs - 带参数的 htm5mode 对我不起作用

第一手,这是我的代码:

配置应用程序:

我的控制器 BlogPostController:

我的博客.html

点击进入帖子时,根据$route.current.templateUrl加载模板blog_post.html,但浏览器显示的内容与blog.html相同,不显示blog_post.html模板的内容。如果没有 html5mode,这可以正常工作并且没有问题。也许 html5mode 不适用于参数链接 (/blog_edit/:blogId)。下面我用图像更好地解释这一点。

使用 html5mode 启用:

  1. 我在博客菜单中,我要点击一个帖子:(模板是blog.html) 在此处输入图像描述

  2. 单击帖子时,当前路由器将模板更改为 blog_post.html,但浏览器向我显示相同的模板 blog.html: 在此处输入图像描述

使用 html5mode 禁用:

  1. 当我在 blog.html 模板中并且我要点击帖子时: 在此处输入图像描述

  2. 当我已经点击了帖子。现在它正确地向我展示了 blog_post.html 模板: 在此处输入图像描述

0 投票
0 回答
128 浏览

android - FusedLocationProvider 在打开 GPS 的情况下更快地找到位置

我的 android 应用程序依赖于位置。但是,我将其用作抽象层的 FusedLocationProvider,这样我就不必担心要使用什么 LocationProvider,它的行为出乎意料。

场景:用户打开应用程序。我检查提供商的可用性并打开位置设置页面。用户启用“访问我的位置”以及 GPS 和 Wi-Fi 位置。当用户返回应用程序时,我没有收到任何位置更新。

当我关闭 GPS 并在系统设置中只允许 Wi-Fi 时,我会得到一个更新的位置。

我尝试了优先级PRIORITY_LOW_POWERPRIORITY_BALANCED_POWER_ACCURACY当 GPS 关闭时,两者都没有给我位置更新。

它是怎么来的,位置检测在 GPS 关闭时有效,而在 GPS 开启时无效?这有任何意义吗?

当 GPS 关闭时,我获得的位置对于应用程序正在执行的操作来说足够准确。如果设备已长时间打开 LocationServices(包括手机在外面),即使打开 GPS,我也会收到位置更新。

有人对此有解释/知道如何解决这个问题吗?

0 投票
1 回答
947 浏览

android - RequestLocationUpdate 与 Pending Intent 以及如何获取位置提供者(GPS、网络)状态?

我使用 Android SDK Location Manager 来获取用户位置。

我正在使用 Pending Intent 请求位置信息。我使用了挂起的意图,因为即使应用程序没有运行,我也需要发送位置信息。

使用上述代码注册后,我将在 LocationIntentService 类的 onHandleIntent 处获取位置信息。

但我没有 onProviderEnabled 或 onProviderDisabled 方法来监听 gps 和网络提供商状态。而且我也不想使用融合的位置 api。

如何通过使用 Pending Intent 请求位置更新来实现这两个目标。或者以任何其他方式注册位置信息以及位置提供者状态。

0 投票
1 回答
1144 浏览

android - 如果应用程序未运行,则在位置更改时执行代码

我正在编写一个小型 android 应用程序,当设计更改位置时需要执行一些代码。我想知道即使应用程序没有运行(不是后台而是停止),是否可以在位置更改时执行代码。我的意思是,当 lat/lng 发生变化时,是否有一些系统服务会“唤醒”(或启动)我的应用程序(或我的应用程序的特定活动)?

到目前为止,我已经创建了一个locationManager,设置了一些条件,一个提供者并设置了requestLocationUpdates。这是有效的,但如果应用程序没有运行,我没有更新。

0 投票
1 回答
880 浏览

javascript - Alternative to the use of hashbangs in the url to resolve IE9 issue

I'm creating a search application in angularjs with these settings:

App Config:

The problem is not the app itself but when im trying to access the page with IE9 im not able to access it at all. After doing som reading i found out that IE9 ignores everyting that comes after the # in an url, and redirects the user back to the host url (everything before the # in the url) And the standard fallback for html5mode is hashbang-mode. Angular docs for $location

My question is if anyone knows if there is any way around the use of hashbangs in the url or if anyone else have this problem. If more documentation is needed, please let me know and i will provide!

EDIT: This is inside the controller:

EDIT: Adding $locationProvider.hashPrefix('!'); will not work because it will only add a "!" after the "#" in the url.

See image from angular docs:

Angular docs on locationprovider

0 投票
1 回答
337 浏览

android - Android Location API 未正确跟踪用户

我有一个后台服务,它应该跟踪用户的汽车移动,并将数据发送到我的服务器。我有两个用于发送位置的变量,要么已经过去了 60 秒,要么用户已经移动了 100 米。

在我的服务中,这是我开始收听位置的方式:

和听众:

因此,当服务正在运行并且我开着车四处行驶时,onLocationChanged 只会触发几次,它没有考虑触发位置读取的时间或米数。我有数据连接,并且在服务运行的整个过程中,通知栏上都可以看到 GPS 图标。

任何想法为什么不工作?

0 投票
1 回答
199 浏览

php - 按坐标搜索附近的位置?

我正在尝试为我们的移动开发人员创建一个 Web 服务。

我有位置坐标数据库。给定坐标,如何返回附近坐标的结果?可以说在100英里的半径范围内。

任何的想法?

0 投票
13 回答
260084 浏览

android - 在Android后台获取用户GPS位置的最佳方法

在我的 android 应用程序中,我想每隔几分钟获取用户当前位置,并使用 Web 服务更新到我的中心服务器。目前我正在使用 Fused Location Provide 获取用户当前位置,请参阅链接

现在我想知道经常获取用户位置并调用网络服务的最佳方法是什么。

下面是我的代码,它给了我用户当前的位置: -

现在我必须从那里调用此代码。我可以在后台服务或其他地方使用它吗?

请提供您的想法。

TIA。

0 投票
1 回答
1316 浏览

android - 不使用 google play 服务的 GPS 位置提供商

我有一个带有 GPS 芯片的 android 设备,我想使用它来获取位置,但该设备没有安装 google play 服务(它不支持 google play 服务)。所以我无法使用 android standard LocationManager

有人对如何获取位置有建议吗?