How To Get The Coordinates Of The Blue Dot In Android Maps V2
Solution 1:
Locationfindme= mMap.getMyLocation();
doublelatitude= findme.getLatitude();
doublelongitude= findme.getLongitude();
LatLnglatLng=newLatLng(latitude, longitude);
This will give you latitude and longitude of your location.
Solution 2:
Since googlemyMap.getMyLocation() method is deprecated...
Best simple solution so far that i found
Getting current location and center the camera on marker. Android Studio editor see there is a error but when you run it there is no problem with the code.
LocationManagerlocationManager= (LocationManager) getSystemService(Context.LOCATION_SERVICE);
Criteriacriteria=newCriteria();
Locationlocation= locationManager.getLastKnownLocation(locationManager.getBestProvider(criteria,false));
if (location != null)
{ mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(newLatLng(location.getLatitude(), location.getLongitude()), 13));
LocationManagerlocationManager= (LocationManager) getSystemService(Context.LOCATION_SERVICE);
Criteriacriteria=newCriteria();
Locationlocation= locationManager.getLastKnownLocation(locationManager.getBestProvider(criteria,false));
if (location != null)
{
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(newLatLng(location.getLatitude(), location.getLongitude()), 13));
CameraPositioncameraPosition=newCameraPosition.Builder()
.target(newLatLng(location.getLatitude(), location.getLongitude())) // Sets the center of the map to location user
.zoom(17) // Sets the zoom
.build(); // Creates a CameraPosition from the builder
mMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
}
LatLnggoztepe=newLatLng(location.getLatitude(), location.getLongitude());
mMap.addMarker(newMarkerOptions().position(goztepe).title("Göz Göz GÖZTEPE"));
explained here .
Solution 3:
The original answer was to use setMyLocationChangeListener()
on GoogleMap
, to be notified of "blue dot" changes. That is now deprecated.
If you can create a sample project that reproduces your problem, you may wish to file an issue, attaching that project. What you are doing is the official replacement for the deprecated methods, and so one would hope that your code would work properly. If you do file an issue, and if you think of it, post a link to it here, as I'd like to keep an eye on it.
Solution 4:
It was actually a really stupid mistake I did.
But here is the answer. The procedure described in the link in the question is the right thing to do.
My problem was that I saved the fetched data to a new shared preferences key, and I was reading it from the old one where the wrong location was saved. Yeah it is pretty dumb :)
So follow the tutorial on android developer portal and there will be no mistakes with it.
Post a Comment for "How To Get The Coordinates Of The Blue Dot In Android Maps V2"