In my application, I am showing map with marker at the current location s latitude and longitude.And I use Map.setMyLocationEnabled(true) for user to interact with their location.
What my problem is setMyLocationEnabled method and my location - lat,long code is marks different positions as follows:
<img src="https://i.stack.imgur.com/SdZ7e.png" alt="Map">
I have used the following code to get Latitude and Longitude of current location:
LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); Criteria criteria = new Criteria(); provider = locationManager.getBestProvider(criteria, true); Location location = locationManager.getLastKnownLocation(provider); if(location!=null){ latitude = location.getLatitude(); longitude = location.getLongitude(); --------- }
How to get accurate latitude and longitude of my current location as google s setLocationEnabled provided?
Green flag marker is my marker and blue dot is android provided.