[英]Gps LocationListenser for GoogleMaps V2 in android
I am trying to understand the relationship between googlemaps LatLng
and Location class
. 我想了解googlemaps
LatLng
和Location class
之间的关系。 Are they convertable ? 他们可以兑换吗? I am using
我在用
GoogleMaps v2
GoogleMaps v2
in my application so How can I use my GPS To locate my position on maps 在我的应用程序中,因此如何使用GPS在地图上定位我的位置
You can call setMyLocationEnabled(true)
on your GoogleMap
and then just call getMyLocation()
periodically, if you wish. 您可以在
GoogleMap
上调用setMyLocationEnabled(true)
,然后根据需要定期调用getMyLocation()
。 Otherwise, in addition to calling setMyLocationEnabled(true)
, you can: 否则,除了调用
setMyLocationEnabled(true)
,您还可以:
Step #1: Set up a LocationListener
using LocationManager
. 第1步:设置
LocationListener
使用LocationManager
。
Step #2: Call setLocationSource()
on your GoogleMap
, supplying a LocationSource
implementation 步骤#2:在您的
GoogleMap
上调用setLocationSource()
,以提供LocationSource
实现
Step #3: In the LocationSource
implementation, hold onto the listener object supplied to you in activate()
步骤#3:在
LocationSource
实现中,保持在activate()
提供给您的侦听器对象上
Step #4: When location fixes come into your LocationListener
, pass them to the listener you were provided in activate()
步骤#4:当位置修复程序进入您的
LocationListener
,将其传递给activate()
中提供的侦听器
Here is a sample project demonstrating this. 这是一个演示此的示例项目 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.