Google Maps&使用mapview的应用程序有不同的当前位置

编程入门 行业动态 更新时间:2024-10-19 12:44:45
本文介绍了Google Maps&使用mapview的应用程序有不同的当前位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个mapview,我想跟踪用户的当前位置。 GPS以及'使用无线网络'在我的手机设置中被激活。 尽管如此,由于我在室内,我没有获得GPS定位,因此该位置是通过网络确定的;无线网点是可用的。

我有Google地图应用程序以及我的应用程序在运行。

奇怪地,当前位置在谷歌地图和我的应用程序之间不一样,谷歌地图非常准确,而在我的应用程序中,位置在某种程度上偏离了几百米。

在我的应用程序我基本上执行以下操作(现在为了调试目的):

1)最初在地图上放置一个标记:通过 locationManager.getLastKnownLocation (LocationManager.GPS_PROVIDER);

2)最初在地图上放置另一个标记:通过 locationManager.getLastKnownLocation (LocationManager.NETWORK_PROVIDER);

这会将这两个提供者的最后已知位置放到地图上(最终从我的应用程序外部最后知道) 。 $ b 3)然后进行定期更新(因为我无法在室内获得GPS修正),我这样做:

locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER,0,0,baseLocationListener);

在这两种情况下,您都可以看到我通过0参数的频率和距离。

在应用清单中,授予以下权限:

android.permission。 ACCESS_COARSE_LOCATION android.permission.ACCESS_FINE_LOCATION android.permission.ACCESS_MOCK_LOCATION

其实我的baseLocationListener确实被调用,我在日志中看到,但更新的位置与最后一个已知的当前位置(LocationManager.NETWORK_PROVIDER)相同,经纬度相同。

我想也许我忽略了一些东西或错过了一个参数或设置,或者我的代码有一个错误。因此我从Android市场安装了其他一些(总共3个)LBS应用程序,这些应用程序还显示当前用户的位置。这些应用程序中显示的当前位置与我的应用程序中显示的位置相同 - 它们都距离约100米 - 但至少都是相同的。

在这里查看屏幕截图: 截图img33.imageshack.us /img33/8679/mapproblem.png

img33.imageshack.us/img33/8679/mapproblem.png

现在我想知道:

1)据我所知,getLastKnowLocation是系统范围的,而不是应用程序范围的,为什么Google地图中的位置与所有其他应用程序之间存在差异? 2)Google地图是否不更新提供商的lastKnownLocation?

b 3)Google地图是否使用除GPS_PROVIDER或NETW以外的其他自定义位置提供商(即由于许可原因) ORK_PROVIDER,因为它们在SDK中?

4)如何通过NETWORK_PROVIDER实现与Google地图相同的准确结果?

解决方案

我想我找到了答案,虽然不是解决方案。看起来问题在于用于Google地图和SDK中的MapView的不同地图提供程序的数据质量,它们有所不同。

t似乎是非常准确的,就像在公共Google Maps Web api / tiles中一样。

请参阅此屏幕截图,其中列出了相同的地理位置。 截图img339.imageshack.us/img339/2793/gmaps2 .png img339.imageshack.us/i /gmaps2.png/

使用公共地图api的地图距离几百米。 似乎我们只需要忍受它?! :(

I have a mapview where I want to track the user's current location. GPS as well as 'use wireless networks' is activated in my phone settings. Nevertheless, since I'm indoor I don't get a GPS fix, therefore the location is determined via network; wifi spot is available.

I have the Google Maps app running as well as my application running.

Strangely, the current location differes between Google Maps and my application, where the Google Maps is very accurate while in my app the location is somehow off a few 100 meters.

In my application I basically do the following (for debugging purposes now):

1) initially place one marker on the map: geopoint retrieved via locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);

2) initially place another marker on the map: geopoint retrieved via locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);

This will put the last known locations of both providers onto the map (eventually last known from outside my app).

3) then for the regular updates (since I don't get a GPS fix anyway indoor here), I do:

locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, baseLocationListener);

You can see for the frequency and distance I pass the 0 param in both cases.

In the app manifest, the following permissions are granted:

android.permission.ACCESS_COARSE_LOCATION android.permission.ACCESS_FINE_LOCATION android.permission.ACCESS_MOCK_LOCATION

Actually my baseLocationListener does get called, which I see in the log, but the updated location is somehow the same as the last known current position (of LocationManager.NETWORK_PROVIDER), same lat/lng.

I thought maybe I overlooked something or missed a parameter or setting, or my code has a bug. Therefore I installed some other (3 in total) LBS apps from the Android market that also show the current user's location. The current locations displayed in those apps are equals to the one in my application - and they're all some 100 meters off - but at least all the same.

See the screenshot here: screenshot img33.imageshack.us/img33/8679/mapproblem.png

img33.imageshack.us/img33/8679/mapproblem.png

Now I am wondering:

1) as I understand, getLastKnowLocation is system-wide and not app-wide, why are there differences between the location in Google maps and all the other apps?

2) does Google Maps not update the lastKnownLocation of a provider?

3) does Google Maps use a different custom location provider (i.e. due to licensing reasons) other than GPS_PROVIDER or NETWORK_PROVIDER as they are in the SDK?

4) how do achieve the same accurate result with the NETWORK_PROVIDER like Google Maps does?

解决方案

I think I found an answer, although not a solution. It seems that the problem is in the data quality of the different map provider that are used for Google Maps and MapView in SDK, which differ.

The map tiles coordinates don't seem to be very accurate, just like in the public google maps web api / tiles.

See this screenshot for an example, where I pinned the same geo point. screenshot img339.imageshack.us/img339/2793/gmaps2.png img339.imageshack.us/i/gmaps2.png/

The map using the public map api is off a few hundred meters. Seems that we just have to live with it ?! :(

更多推荐

Google Maps&使用mapview的应用程序有不同的当前位置

本文发布于:2023-11-27 19:04:13,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:当前位置   应用程序   Maps   Google   mapview

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!