Google Maps API Android v2 - “ACCESS_FINE_LOCATION” permission required with my-location layer enabled

后端 未结 2 659
囚心锁ツ
囚心锁ツ 2020-12-21 00:36

I want to show the location of the user on a Google Maps enabling my-location layer, but this functionality requires the \"ACCESS_FINE_LOCATION\" permission to get the locat

2条回答
  •  南方客
    南方客 (楼主)
    2020-12-21 01:03

    You can use the LocationSource pattern to supply your own locations, which could come from whatever. LocationSource is an interface, which you would implement on some object that can supply location data. You register this with setLocationSource() on the GoogleMap. You implement activate() and deactivate() methods on your LocationSource that will get called to let you know when you should start and stop pushing over locations. As you get location fixes in, you call onLocationChanged() on a supplied OnLocationChangedListener.

    This sample project demonstrates the use of LocationSource.

提交回复
热议问题