how to get current location in google map android

前端 未结 17 2005
长发绾君心
长发绾君心 2020-11-27 14:04

Actually my problem is I am not getting current location latitude and longitude I tried so many ways.I know that this question already asked in SO I tried that answers also

17条回答
  •  北荒
    北荒 (楼主)
    2020-11-27 14:59

    Your current location might not be available immediately, after the map fragment is initialized.

    After set

    googleMap.setMyLocationEnabled(true);
    

    you have to wait until you see the blue dot shown on your MapView. Then

    Location myLocation = googleMap.getMyLocation();
    

    myLocation won't be null.

    I think you better use the LocationClient instead, and implement your own LocationListener.onLocationChanged(Location l)

    Receiving Location Updates will show you how to get current location from LocationClient

提交回复
热议问题