How to get the current location in Google Maps Android API v2?

前端 未结 13 1165
Happy的楠姐
Happy的楠姐 2020-11-27 12:32

Using

mMap.setMyLocationEnabled(true)

can set the myLocation layer enable.
But the problem is how to get the myLocation when the user

13条回答
  •  臣服心动
    2020-11-27 13:23

    At the moment GoogleMap.getMyLocation() always returns null under every circumstance.

    There are currently two bug reports towards Google, that I know of, Issue 40932 and Issue 4644.

    Implementing a LocationListener as brought up earlier would be incorrect because the LocationListener would be out of sync with the LocationOverlay within the new API that you are trying to use.

    Following the tutorial on Vogella's Site, linked earlier by Pramod J George, would give you directions for the Older Google Maps API.

    So I apologize for not giving you a method to retrieve your location by that means. For now the locationListener may be the only means to do it, but I'm sure Google is working on fixing the issue within the new API.

    Also sorry for not posting more links, StackOverlow thinks I'm spam because I have no rep.

    ---- Update on February 4th, 2013 ----

    Google has stated that the issue will be fixed in the next update to the Google Maps API via Issue 4644. I am not sure when the update will occur, but once it does I will edit this post again.

    ---- Update on April 10th, 2013 ----

    Google has stated the issue has been fixed via Issue 4644. It should work now.

提交回复
热议问题