想在我的应用程序中创建谷歌地图导航 - 自定义的方式我的、自定义、应用程序、方式

2023-09-13 01:45:52 作者:花落微凉梦清幽

我已经创建了,而我试图通过动画标记的位置显示用户的移动应用程序。

I have created an application in which I am trying to show user's movement by animating marker position.

在使用谷歌地图V2。 使用位置客户端在位置更新。 在使用新的位置的动画标记。 Using Google map V2. Location updates using location client. Animating marker using new location.

不过,与谷歌地图导航相比,存在渲染导航没有连续性。

But comparing with Google map navigation, there is no continuity in rendering navigation.

任何人都可以提出一个更好的办法?谢谢!

Can anyone suggest a better approach? Thanks!

推荐答案

有关连续性,我认为你需要通过给位置请求这样来从位置​​客户端定期位置更新。

For continuity, I think you need to fetch regular location updates from location client by giving location request like this.

LocationRequest request = LocationRequest.create()
                .setInterval(0).setFastestInterval(0)
                .setSmallestDisplacement(0)
                .setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);

那么对于流畅的动画,你可以按照史蒂夫贝内特提到的方法。 here

您在对路径的注释中提到的最后一种情况。我也是在我的应用程序之一,有同样的问题。我试着用GPS路线模拟器的应用程序,以嘲笑的路线。再对比我的应用程序和谷歌地图,GoogleMap的遵循了正确道路的路径,而我的应用程序的标志物在动略微从公路转移。然后,我尝试了一些调整与标记。像这样

The last case you mentioned in the comment about the path. I also had the same issue in one of my app. I tried with gps route simulator app to mock a route. then comparing my app and google map, googlemap followed the correct road path while my app's marker was moving slightly shifted from road. Then I tried some tweaks with marker. Like this

mPositionMarker = mMap.addMarker(new MarkerOptions()
                .flat(true)
                .icon(BitmapDescriptorFactory
                        .fromResource(R.drawable.positionIndicator))
                .anchor(0.5f, 0.5f)
                .position(
                        new LatLng(location.getLatitude(), location
                                .getLongitude())));

这为我工作。这个定位我的标记在同一个位置的谷歌地图。 (取决于所在的位置的精度虽然)。

This worked for me. This positioned my marker on same location as of google map. (Depends on the accuracy of location though).

感谢您的回答here