If you are using google maps v2 just set setMyLocationEnabled(boolean)
to true and it will display your location without you having to do anything
android location listener two functions Google Maps
-
29-05-2022 - |
Domanda
I am working on an app that runs a service that has a location listener, and needs to do things in the background.
I am currently integrating Google Maps in my app, do I need to create a different location listener? Do I use the same one, how?
If someone can point me in the right direction for the right way to do it, I would greatly appreciate it...
Soluzione
Altri suggerimenti
In your location Listener, wherever you get your location, you use the googleMaps change position method call.
googleMap.moveCamera(CameraUpdateFactory.newLatLng(position));
position would be instantiated like so:
LatLng position = new LatLng(location.getLatitude(), location.getLongitude());
That should do what you want it to do. Spend some time looking at the developer guide for google maps.
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow