简体   繁体   English

Android 实时谷歌地图位置跟踪

[英]Android real-time Google Maps location tracking

I am working on an Android app where players battle each on their phones in real-time based on their location.我正在开发一个 Android 应用程序,玩家可以根据他们的位置在他们的手机上实时对战。 On Google maps, you can see where you are, in what direction you are facing, and where you are moving, all from a little blue dot.在 Google 地图上,您可以通过一个小蓝点看到自己的位置、面向的方向以及移动的位置。 My question is: How can I integrate something like that in my app, so when the player moves, you can see it on the Google Maps fragment?我的问题是:如何在我的应用程序中集成类似的东西,以便当玩家移动时,您可以在 Google 地图片段上看到它?

Edit: Currently, my application drops a new pin every time your location updates.编辑:目前,每次您的位置更新时,我的应用程序都会删除一个新引脚。 I'm looking for something that moves the pin rather then adding a new one.我正在寻找可以移动图钉而不是添加新图钉的东西。

I found a temporary solution!我找到了一个临时解决方案! What I'm doing now is calling map.clear() , and then adding new markers to the places I need... I decided this was best because I am dynamically creating new ones, and not just working with an array, or single marker.我现在正在做的是调用map.clear() ,然后在我需要的地方添加新标记......我认为这是最好的,因为我正在动态创建新标记,而不仅仅是使用数组或单个标记。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM