我一直在寻找答案,但在任何论坛问题中都没有人能够提供帮助.我已经搜索了教程.API 指南 说:
I've looked high and low for an answer on this, and no one, in any forum question has been able to help. I've searched through the tutorials. The API Guide says:
我的位置"按钮出现在屏幕的右上角仅当启用我的位置"图层时.
The My Location button appears in the top right corner of the screen only when the My Location layer is enabled.
所以我一直在寻找这个我的位置"图层,但找不到任何东西.如何在 Google 地图上显示我的位置?
So I've been looking for this My Location layer and have been unable to find anything. How do I show my location on a Google Map?
API 指南完全错了(真的是 Google?).使用 Maps API v2,您无需启用图层来显示自己,只需调用您使用地图创建的 GoogleMaps 实例即可.
The API Guide has it all wrong (really Google?). With Maps API v2 you do not need to enable a layer to show yourself, there is a simple call to the GoogleMaps instance you created with your map.
Google 文档
Google 提供的实际文档可以为您提供答案.你只需要
The actual documentation that Google provides gives you your answer. You just need to
// map is a GoogleMap object
map.isMyLocationEnabled = true
// map is a GoogleMap object
map.setMyLocationEnabled(true);
并观看奇迹发生.
只需确保您拥有位置权限,并且在 API 级别在运行时请求它23(男)或以上
Just make sure that you have location permission and requested it at runtime on API Level 23 (M) or above
这篇关于如何在 Google Maps for Android API v2 上显示我的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!